openchart is not affiliated, endorsed, or vetted by NSEIndia. It's an open-source tool that uses NseIndia's publicly available APIs, and is intended for research and educational purposes. OpenChart is a Python library for downloading intraday and EOD (End of Day) historical data from the NSE (National Stock Exchange of India) and NFO (NSE Futures and Options) exchanges.
You can install the library directly from the GitHub repository: pip install openchart or from the GitHub repository: pip install git+https://github.com/marketcalls/openchart.git from openchart import NSEData nse = NSEData() Before fetching historical data or searching for symbols, download the master data: nse.download() To fetch historical data for a symbol, use the Fetch intraday data for TCS with a 5-minute interval, 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='TCS',
exchange='NSE',
start=start_date,
end=end_date,
interval='5m'
)
print(data) Fetch end-of-day data for Nifty 50, from 365 days ago until today: import datetime
end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=365)
data = nse.historical(
symbol='Nifty 50',
exchange='NSE',
start=start_date,
end=end_date,
interval='1d'
)
print(data) 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) Search for symbols like Nifty 50, TCS, RELIANCE in the NSE exchange. symbols = nse.search('RELIANCE', exchange='NSE')
print(symbols) Search for symbols like NIFTY24OCTFUT, BANKNIFTY24OCTFUT, NIFTY24N2124800CE, NIFTY24N2124800PE in the NFO exchange.
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]
If you want to perform an exact match search, you can set symbol_info = nse.search('BANKNIFTY24OCTFUT', exchange='NFO', exact_match=True)
print(symbol_info) print(nse.timeframes())
# Output: ['1m', '3m', '5m', '10m', '15m', '30m', '1h', '1d', '1w', '1M']
This project is licensed under the MIT License - see the LICENSE file for details. Contributions are welcome! Please open an issue or submit a pull request. For any questions or support, please open an issue on the GitHub repository |
forked from marketcalls/openchart
-
Notifications
You must be signed in to change notification settings - Fork 0
OpenChart is a Python library for downloading intraday and EOD (End of Day) historical data from the NSE (National Stock Exchange of India) and NFO (NSE Futures and Options) exchanges
License
kratos143/openchartkaran
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
OpenChart is a Python library for downloading intraday and EOD (End of Day) historical data from the NSE (National Stock Exchange of India) and NFO (NSE Futures and Options) exchanges
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Python 100.0%