Skip to main content

breeze-historical-options

Introduction

breeze-historical-options provides historic options data(starting from seconds) using the ICICI Breeze API. Data can be used for backtesting, analysis and simulation purposes. All you need is a free ICICI direct account to access Breeze API.

Referral Link - https://secure.icicidirect.com/accountopening?rfrlcode=8510403004&utm_source=referral&utm_medium=referral&utm_campaign=OAO2.0

Installation

  • Clone or download the repository using:
git clone https://github.com/madmay247/breeze-historical-options.git

or using PyPi Package:

pip install breeze-historical-options
  • Create Virtual Environment
  • Install required dependencies(if using git clone):
pip install -r requirements.txt

Usage

  • Fill in cred.yml with your Breeze API keys and credentials.
  • Adjust parameters in example.py as needed (e.g., expiry dates, time range, scrip, strike range, path).
  • Run the script:
python example.py
  • Data will be fetched and saved to the specified path.

Files Explanation

  • sample_cred.yml: Template for API credentials.
  • expiries.json: Contains a list of expiry dates for options data.
  • example.py: Main script to fetch data using the package.

Login Code

from datetime import datetime
from breeze_connect import BreezeConnect
from BreezeHistoricalOptions import autologin, Breezy
import json, yaml, time

with open('cred.yml') as f:
    cred = yaml.load(f, Loader=yaml.FullLoader)
    
breeze = BreezeConnect(api_key=cred['api_key'])

try:
    session_key = autologin.get_session_key(cred=cred, force=False)
except:
    session_key = autologin.get_session_key(cred=cred, force=True)
    
    
breeze.generate_session(api_secret=cred['api_secret'],
                        session_token=session_key)

Fetch Data Function

from datetime import datetime
from breeze_connect import BreezeConnect
from BreezeHistoricalOptions import autologin, Breezy
import json, yaml, time

expiry_date = "06-Dec-2023" # 'expiries.json' contains a list of expiry dates in this format
start_datetime = "06-Dec-2023 9:15:00" 
end_datetime = "06-Dec-2023 15:29:59" 

Breezy.fetch_data(
                api = breeze,
                scrip = "CNXBAN",  # 'NIFTY' for Nifty 50 | 'CNXBAN' for Bank Nifty | 'NIFFIN' for Finnifty | 'NIFMID' for Midcap Nifty
                exch = "NFO",
                expiry_date = datetime.strptime(expiry_date, "%d-%b-%Y"),
                start_datetime = datetime.strptime(start_datetime, "%d-%b-%Y %H:%M:%S"),
                end_datetime = datetime.strptime(end_datetime, "%d-%b-%Y %H:%M:%S"),
                start_strike = 47000,
                end_strike = 47200,
                step = 100,
                max_threads = 3, #Set this to 1 if you are getting api breeze_historical_v2() error
                export_path = 'HistoricData/' #will auto-create path if it doesn't exist
                )

Contributing

Contributions are welcome. Please fork the repository, make your changes, and submit a pull request.

Support

Consider supporting via using this referral link for ICICI Direct account: https://secure.icicidirect.com/accountopening?rfrlcode=8510403004&utm_source=referral&utm_medium=referral&utm_campaign=OAO2.0

Usage Video

https://github.com/madmay247/breeze-historical-options/assets/132202725/3047a80e-1ae3-44f4-ac20-f1445375e0cf

Metadata

Release files for breeze-historical-options 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for breeze-historical-options 1.2
File Size Uploaded Provenance Actions
breeze-historical-options-1.2.tar.gz 7.8 kB Without provenance Details for breeze-historical-options-1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for breeze-historical-options 1.2
File Interpreter ABI Platform Actions
breeze_historical_options-1.2-py3-none-any.whl Python 3 none any Details for breeze_historical_options-1.2-py3-none-any.whl

Total release size: 16.4 kB

Release files / breeze-historical-options-1.2.tar.gz

Download URL breeze-historical-options-1.2.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
96eec9fcacfb9e1d78317f9408e795f7aa2b84640ed80dee1525da89c2221e28
BLAKE2b-256 checksum
How to use checksums
f32297a4b6ccae1231d08b4c9106822957c98bd62eb5c361dc129a947545922c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / breeze_historical_options-1.2-py3-none-any.whl

Download URL breeze_historical_options-1.2-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5071c58f255d9dc7e55b6a8c160cd55fb5d469be6e0a32b358f21f727f4f47c
BLAKE2b-256 checksum
How to use checksums
f7b90ed43e781a53ce2af674122f441201bae78c8564a94e6c98740412114e9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for breeze-historical-options 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page