📈 NiftyFetcher
A powerful CLI tool to fetch historical OHLC (Open, High, Low, Close) data for stocks using the Upstox API.
🚀 Features
- Fetch historical stock data with customizable time intervals
- Support for multiple time units (minute, hour, day, week, month)
- Export data to CSV or Excel formats
- Automatic handling of large date ranges with intelligent chunking
- Clean, user-friendly command-line interface
- Error handling with detailed feedback
📦 Installation
Install from PyPI:
pip install niftyfetcher
Or install from source:
git clone https://github.com/yash2002vardhan/niftyfetcher.git
cd niftyfetcher
pip install -e .
🛠️ Usage
Basic Syntax
niftyfetcher INSTRUMENT_KEY UNIT INTERVAL FROM_DATE TO_DATE FILE_TYPE
Arguments
| Argument | Description | Example Values |
|---|---|---|
INSTRUMENT_KEY |
Upstox instrument key for the stock | NSE_EQ|INE002A01018 |
UNIT |
Time unit for data | minutes, hours, days, weeks, months |
INTERVAL |
Interval within the unit | 1, 5, 15, 30 |
FROM_DATE |
Start date (YYYY-MM-DD) | 2024-01-01 |
TO_DATE |
End date (YYYY-MM-DD) | 2024-01-31 |
FILE_TYPE |
Output format | csv or xlsx |
📋 Examples
Fetch daily data for Nifty 50:
niftyfetcher "NSE_INDEX|Nifty 50" days 1 2024-01-01 2024-01-31 csv
Fetch 5-minute interval data:
niftyfetcher "NSE_EQ|INE002A01018" minutes 5 2024-01-15 2024-01-16 xlsx
Fetch weekly data for a year:
niftyfetcher "NSE_EQ|INE002A01018" weeks 1 2023-01-01 2023-12-31 csv
📊 Output
The tool generates files with the following naming convention:
{instrument_key}_{unit}_{interval}_{from_date}_{to_date}.{file_type}
Output contains columns:
timestamp- Date/time of the data pointopen- Opening pricehigh- Highest pricelow- Lowest priceclose- Closing price
🔧 Getting Help
niftyfetcher --help
📝 Requirements
- Python 3.8+
- Internet connection for API access
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
⚠️ Disclaimer
This tool is for educational and research purposes. Always verify data accuracy for trading decisions. The authors are not responsible for any financial losses.
🐛 Issues
If you encounter any issues, please report them on GitHub Issues.
⚠️ Note on Rate Limits
Please be mindful of the rate limits imposed by the Upstox API to avoid errors or temporary bans. While this tool includes basic safeguards (such as delays between requests), it is ultimately your responsibility to ensure you do not exceed Upstox's allowed request limits. The authors are not liable for any issues arising from rate limit violations.
Metadata
Release files for niftyfetcher 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| niftyfetcher-0.1.3.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| niftyfetcher-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / niftyfetcher-0.1.3.tar.gz
| Download URL | niftyfetcher-0.1.3.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
834fd5946ac744a5cb2d004209a7b7ea5438528d939bab96dcf0fc7dec0b97a0
|
|
BLAKE2b-256 checksum How to use checksums |
6aaa12f14410b8156aa94476ac7425f7896d7a74c0f8038ee95e52c9e7d4da41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / niftyfetcher-0.1.3-py3-none-any.whl
| Download URL | niftyfetcher-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcbbd7941a33cabded7fe39134185597b9659ce004e365afa1f5f0e89e9b25c0
|
|
BLAKE2b-256 checksum How to use checksums |
0d509a8113ae0f39ef40568fe73e5b0690924075d0efa0896b2031ad124b84be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|