nsepy
nsepy copied to clipboard
Not Getting Data.
Always getting Empty data
`from nsepy import get_history
from datetime import date
data = get_history(symbol="SBIN", start=date(2015,12,1), end=date(2015,12,10)) print("first Out Put") print(data)
print("Second Out Put") data1 = get_history(symbol="sbin", start=date(2015,12,1), end=date(2015,12,10)) print(data1)`
Output ::
first Out Put Empty DataFrame Columns: [Symbol, Series, Prev Close, Open, High, Low, Last, Close, VWAP, Volume, Turnover, Trades, Deliverable Volume, %Deliverble] Index: [] Second Out Put Empty DataFrame Columns: [Symbol, Series, Prev Close, Open, High, Low, Last, Close, VWAP, Volume, Turnover, Trades, Deliverable Volume, %Deliverble] Index: []
@swapniljariwala please check
I too am facing the same problem. I think this is because of the NSE India's site. As of today, you won't be able to download any historical data from NSE India's site. Since nsepy scrapes historical data from NSE India's site, this is the reason why you are not getting the historical data.
Then any other alternative solution ?
One thing you could do is wait for NSE India site to make the historical data available or you could look into this fix-yahoo-finance on pypi and the same project on github.
If you are gonna use fix_yahoo_finance library. There is a syntax which you need to follow in case you want to fetch Indian stock market data(<TICKER_SYMBOL>.NS).
from pandas_datareader import data as pdr
import fix_yahoo_finance as yf
yf.pdr_override()
# download dataframe
data = pdr.get_data_yahoo("ONGC.NS", start="2017-01-01", end="2017-04-30")
This works sometimes and sometimes it doesn't.
I'm building my own historical data API that would fetch data from Upstox(Paid), Zerodha(Paid), NSE, Yahoo finance. It isn't complete and the work is still in progress. I'll update you whenever it's done. Here are the links for my project: Github -> TickerStore PyPI -> TickerStore Still a lot of work has to be done, documentation has to be written, example code etc.
NSE India's site is back online with the historical data and so is nsepy. Now you can fetch historical data.
Hey @pavanpolineni As I previously explained that I was working on historical data library. You can take a look at TickerStore. I have written documentation for the project. More documentation and support for the project will be provided soon.
Thank You!
@pavanpolineni @swapniljariwala
just add the following line that works... syntax : dataframe.reste_index()
data.reset_index() ...put this line after this line data = get_history(symbol="SBIN", start=date(2015,12,1), end=date(2015,12,10))
This is definitely work
@sachin2404 Tried doing it still it is taking forever to get data
@swapniljariwala get_hist() is throwing 'Date' error for the last couple of days. Unable to get trading days, even bhavcopy_FnO() is also throwing same error. Kindly resolve issue. KeyError Traceback (most recent call last) c:\Users\Babu\anaconda3\envs\bhav\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 3360 try: -> 3361 return self._engine.get_loc(casted_key) 3362 except KeyError as err:
c:\Users\Babu\anaconda3\envs\bhav\lib\site-packages\pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
c:\Users\Babu\anaconda3\envs\bhav\lib\site-packages\pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'Date'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17508/2452940433.py in
KeyError: 'Date'