jugad-data
is a library to fetch live as well as historical stock data. This library will be a cruicial part of your analysis, backtesting and automation workflow for trading and investing.
This library fetches data from new website of NSE and hence jugaad-data
is future-proof. Many other libraries still rely on old website and may eventually stop working.
Download bhavcopy for stocks, index and derivatives
Download historical stock, index and derivatives (Futures & Options) data
Fetch live quotes for stocks and derivatives
Fetch live index and turnover data
Fetch option chains
In pipeline
In case you find other information available in NSE’s website as JSON api, please raise a feature here
pip install jugaad-data
You can optionally install pandas
library in case you are interested in fetching data directly into ‘pandas’ dataframes, in which case you can run-
pip install jugaad-data pandas
from datetime import date
from jugaad_data.nse import bhavcopy_save, bhavcopy_fo_save
# Download bhavcopy
bhavcopy_save(date(2020,1,1), "/path/to/directory")
# Download bhavcopy for futures and options
bhavcopy_fo_save(date(2020,1,1), "/path/to/directory")
# Download stock data to pandas dataframe
from jugaad_data.nse import stock_df
df = stock_df(symbol="SBIN", from_date=date(2020,1,1),
to_date=date(2020,1,30), series="EQ")
from jugaad_data.nse import NSELive
n = NSELive()
q = n.stock_quote("HDFC")
print(q['priceInfo'])
{'lastPrice': 2589.95, 'change': -73.05000000000018, 'pChange': -2.7431468268869765, 'previousClose': 2663, 'open': 2669, 'close': 2589.45, 'vwap': 2623.6, 'lowerCP': '2396.70', 'upperCP': '2929.30', 'pPriceBand': 'No Band', 'basePrice': 2663, 'intraDayHighLow': {'min': 2583.05, 'max': 2678.75, 'value': 2589.95}, 'weekHighLow': {'min': 1473.45, 'minDate': '24-Mar-2020', 'max': 2777.15, 'maxDate': '13-Jan-2021', 'value': 2589.95}}
Overall CLI functionality-
$ jdata --help
Usage: jdata [OPTIONS] COMMAND [ARGS]...
This is a command line tool to download stock market data to csv files.
Options:
--help Show this message and exit.
Commands:
bhavcopy Downloads bhavcopy from NSE's website Download today's...
derivatives Sample usage- Download stock futures- jdata derivatives -s...
index Download historical index data $jdata index --symbol "NIFTY...
stock Download historical stock data $jdata stock --symbol STOCK1...
Download stock data-
$ jdata stock -s SBIN -f 2020-01-01 -t 2020-01-31 -o SBIN-Jan.csv
Download historical stock market data using python
2021-01-08Fetch live stock market data data using python
2021-01-08