Skip to main content

📈 A CLI tool to fetch historical OHLC data for stocks using Upstox API

Project description

📈 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 point
  • open - Opening price
  • high - Highest price
  • low - Lowest price
  • close - 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

niftyfetcher-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

niftyfetcher-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file niftyfetcher-0.1.1.tar.gz.

File metadata

  • Download URL: niftyfetcher-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for niftyfetcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0eac226aeb70966fd2224e491d4ba68d65b067f751be05d110abf94ea05b4fc7
MD5 722903e18fc2ee393079581cdc975470
BLAKE2b-256 30edb5ceb195f27948d7bf7c283e4de21aaa7c1ee410787260840062f06f8f10

See more details on using hashes here.

File details

Details for the file niftyfetcher-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: niftyfetcher-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for niftyfetcher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3c6e7c64fa6c3226b3ceece8540303516dcfe8f0eecf57355d5a0c3d120e5e
MD5 b9fd77fb8e97827ae036618105aeecc2
BLAKE2b-256 28f135fb93e113a7d8c30495ddf6fffe0681b5a0dc7e7ea16f544dc8ccdc9283

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page