Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

Introducing OpenChart: A Python Library for NSE and NFO Historical Data

5 min read

OpenChart is a free, open-source Python library that downloads intraday and end-of-day historical data for NSE stocks, indices and NFO futures and options straight into a pandas DataFrame. Install it with pip install openchart, search for a symbol and call historical() with a start date, end date and interval. This guide covers the original release and the updated API in version 0.2.0 (January 2026).

OpenChart Python library for downloading NSE and NFO intraday and EOD historical data

Key Takeaways

  • OpenChart fetches OHLCV data for NSE equities, indices and F&O contracts in timeframes from 1 minute to 1 month.
  • Version 0.2.0, released on PyPI in January 2026, replaced the exchange='NSE'/'NFO' argument with segment='EQ'/'IDX'/'FO' and no longer needs a master data download.
  • Always pass explicit start and end dates when fetching data.
  • The library uses NSE’s publicly available charting endpoints, is not affiliated with NSE and is meant for research and education.

Financial data analysis is crucial for traders, investors, and analysts who need to make informed decisions based on historical market trends. Access to reliable and timely data is essential. Today, we’re excited to introduce OpenChart, a Python library designed to simplify the process of downloading intraday and end-of-day (EOD) historical data from the National Stock Exchange of India (NSE) and NSE Futures and Options (NFO) exchanges.

In this blog post, we’ll go through the features of OpenChart, guide you through the installation process, and provide examples of how to use the library to fetch historical data for your favorite stocks and derivatives.

OpenAlgo: one API for 35+ Indian brokers

FREE AND OPEN SOURCE

OpenAlgo: one API for 35+ Indian brokers

Self-hosted algo trading platform. Send orders from Python, AmiBroker, TradingView, Excel or a no-code flow through one consistent API.

  • Unified REST and WebSocket API
  • Works with AmiBroker, TradingView, ChartInk and Excel
  • Sandbox mode to test before going live
Get OpenAlgo →by Marketcalls

Version note (2026): the examples in the sections below were written for OpenChart 0.1.0 (October 2024) and use nse.download() and the exchange argument. If you install the latest release from PyPI, jump to the updated 0.2.0 examples, or pin the old version with pip install openchart==0.1.0.

What is OpenChart?

OpenChart is an open-source Python library that allows users to:

  • Download NSE and NFO master data
  • Search for symbols in NSE and NFO exchanges
  • Fetch historical data for equities and derivatives
  • Support various timeframes: 1m, 3m, 5m, 10m, 15m, 30m, 1h, 1d, 1w, 1M

Key Features

  • Ease of Use: Simple and intuitive API for fetching data.
  • Flexibility: Supports multiple timeframes and exchanges.
  • Open Source: Licensed under MIT License for community use and contributions.
  • Up-to-Date Data: Fetches the most recent data available from NSE and NFO.

Installation

OpenChart is available on PyPI, and you can install it using pip:

pip install openchart

Getting Started

Importing the Library and Initializing the NSEData Class

from openchart import NSEData
nse = NSEData()

Downloading Master Data

Before fetching historical data or searching for symbols, download the master data for NSE and NFO:

nse.download()

Fetching Historical Data

Important Note

Always specify start and end dates when fetching historical data. This ensures you get the data for the exact period you’re interested in.

Fetching Intraday Data

Fetch 5-minute interval data for RELIANCE from the last 30 days:

import datetime

end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=30)

data = nse.historical(
    symbol='RELIANCE',
    exchange='NSE',
    start=start_date,
    end=end_date,
    interval='5m'
)

print(data)

Output

                        Open     High      Low    Close  Volume
Timestamp                                                      
2024-09-20 13:14:59  2983.85  2985.60  2982.30  2984.65   81648
2024-09-20 13:19:59  2984.95  2987.00  2983.20  2985.75   93902
2024-09-20 13:24:59  2986.00  2987.75  2981.75  2985.30  118105
2024-09-20 13:29:59  2985.70  2990.00  2983.70  2986.40  161902
2024-09-20 13:34:59  2985.95  2987.15  2959.00  2960.95  383962
...                      ...      ...      ...      ...     ...
2024-10-18 15:09:59  2721.45  2721.50  2718.40  2719.40  210486
2024-10-18 15:14:59  2720.00  2720.90  2715.20  2716.10  178000
2024-10-18 15:19:59  2716.10  2716.10  2713.00  2714.70  175154
2024-10-18 15:24:59  2714.70  2718.85  2713.55  2718.85  175184
2024-10-18 15:29:59  2718.85  2719.10  2715.50  2717.00  194882

[480 rows x 5 columns]

Fetch historical data for a futures contract of 15min data, from 30 days ago until today:

import datetime

end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=30)

data = nse.historical(
    symbol='BANKNIFTY24OCTFUT',
    exchange='NFO',
    start=start_date,
    end=end_date,
    interval='15m'
)
print(data)

Output

                         Open      High       Low     Close  Volume
