Stocky Will help you generate a consolidated list of Instruments
- by mapping their ISIN codes to
- BSE Stock codes and symbols
- NSE symbols
- Zerodha symbols
- Yahoo symbols (Both .NS and .BO)
Clone the repository.
git clone https://github.com/justgoodin/stocky.git
cd stockyInstall dependencies with uv.
uv sync- BSE Bhavcopy: Download from
https://www.bseindia.com/markets/MarketInfo/BhavCopy.aspx. - NSE Bhavcopy:
- Current files: Download
CM-UDiFF Common Bhavcopy Final (zip)fromhttps://www.nseindia.com/all-reports, or open the date-specific archive URL:https://nsearchives.nseindia.com/content/cm/BhavCopy_NSE_CM_0_0_0_YYYYMMDD_F_0000.csv.zip - Example direct file:
https://nsearchives.nseindia.com/content/cm/BhavCopy_NSE_CM_0_0_0_20260522_F_0000.csv.zip - Legacy files before 2024-07-08 use the older
NSE-cmDDMONYYYYbhav.csvfilename convention. - This project treats exchange bhavcopies as manually downloaded local inputs; do not add automated NSE downloads here.
- Current files: Download
- Zerodha Instruments: Download from
https://api.kite.trade/instruments
- BSE Bhavcopy:
data/marketData/bhavCopies - NSE Bhavcopy:
data/marketData/bhavCopies. Current NSE UDiFF.csv.zipfiles can be used directly. - Zerodha Instruments:
data/marketData/zerodha. The filename should beinstruments.csv
Raw market data files are local inputs and are ignored by Git. The durable output is data/output/stocky.db.
Run the interactive menu:
uv run stockyRebuild the SQLite database using the latest matching BSE/NSE bhavcopy pair:
uv run stocky rebuild --latestRebuild for a specific source date:
uv run stocky rebuild --date 2021-05-03Use explicit source files:
uv run stocky rebuild \
--bse-bhavcopy data/marketData/bhavCopies/BSE-EQ_ISINCODE_030521.CSV \
--nse-bhavcopy data/marketData/bhavCopies/NSE-cm03MAY2021bhav.csv \
--zerodha-instruments data/marketData/zerodha/instruments.csvImport the legacy Yahoo JSON cache into SQLite:
uv run stocky yahoo import-cacheUpdate Yahoo responses in SQLite:
uv run stocky yahoo update --exchange BSEShow database statistics, per-column coverage, and Yahoo cache freshness:
uv run stocky statusLook up an instrument by symbol, ISIN, BSE scrip code, or name fragment:
uv run stocky query RELIANCE
uv run stocky query "hdfc bank"
uv run stocky query 500325 --exactFor compatibility, python app.py still launches the CLI after dependencies are installed.
There are six options.
1. Rebuild stocky.db from scratch:
This backs up the existing database and replaces the consolidated table. Requires bhavcopies and Zerodha instruments in their respective locations.
2. Update all Yahoo data:
Downloads Yahoo data using yahooquery and stores responses in data/output/stocky.db
3. Import Yahoo JSON cache:
Imports legacy files from data/marketData/yahoo/apiResponse into the yahoo_responses SQLite table.
4. Show database status:
Prints row counts, per-column coverage, and Yahoo cache freshness for data/output/stocky.db.
5. Look up an instrument:
Searches the consolidated table across all symbol namespaces (Zerodha, Yahoo, NSE, BSE, ISIN, name).
6. Exit: Exit the program