NSE option chain historical data (end of day) since 2010
How to get a past NSE option chain for any date since 2010: expiries, strikes, open interest, futures and single-contract history from the end-of-day F&O bhavcopy, with the no-trade rows and unit traps explained.
The NSE website shows today's option chain. It does not let you pick a date in 2019 and see the chain as it stood at that close. That history exists, in the equity derivatives bhavcopy NSE publishes every trading day, one row per contract per day. We parse every one of those files from 4 January 2010 and serve them through four endpoints. This post shows how to get a past chain, the expiries on a date, futures and one contract's history, using 4 June 2024, the day the general election results came in, as the example.
Two limits first. This is end-of-day data only: one row per contract per day, no intraday snapshots, no bid and ask, no implied volatility or greeks. And it is on the Retail plan (₹599/month) and up, not the free key.
What a historical chain contains
Each row is one contract on one day: instrument (FUTIDX, FUTSTK, OPTIDX, OPTSTK), expiry, strike, option_type, open, high, low, close, settle_price, contracts, turnover, open_interest and oi_change. From 8 July 2024 NSE's file also carries underlying and lot_size, so those are null before that date. Option types are CE and PE, with some rows before 2011 marked CA and PA.
Step 1: which expiries traded that day
import os
from tej import Client
c = Client(api_key=os.environ["TEJ_API_KEY"]) # Retail or Pro
for e in c.fo_expiries("NIFTY", date="2024-06-04")[:6]:
print(e["expiry"], e["instrument"], e["contracts"], e["open_interest"], e["strikes"])2024-06-06 OPTIDX 126842154 190922750 97
2024-06-13 OPTIDX 4087719 15765875 97
2024-06-20 OPTIDX 128288 1308500 94
2024-06-27 FUTIDX 1615661 14558300 0
2024-06-27 OPTIDX 9720479 89678450 107
2024-07-04 OPTIDX 2327 55275 94NIFTY had 21 instrument and expiry pairs open that day, from the weekly expiring two days later out to December 2028. Almost all the activity sat in the nearest weekly.
Step 2: the chain for one expiry
fo_chain takes a date and an expiry. Leave out the expiry and you get the nearest one, leave out the date and you get the latest trading day.
chain = c.fo_chain("NIFTY", date="2024-06-04", expiry="2024-06-06")
print(len(chain)) # 194: 97 strikes, CE and PE
for r in chain:
if r["strike"] in (21500, 22000, 22500):
print(r["strike"], r["option_type"], r["close"], r["contracts"], r["open_interest"], r["oi_change"])strike type close contracts open_interest oi_change
21500 CE 476.25 473,223 454,100 +374,575
21500 PE 183.80 4,841,744 3,438,750 -163,350
22000 CE 205.50 2,564,552 4,126,975 +3,593,200
22000 PE 406.20 4,564,682 3,127,300 -712,025
22500 CE 99.65 2,379,745 4,371,200 +2,712,475
22500 PE 785.45 1,982,109 2,251,850 -1,694,625The file has no underlying price before July 2024, and we do not publish index values. For an index chain before then, the near-month future is the closest thing in the same dataset. For stock options, join the cash market close from /v1/ohlcv. From July 2024 the chain response carries the underlying in its meta, and fo_chain_envelope returns it.
Step 3: futures across expiries
for r in c.fo_futures("NIFTY", from_="2024-06-03", to="2024-06-04"):
print(r["date"], r["expiry"], r["close"], r["contracts"], r["open_interest"])2024-06-03 2024-06-27 23407.9 561462 14389975
2024-06-03 2024-07-25 23542.05 35796 702250
2024-06-03 2024-08-29 23684.3 7391 95175
2024-06-04 2024-06-27 21908.15 1615661 14558300
2024-06-04 2024-07-25 22063 111357 956925
2024-06-04 2024-08-29 22196.5 19775 193625The near-month future fell from 23,407.90 to 21,908.15, or 6.41%. Every expiry comes back for every day, so you can build a continuous series with your own roll rule.
Step 4: one contract to expiry
pe = c.fo_contract("NIFTY", expiry="2024-06-06", strike=22000, option_type="PE")
for r in pe[-5:]:
print(r["date"], r["close"], r["settle_price"], r["contracts"], r["open_interest"])2024-05-31 220.55 220.55 763899 3147550
2024-06-03 43.20 43.20 1061830 3839325
2024-06-04 406.20 406.20 4564682 3127300
2024-06-05 23.20 23.20 5077261 6129150
2024-06-06 0.10 22821.40 9662414 8460625Leave out strike and option_type and you get the future for that expiry. Note the last row: on the expiry day itself, settle_price on this option row is 22,821.40, which is not an option premium. Use closefor the option's price on that day.
The rows that are not trades
A chain lists every strike that was open, traded or not. A row with contracts = 0did not trade that day: open, high and low are 0, and the close is not a price from that session. On 4 June 2024, 3 of the 194 rows in the NIFTY weekly chain were like that. In the Reliance monthly chain the same day it was 23 of 108. Across all NSE F&O rows since 2010 it is 81.53%. We wrote that up in four out of five NSE F&O rows are not trades.
The rule we use:
- Reading a price (a premium, a straddle, a volatility estimate): drop rows with
contracts = 0. - Summing open interest (put-call ratio, OI by strike, max pain): keep them. They still hold OI.
contractscounts lots,open_interestcounts units of the underlying. Lot sizes change over the years, so do not compare contract counts across those changes.
Without the SDK
H="Authorization: Bearer $TEJ_API_KEY"
curl -H "$H" "https://api.tejhq.dev/v1/fo/expiries/NIFTY?date=2024-06-04"
curl -H "$H" "https://api.tejhq.dev/v1/fo/chain/NIFTY?date=2024-06-04&expiry=2024-06-06"
curl -H "$H" "https://api.tejhq.dev/v1/fo/futures/NIFTY?from=2024-06-03&to=2024-06-04"
curl -H "$H" "https://api.tejhq.dev/v1/fo/contract/NIFTY?expiry=2024-06-06&strike=22000&option_type=PE"Without a key these return 401 key_required, and with a free key 402 pro_required. The Node SDK has the same calls as foChain, foExpiries, foFutures and foContract.
Access and limits
- Retail, ₹599/month, or pay once ₹599 for 30 days with no AutoPay: 10,000 calls a day, personal use.
- Pro, ₹4,999/month: 500,000 calls a day and commercial use.
- NSE only. No BSE derivatives, no currency or commodity contracts.
- F&O is served through the API only. It is not in the free parquet on HuggingFace.
- Each trading day's file is usually ready by the next morning IST. There is no SLA.
Column details and more examples are at /fo, and the subscription is at /upgrade. The data comes from the bhavcopy NSE publishes, and the data terms cover what you can do with it. None of this is investment advice.