How to get Historical data for expired option contract with Upstox Plus

As mentioned in the Upstox plus features, we can get historical data for expired contracts. @Upstox , can you guide how to get historical data for expired option contracts.

Hi @Bhawik_37243451

You can find the documentation here: Expired Instruments | Upstox Developer API

1 Like

Thanks for sharing, Just a request to include Python SDKs as well for all the new API upgrades. Would be great if I can get python SDKs for APIs like expired instruments, historical datav3, intraday datav3 etc

Yes, @Bhawik_37243451, the SDK release is in our plans and will be released soon. Thank you for your patience.

1 Like

Hi @Ketan and @MohitGolecha, this new feature about expired contracts is very good, but the time period of six months is quite short. I suggest increasing it to at least two years.

1 Like

we can get historical data for options but to do that it need expired instrument key. every link required instrument key for retrieving data. from where do i get expired instrument key?

You can first retrieve all expiries for a given instrument using the API, and then fetch the expired option contracts by providing the underlying instrument and the selected expiry.

@Pradeep_Jaiswar @Ketan @MohitGolecha

I am facing a problem for a particular expiry for nifty.
Please check this post and advice..

Hello Sir, Were you able to extract option contracts before 6 months something around early 2024? I am unable to get the data it empty.

Hi @jtutanota ,
Yes. i was able to download 1 min candles of expired NIFTY option contracts with above APIs from OCTOBER 2024.

If you are facing any error, share the problematic cURL for help.

Did you try for 2023 or something. i am getting data from feb 25 only

What is the underlying script that you are trying ?
Also, share cURL for better understanding..

In the Get Expiries API, Mentioned below.

The API will retrieve the complete list of expiry dates (including weekly and monthly) for the instrument, covering up to six months of historical expiries.

So, you cannot expect data more than past six months.. 2023.. not possible..
But, in my case i got from october 2024 for nifty.. (9 months) Which is helpful for me..

Sorry i am away from my desk, i will share the cURL tomrrow. so we will get data max for expired options for 6 month only even with plus account?

Yes, even with plus account. I would say 6 months of data will give you 6*4 = 24 expiries.
To initiate back testing, 24 different weeks of data set is a good starting point.

helli Sir, Thsi sis teh cURl curl -X GET \

-H ā€œAuthorization: Bearer YOUR_ACCESS_TOKENā€ \

-H ā€œAccept: application/jsonā€ \

-G \

–data-urlencode ā€œinstrument_key=NSE_INDEX|Nifty 50ā€ \

–data-urlencode ā€œexpiry_date=2025-01-02ā€ \

ā€œhttps://api.upstox.com/v2/expired-instruments/option/contractā€

Data is returning for this cURL..
Do you face any issue in this URL?

curl --location 'https://api.upstox.com/v2/expired-instruments/option/contract?instrument_key=NSE_INDEX%7CNifty%2050&expiry_date=2025-01-02' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN_HERE'

I somehow successfully developed a complete future index and options expired contract downloader. However, as of now, it only retrieves data starting from January 2025.

1 Like