Getting Started - jinto-ag/upstox_instrument_query GitHub Wiki

Getting Started with Upstox Instrument Query

Welcome to the Upstox Instrument Query project wiki!

This wiki provides documentation, guides, and resources to help you get the most out of the Upstox Instrument Query Python package. Here you’ll find information on installation, usage, contributing, and troubleshooting.

What is Upstox Instrument Query?

Upstox Instrument Query is a Python package designed to efficiently query large Upstox instruments JSON files using SQLite for optimal performance. It is ideal for developers and analysts working with Upstox market data, and supports advanced querying, caching, and integration with yfinance.

Table of Contents

Installation

Install the latest version from PyPI:

pip install upstox-instrument-query

Basic Usage

You can use the package programmatically to query instrument data:

from upstox_instrument_query.query import query

# Query by symbol
result = query('NSE_EQ', symbol='RELIANCE')
print(result)

# Query by ISIN
result = query('NSE_EQ', isin='INE002A01018')
print(result)

# Query by instrument token
result = query('NSE_EQ', instrument_token=2885)
print(result)

Command Line Interface

The package provides a CLI for quick queries:

upstox-query NSE_EQ --symbol RELIANCE
upstox-query NSE_EQ --isin INE002A01018
upstox-query NSE_EQ --instrument_token 2885

You can also use the interactive mode:

upstox-query interactive

Advanced Features

  • Caching: Results are cached for faster repeated queries.
  • Multiple Query Modes: Query by symbol, ISIN, or instrument token.
  • Integration with yfinance: Use the --yfinance option in CLI or yfinance extra in Python for extended data.
  • Custom Database: You can specify a custom SQLite database for instrument data.

Testing

Run all tests using pytest:

pytest

Test files are located in the tests/ directory and cover all major modules, including edge cases and CLI behavior.

Contributing

We welcome contributions! Please read our Contributing Guidelines and Code of Conduct.

FAQ

  • Where is the instrument data stored?
    • The package uses SQLite to store and query instrument data efficiently.
  • How do I update the instrument data?
    • Replace the JSON file in the data/ directory and rebuild the database using the CLI or helper scripts.
  • How do I enable yfinance integration?
    • Install with pip install upstox-instrument-query[yfinance] and use the --yfinance CLI option or import upstox_instrument_query.yfinance in Python.

Support

If you have questions or need help, open an issue or start a discussion.


Thank you for using and contributing to Upstox Instrument Query!