Timestamp                                                          
2024-09-20 13:14:58  53553.20  53562.60  53543.30  53544.95    1290
2024-09-20 13:29:59  53554.00  53572.00  53516.50  53532.95   32940
2024-09-20 13:44:58  53522.40  53535.40  53145.05  53238.85  266415
2024-09-20 13:59:59  53232.40  53428.00  53220.00  53331.70  137010
2024-09-20 14:14:58  53326.80  53376.05  53275.00  53335.05   54195
...                       ...       ...       ...       ...     ...
2024-10-18 14:29:59  52338.00  52400.00  52311.15  52360.75   71445
2024-10-18 14:44:58  52360.00  52415.50  52360.00  52390.00   68265
2024-10-18 14:59:59  52390.00  52390.00  52320.00  52348.60   49935
2024-10-18 15:14:58  52350.10  52355.00  52241.00  52275.00  146895
2024-10-18 15:29:58  52272.95  52360.00  52264.95  52360.00  183180

[480 rows x 5 columns]

Fetching End-of-Day Data

Fetch daily data for Nifty 50 for the last 3650 days:

import datetime

end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=3650)

data = nse.historical(
    symbol='Nifty 50',
    exchange='NSE',
    start=start_date,
    end=end_date,
    interval='1d'
)

print(data)

Output

                         Open      High       Low     Close      Volume
Timestamp                                                              
2014-10-27 00:00:00   8064.35   8064.40   7985.65   7991.70   133453808
2014-10-28 00:00:00   8002.40   8037.80   7995.05   8027.60   130545143
2014-10-29 00:00:00   8077.05   8097.95   8052.25   8090.45   157278723
2014-10-30 00:00:00   8085.20   8181.55   8085.20   8169.20   203111083
2014-10-31 00:00:00   8200.80   8330.75   8198.05   8322.20   215483674
...                       ...       ...       ...       ...         ...
2024-10-14 00:00:00  25023.45  25159.75  25017.50  25127.95  3009476572
2024-10-15 00:00:00  25186.30  25212.05  25008.15  25057.35  2875166269
2024-10-16 00:00:00  25008.55  25093.40  24908.45  24971.30  2883096337
2024-10-17 00:00:00  25027.40  25029.50  24728.90  24749.85  2886728701
2024-10-18 16:14:59  24664.95  24886.20  24567.65  24854.05           1

[2473 rows x 5 columns]

Supported Timeframes

You can check the supported timeframes using:

print(nse.timeframes())

Output

['1m', '3m', '5m', '10m', '15m', '30m', '1h', '1d', '1w', '1M']

Search for Symbols

NSE Exchange

Search for symbols like Nifty 50, TCS, RELIANCE in the NSE exchange.

symbols = nse.search('RELIANCE', exchange='NSE')
print(symbols)

NFO Exchange

Search for symbols like NIFTY24OCTFUT, BANKNIFTY24OCTFUT, NIFTY24N2124800CE, NIFTY24N2124800PE in the NFO exchange.

  • NIFTY24N2124800CE corresponds to NIFTY 21 Nov 2024 CE 24800.00.
  • NIFTY24N2124800PE corresponds to NIFTY 21 Nov 2024 PE 24800.00.
symbols = nse.search('24OCTFUT', exchange='NFO')
print(symbols)

Output

    ScripCode              Symbol                    Name Type
0       35006   BANKNIFTY24OCTFUT   BANKNIFTY 30 Oct 2024    1
1       35007  NIFTYNXT5024OCTFUT  NIFTYNXT50 25 Oct 2024    1
2       35012    FINNIFTY24OCTFUT    FINNIFTY 29 Oct 2024    1
3       35239  MIDCPNIFTY24OCTFUT  MIDCPNIFTY 28 Oct 2024    1
4       35382       NIFTY24OCTFUT       NIFTY 31 Oct 2024    1
..        ...                 ...                     ...  ...
179     48598         UPL24OCTFUT         UPL 31 Oct 2024    3
180     48601        VEDL24OCTFUT        VEDL 31 Oct 2024    3
181     48602      VOLTAS24OCTFUT      VOLTAS 31 Oct 2024    3
182     48603       WIPRO24OCTFUT       WIPRO 31 Oct 2024    3
183     48604   ZYDUSLIFE24OCTFUT   ZYDUSLIFE 31 Oct 2024    3

[184 rows x 4 columns]

Exact Match Search

If you want to perform an exact match search, you can set exact_match=True.

symbol_info = nse.search('BANKNIFTY24OCTFUT', exchange='NFO', exact_match=True)
print(symbol_info)

Updated Version (2026): OpenChart 0.2.0 API

OpenChart 0.2.0 was published on PyPI on 16 January 2026. It switches to NSE’s symbol search and historical charting endpoints and simplifies the API. The main changes, based on the 0.2.0 source code:

