breeze-historical-options


Namebreeze-historical-options JSON
Version 1.1 PyPI version JSON
download
home_pagehttps://github.com/madmay247/breeze-historical-options
SummaryA Python package for easily downloading historical options data
upload_time2023-12-12 05:38:48
maintainer
docs_urlNone
authorMayank Rai
requires_python>=3.9
license
keywords
VCS
bugtrack_url
requirements asttokens attrs bidict breeze-connect certifi cffi charset-normalizer colorama comm debugpy decorator executing h11 idna jedi matplotlib-inline nest-asyncio numpy outcome packaging pandas parso platformdirs prompt-toolkit psutil pure-eval pycparser Pygments pyotp PySocks python-dateutil python-dotenv python-engineio python-socketio pytz pywin32 PyYAML pyzmq requests selenium simple-websocket six sniffio sortedcontainers stack-data tornado traitlets trio trio-websocket tzdata urllib3 wcwidth webdriver-manager websocket-client wsproto
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/madmay247/breeze-historical-options",
    "name": "breeze-historical-options",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mayank Rai",
    "author_email": "mrai748@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/c6/4c4783c751d88033d2ffd7b1a68aed1875948094e5ee6073182aa556471e/breeze-historical-options-1.1.tar.gz",
    "platform": null,
    "description": "# breeze-historical-options\r\n\r\n## Introduction\r\nbreeze-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.\r\n\r\n## Installation\r\n- Clone or download the repository.\r\n- Install Python and required dependencies: `pip install -r requirements.txt`.\r\n\r\n## Usage\r\n- Fill in `cred.yml` with your Breeze API keys and credentials.\r\n- Adjust parameters in `example.py` as needed (e.g., expiry dates, time range, scrip, strike range).\r\n- Run the script: `python example.py`.\r\n- Data will be fetched and saved to the specified path.\r\n\r\n## Files Explanation\r\n- `sample_cred.yml`: Template for API credentials.\r\n- `expiries.json`: Contains a list of expiry dates for options data.\r\n- `example.py`: Main script to fetch data using the package.\r\n\r\n## Fetch Data Function\r\n```python\r\nfrom datetime import datetime\r\nfrom breeze_connect import BreezeConnect\r\nfrom BreezeHistoricalOptions import autologin, Breezy\r\nimport json, yaml, time\r\n\r\nexpiry_date = \"06-Dec-2023\" # 'expiries.json' contains a list of expiry dates in this format\r\nstart_datetime = \"06-Dec-2023 9:15:00\" \r\nend_datetime = \"06-Dec-2023 15:29:59\" \r\n\r\nBreezy.fetch_data(\r\n                api = breeze,\r\n                scrip = \"CNXBAN\",  # 'NIFTY' for Nifty 50 | 'CNXBAN' for Bank Nifty | 'NIFFIN' for Finnifty | 'NIFMID' for Midcap Nifty\r\n                exch = \"NFO\",\r\n                expiry_date = datetime.strptime(expiry_date, \"%d-%b-%Y\"),\r\n                start_datetime = datetime.strptime(start_datetime, \"%d-%b-%Y %H:%M:%S\"),\r\n                end_datetime = datetime.strptime(end_datetime, \"%d-%b-%Y %H:%M:%S\"),\r\n                start_strike = 47000,\r\n                end_strike = 47200,\r\n                step = 100,\r\n                max_threads = 3, #Set this to 1 if you are getting api breeze_historical_v2() error\r\n                export_path = 'HistoricData/' #will auto-create path if it doesn't exist\r\n                )\r\n```\r\n## Login Code\r\n```python\r\nfrom datetime import datetime\r\nfrom breeze_connect import BreezeConnect\r\nfrom BreezeHistoricalOptions import autologin, Breezy\r\nimport json, yaml, time\r\n\r\nwith open('cred.yml') as f:\r\n    cred = yaml.load(f, Loader=yaml.FullLoader)\r\n    \r\nbreeze = BreezeConnect(api_key=cred['api_key'])\r\n\r\ntry:\r\n    session_key = autologin.get_session_key(cred=cred, force=False)\r\nexcept:\r\n    session_key = autologin.get_session_key(cred=cred, force=True)\r\n    \r\n    \r\nbreeze.generate_session(api_secret=cred['api_secret'],\r\n                        session_token=session_key)\r\n```\r\n## Contributing\r\nContributions are welcome. Please fork the repository, make your changes, and submit a pull request.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python package for easily downloading historical options data",
    "version": "1.1",
    "project_urls": {
        "Homepage": "https://github.com/madmay247/breeze-historical-options"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "401ac801329f8b7e2e83212e5b2e29c1ca6b543fc445f2e23b443637ad52a3f9",
                "md5": "6400b26196fe3149ca75ea2aaa42fd43",
                "sha256": "bf1c6ad893f5ae238d8a658dee08d48e58830465bc53127ab4cc36c0c71a5819"
            },
            "downloads": -1,
            "filename": "breeze_historical_options-1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6400b26196fe3149ca75ea2aaa42fd43",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9176,
            "upload_time": "2023-12-12T05:38:46",
            "upload_time_iso_8601": "2023-12-12T05:38:46.488687Z",
            "url": "https://files.pythonhosted.org/packages/40/1a/c801329f8b7e2e83212e5b2e29c1ca6b543fc445f2e23b443637ad52a3f9/breeze_historical_options-1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1c64c4783c751d88033d2ffd7b1a68aed1875948094e5ee6073182aa556471e",
                "md5": "af2d3e88d3fa6af8d7bb5bad0ab3104c",
                "sha256": "bbfd3a6bb89c9a13913399fdd70b04af1ccab715515074d7644a0d3b0404f5dd"
            },
            "downloads": -1,
            "filename": "breeze-historical-options-1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "af2d3e88d3fa6af8d7bb5bad0ab3104c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8388,
            "upload_time": "2023-12-12T05:38:48",
            "upload_time_iso_8601": "2023-12-12T05:38:48.360791Z",
            "url": "https://files.pythonhosted.org/packages/e1/c6/4c4783c751d88033d2ffd7b1a68aed1875948094e5ee6073182aa556471e/breeze-historical-options-1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-12 05:38:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "madmay247",
    "github_project": "breeze-historical-options",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "asttokens",
            "specs": [
                [
                    "==",
                    "2.4.1"
                ]
            ]
        },
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "23.1.0"
                ]
            ]
        },
        {
            "name": "bidict",
            "specs": [
                [
                    "==",
                    "0.22.1"
                ]
            ]
        },
        {
            "name": "breeze-connect",
            "specs": [
                [
                    "==",
                    "1.0.43"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2023.11.17"
                ]
            ]
        },
        {
            "name": "cffi",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.3.2"
                ]
            ]
        },
        {
            "name": "colorama",
            "specs": [
                [
                    "==",
                    "0.4.6"
                ]
            ]
        },
        {
            "name": "comm",
            "specs": [
                [
                    "==",
                    "0.2.0"
                ]
            ]
        },
        {
            "name": "debugpy",
            "specs": [
                [
                    "==",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "decorator",
            "specs": [
                [
                    "==",
                    "5.1.1"
                ]
            ]
        },
        {
            "name": "executing",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "h11",
            "specs": [
                [
                    "==",
                    "0.14.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.6"
                ]
            ]
        },
        {
            "name": "jedi",
            "specs": [
                [
                    "==",
                    "0.19.1"
                ]
            ]
        },
        {
            "name": "matplotlib-inline",
            "specs": [
                [
                    "==",
                    "0.1.6"
                ]
            ]
        },
        {
            "name": "nest-asyncio",
            "specs": [
                [
                    "==",
                    "1.5.8"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.26.2"
                ]
            ]
        },
        {
            "name": "outcome",
            "specs": [
                [
                    "==",
                    "1.3.0.post0"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "23.2"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.1.4"
                ]
            ]
        },
        {
            "name": "parso",
            "specs": [
                [
                    "==",
                    "0.8.3"
                ]
            ]
        },
        {
            "name": "platformdirs",
            "specs": [
                [
                    "==",
                    "4.1.0"
                ]
            ]
        },
        {
            "name": "prompt-toolkit",
            "specs": [
                [
                    "==",
                    "3.0.41"
                ]
            ]
        },
        {
            "name": "psutil",
            "specs": [
                [
                    "==",
                    "5.9.6"
                ]
            ]
        },
        {
            "name": "pure-eval",
            "specs": [
                [
                    "==",
                    "0.2.2"
                ]
            ]
        },
        {
            "name": "pycparser",
            "specs": [
                [
                    "==",
                    "2.21"
                ]
            ]
        },
        {
            "name": "Pygments",
            "specs": [
                [
                    "==",
                    "2.17.2"
                ]
            ]
        },
        {
            "name": "pyotp",
            "specs": [
                [
                    "==",
                    "2.9.0"
                ]
            ]
        },
        {
            "name": "PySocks",
            "specs": [
                [
                    "==",
                    "1.7.1"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.8.2"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "python-engineio",
            "specs": [
                [
                    "==",
                    "4.8.0"
                ]
            ]
        },
        {
            "name": "python-socketio",
            "specs": [
                [
                    "==",
                    "5.10.0"
                ]
            ]
        },
        {
            "name": "pytz",
            "specs": [
                [
                    "==",
                    "2023.3.post1"
                ]
            ]
        },
        {
            "name": "pywin32",
            "specs": [
                [
                    "==",
                    "306"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": [
                [
                    "==",
                    "6.0.1"
                ]
            ]
        },
        {
            "name": "pyzmq",
            "specs": [
                [
                    "==",
                    "25.1.2"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "selenium",
            "specs": [
                [
                    "==",
                    "4.16.0"
                ]
            ]
        },
        {
            "name": "simple-websocket",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "sniffio",
            "specs": [
                [
                    "==",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "sortedcontainers",
            "specs": [
                [
                    "==",
                    "2.4.0"
                ]
            ]
        },
        {
            "name": "stack-data",
            "specs": [
                [
                    "==",
                    "0.6.3"
                ]
            ]
        },
        {
            "name": "tornado",
            "specs": [
                [
                    "==",
                    "6.4"
                ]
            ]
        },
        {
            "name": "traitlets",
            "specs": [
                [
                    "==",
                    "5.14.0"
                ]
            ]
        },
        {
            "name": "trio",
            "specs": [
                [
                    "==",
                    "0.23.1"
                ]
            ]
        },
        {
            "name": "trio-websocket",
            "specs": [
                [
                    "==",
                    "0.11.1"
                ]
            ]
        },
        {
            "name": "tzdata",
            "specs": [
                [
                    "==",
                    "2023.3"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "wcwidth",
            "specs": [
                [
                    "==",
                    "0.2.12"
                ]
            ]
        },
        {
            "name": "webdriver-manager",
            "specs": [
                [
                    "==",
                    "4.0.1"
                ]
            ]
        },
        {
            "name": "websocket-client",
            "specs": [
                [
                    "==",
                    "1.7.0"
                ]
            ]
        },
        {
            "name": "wsproto",
            "specs": [
                [
                    "==",
                    "1.2.0"
                ]
            ]
        }
    ],
    "lcname": "breeze-historical-options"
}
        
Elapsed time: 0.16249s