How to get free, high quality NSE Option data

This article teaches you how to get good quality NSE data (stocks, futures, options) for both Index and stocks completely free using NSEpy python package.


They say, good data is expensive. You must pay for high quality data. 

Well, that may be true, but not always :-)

Let me show you how to get good quality historical NSE option data (both Put and Call) for both Index and stocks completely free of cost. And the data comes directly from NSE website.

Use NSEpy

NSEpy is an independently maintained unofficial NSE data retrieval python package that lets you download stocks, options, futures daily price data free of cost. If you are interested to know more about the package, please visit

How to use NSEpy to retrieve Options data

Okay, here is a sample program that you can readily use to get index options data -

from datetime import date
from dateutil.relativedelta import relativedelta

from nsepy import get_history
from nsepy.derivatives import get_expiry_date

# Returns NIFTY option data for a given strike and a given expiry month, year
def get_index_monthly_option_data(year, month, strike, pe_ce):
        expiry_dates = list(get_expiry_date(year, month, index=True))
        exp = expiry_dates.pop()
        st = date(year, month, 1) - relativedelta(months=2)
        return get_history(symbol = 'NIFTY',
                           start = st,
                           end = exp,
                           index = True,
                           option_type = pe_ce,
                           strike_price = strike,
                           expiry_date = exp)

How do I use this?

Say, you want to retrive the price data for 2022 September NIFTY 17500 Call option.

# Get 2022 September NIFTY 17500 Call data
data = nse_data_source.get_index_monthly_option_data(2022, 9, 17500, 'CE')

# print the data shape

# show a few records

# plot the closing price

And here is the output

Terms Privacy Feed