Metadata-Version: 2.1
Name: breeze-historical-options
Version: 1.1
Summary: A Python package for easily downloading historical options data
Home-page: https://github.com/madmay247/breeze-historical-options
Author: Mayank Rai
Author-email: mrai748@gmail.com
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: asttokens ==2.4.1
Requires-Dist: attrs ==23.1.0
Requires-Dist: bidict ==0.22.1
Requires-Dist: breeze-connect ==1.0.43
Requires-Dist: certifi ==2023.11.17
Requires-Dist: cffi ==1.16.0
Requires-Dist: charset-normalizer ==3.3.2
Requires-Dist: colorama ==0.4.6
Requires-Dist: comm ==0.2.0
Requires-Dist: debugpy ==1.8.0
Requires-Dist: decorator ==5.1.1
Requires-Dist: executing ==2.0.1
Requires-Dist: h11 ==0.14.0
Requires-Dist: idna ==3.6
Requires-Dist: jedi ==0.19.1
Requires-Dist: matplotlib-inline ==0.1.6
Requires-Dist: nest-asyncio ==1.5.8
Requires-Dist: numpy ==1.26.2
Requires-Dist: outcome ==1.3.0.post0
Requires-Dist: packaging ==23.2
Requires-Dist: pandas ==2.1.4
Requires-Dist: parso ==0.8.3
Requires-Dist: platformdirs ==4.1.0
Requires-Dist: prompt-toolkit ==3.0.41
Requires-Dist: psutil ==5.9.6
Requires-Dist: pure-eval ==0.2.2
Requires-Dist: pycparser ==2.21
Requires-Dist: Pygments ==2.17.2
Requires-Dist: pyotp ==2.9.0
Requires-Dist: PySocks ==1.7.1
Requires-Dist: python-dateutil ==2.8.2
Requires-Dist: python-dotenv ==1.0.0
Requires-Dist: python-engineio ==4.8.0
Requires-Dist: python-socketio ==5.10.0
Requires-Dist: pytz ==2023.3.post1
Requires-Dist: pywin32 ==306
Requires-Dist: PyYAML ==6.0.1
Requires-Dist: pyzmq ==25.1.2
Requires-Dist: requests ==2.31.0
Requires-Dist: selenium ==4.16.0
Requires-Dist: simple-websocket ==1.0.0
Requires-Dist: six ==1.16.0
Requires-Dist: sniffio ==1.3.0
Requires-Dist: sortedcontainers ==2.4.0
Requires-Dist: stack-data ==0.6.3
Requires-Dist: tornado ==6.4
Requires-Dist: traitlets ==5.14.0
Requires-Dist: trio ==0.23.1
Requires-Dist: trio-websocket ==0.11.1
Requires-Dist: tzdata ==2023.3
Requires-Dist: urllib3 ==2.1.0
Requires-Dist: wcwidth ==0.2.12
Requires-Dist: webdriver-manager ==4.0.1
Requires-Dist: websocket-client ==1.7.0
Requires-Dist: wsproto ==1.2.0

# breeze-historical-options

## Introduction
breeze-historical-options provides traders with second-level historic options data using the ICICI Breeze API. Data can be used for backtesting, analysis and simulation purposes.

## Installation
- Clone or download the repository.
- Install Python and required dependencies: `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).
- 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.

## Fetch Data Function
```python
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
                )
```
## Login Code
```python
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)
```
## Contributing
Contributions are welcome. Please fork the repository, make your changes, and submit a pull request.
