A library for fetching and caching historical market data from Breeze API using DynamoDB
Project description
Breeze Historical
A Python library for fetching and caching historical market data from ICICI Direct's Breeze API using DynamoDB.
Features
- Fetch historical option chain data from Breeze API
- Cache data in DynamoDB for faster subsequent access
- Support for multiple timeframes (1min, 5min, 30min, daily)
- Automatic symbol mapping between NSE and ICICI Direct
- Data interpolation for missing timestamps
- Market hours aware timestamp generation
- Verbose mode for detailed operation logging
- Handles missing data through interpolation
- Supports multiple expiry dates
Installation
pip install breeze-historical
Prerequisites
- ICICI Direct Breeze API credentials
- AWS credentials with DynamoDB access
- DynamoDB table with the following schema:
- Partition Key:
contract_id(String) - Sort Key:
ts(String)
- Partition Key:
Configuration
The library requires both Breeze API and AWS credentials:
Breeze Credentials
api_key: Your Breeze API keyapi_secret: Your Breeze API secretuser_id: Your Breeze user IDpassword: Your Breeze passwordtotp_key: Your TOTP secret key
AWS Credentials
access_key_id: AWS access key IDsecret_access_key: AWS secret access keyregion: AWS region (default: "ap-south-1")table_name: DynamoDB table name (default: "breeze_historical")
Usage
from breeze_historical import BreezeHistorical
# Initialize credentials
breeze_creds = {
"api_key": "your_api_key",
"api_secret": "your_api_secret",
"user_id": "your_user_id",
"password": "your_password",
"totp_key": "your_totp_key"
}
aws_creds = {
"access_key_id": "your_aws_access_key",
"secret_access_key": "your_aws_secret_key",
"region": "ap-south-1",
"table_name": "breeze_historical"
}
# Initialize client
client = BreezeHistorical(
breeze_creds=breeze_creds,
aws_creds=aws_creds,
verbose=False # Set to True for detailed operation logging
)
# Fetch option chain data
data = client.option_chain(
symbol="BANKNIFTY",
expiry="2024-03-28",
start_date="2024-03-20",
end_date="2024-03-21",
granularity="5minute"
)
# Data format:
{
"2024-01-01T09:15:00.000Z": {
45000: {
"CE": {
"open": 100.5,
"high": 102.0,
"low": 99.5,
"close": 101.0,
"volume": 1000,
"oi": 5000
},
"PE": {
...
}
},
45500: {
...
}
},
"2024-01-01T09:16:00.000Z": {
...
}
}
Verbose Mode
The library includes a verbose mode that provides detailed logging of operations:
- Set
verbose=Truewhen initializing the client to enable detailed logging - Logs include:
- Client initialization status
- Data fetching progress
- Cache hit/miss information
- Symbol mapping details
- Strike price discovery
- Data processing steps
- Interpolation of missing data
Example with verbose mode:
client = BreezeHistorical(
breeze_creds=breeze_creds,
aws_creds=aws_creds,
verbose=True # Enable verbose mode
)
Symbol Mapping
Create a JSON file with NSE to ICICI Direct symbol mapping:
{
"BANKNIFTY": "CNXBAN",
"NIFTY": "CNX",
...
}
Error Handling
The library raises BreezeHistoricalError for various error conditions:
- Invalid date ranges
- API failures
- Authentication issues
- Data validation errors
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file breeze_historical-0.1.2.tar.gz.
File metadata
- Download URL: breeze_historical-0.1.2.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f891cd49b9e6fda557cae6d305c6d4d2f46e0be4e8f43bdeaa2e3b5a817deb77
|
|
| MD5 |
7d28c9e5c507d8d3b07f8aa0bf90aa31
|
|
| BLAKE2b-256 |
7504e0b57705dab5ad7d3d752bc4417fa19439398ff6b8f6bd3ae956c8c0795c
|
File details
Details for the file breeze_historical-0.1.2-py3-none-any.whl.
File metadata
- Download URL: breeze_historical-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14e710378ea61f5a821fb5289e4ec778b270e70c0d3d95eb894ed5dad9ba4f36
|
|
| MD5 |
8425d2f931c7318971aff5403c48b122
|
|
| BLAKE2b-256 |
d443ec191f8fe58bbf6539eb524fdd0ecb2d97ff13d203bc731f8aa1098edebf
|