TaskOpenChart 0.1.0 (2024)OpenChart 0.2.0 (2026)
Master datanse.download() before searchingNot needed; search queries NSE directly
Choose marketexchange='NSE' or 'NFO'segment='EQ', 'IDX' or 'FO'
Exact match searchexact_match=Truehistorical() picks the exact symbol match automatically
Timeframes1m, 3m, 5m, 10m, 15m, 30m, 1h, 1d, 1w, 1M1m, 5m, 10m, 15m, 30m, 1h, 1d, 1w, 1M (3m removed)
Search result columnsScripCode, Symbol, Name, Typesymbol, scripcode, description, type, exchange
Fetch by tokenNot availablehistorical_direct(token, symbol, symbol_type, ...)

Here is the equivalent of the earlier examples with the new API:

import datetime
from openchart import NSEData

nse = NSEData()   # no master data download needed in 0.2.0

# Search: segment is 'EQ' (equity), 'IDX' (index) or 'FO' (futures and options)
print(nse.search('RELIANCE', segment='EQ'))
print(nse.search('NIFTY 50', segment='IDX'))
print(nse.search('NIFTY', segment='FO').head())

end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=30)

# 5-minute data for an NSE stock
reliance = nse.historical('RELIANCE', segment='EQ',
                          start=start_date, end=end_date, interval='5m')

# Daily data for an index over roughly 10 years
nifty = nse.historical('NIFTY 50', segment='IDX',
                       start=end_date - datetime.timedelta(days=3650),
                       end=end_date, interval='1d')

print(reliance.tail())
print(nifty.tail())

print(nse.timeframes())   # ['1m', '5m', '10m', '15m', '30m', '1h', '1d', '1w', '1M']
print(nse.segments())     # ['IDX', 'EQ', 'FO']

If a symbol is ambiguous, run search() first, check the symbol, scripcode and type columns, and pass those values to historical_direct():

# If you already know the token (scripcode), symbol and type from a search result
df = nse.historical_direct(token='26000', symbol='NIFTY 50', symbol_type='Index',
                           start=start_date, end=end_date, interval='15m')

Tips and Limitations

  • Data comes from NSE’s public charting service, so availability, history length and rate limits are controlled by NSE and can change without notice. Add a short pause between requests when downloading many symbols.
  • Intraday timestamps mark the end of each bar, and intraday data is trimmed to the 15:29:59 market close.
  • F&O contracts expire, so look up the current contract name with search(..., segment='FO') rather than hard-coding symbols such as BANKNIFTY24OCTFUT.
  • For production trading systems, a broker API is more reliable. OpenAlgo can fetch broker historical data without hitting API rate limits.

OpenChart vs Other Ways to Get NSE Historical Data in Python

OptionBest forNotes
OpenChartFree NSE intraday and EOD data for stocks, indices and F&ONo login; uses NSE public charting endpoints
yfinanceDaily data for NSE stocks and indices (.NS tickers)Limited intraday history; see the yfinance guide
Broker APIs (via OpenAlgo)Reliable intraday data for live systemsNeeds a trading account and API access

For a broader comparison, read top 10 Python libraries with historical data APIs, and to build a local archive, see how to download 10 years of intraday data in CSV format.

Frequently Asked Questions

How do I download NSE historical data in Python?

Install OpenChart with pip install openchart, create an NSEData object and call historical() with the symbol, segment, start date, end date and interval. The result is a pandas DataFrame with Open, High, Low, Close and Volume columns.

Is OpenChart free?

Yes. OpenChart is open source under the MIT License and is free to use. It is not affiliated with NSE and is intended for research and educational use.

Why does nse.download() not work after upgrading OpenChart?

Version 0.2.0 removed the master data download. Searches now query NSE directly, and the exchange argument was replaced by segment (EQ, IDX or FO). Update your code as shown above or install openchart==0.1.0.

Which timeframes does OpenChart support?

Version 0.2.0 supports 1m, 5m, 10m, 15m, 30m, 1h, 1d, 1w and 1M. Call nse.timeframes() to see the list for the version you have installed.

Contributing

OpenChart is an open-source project, and contributions are welcome! You can contribute by:

  • Reporting bugs
  • Submitting pull requests
  • Suggesting new features

Visit the GitHub repository to get started.

Final Word

OpenChart simplifies the process of fetching historical data from NSE and NFO, making it an invaluable tool for traders, analysts, and developers. With easy installation and a straightforward API, you can integrate it into your projects quickly.

Give OpenChart a try, and feel free to contribute to the project!

IMPORTANT LEGAL DISCLAIMER
OpenChart is not affiliated, endorsed, or vetted by NSEIndia. It is an open-source tool that uses NSEIndia’s publicly available APIs, and is intended for research and educational purposes.
Python Elite membership

MEMBERSHIP

Python Elite membership

15 Python, AI and algo trading programs in one plan, including QuantFlow and AI Bootcamp live mentorship.

  • Python from fundamentals to trading apps
  • Backtesting, broker APIs and OpenAlgo
  • Live QuantFlow and AI Bootcamp sessions
View Python Elite →by Marketcalls

Learn by watching: free videos every week

Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

One Reply to “Introducing OpenChart: A Python Library for NSE and NFO…”

  1. Sir , unable to MSG you on Twitter. How to get nifty weekly options data using opencharts python library. If I search for symbol using strike Price then I don’t see symbol for weekly options

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More