nsepy icon indicating copy to clipboard operation
nsepy copied to clipboard

Not Getting Data.

Open pavanpolineni opened this issue 5 years ago • 9 comments

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: []

pavanpolineni avatar Dec 30 '18 07:12 pavanpolineni

@swapniljariwala please check

pavanpolineni avatar Dec 30 '18 07:12 pavanpolineni

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.

meticulousCraftman avatar Dec 30 '18 14:12 meticulousCraftman

Then any other alternative solution ?

pavanpolineni avatar Dec 31 '18 00:12 pavanpolineni

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.

meticulousCraftman avatar Dec 31 '18 05:12 meticulousCraftman

NSE India's site is back online with the historical data and so is nsepy. Now you can fetch historical data.

meticulousCraftman avatar Dec 31 '18 15:12 meticulousCraftman

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!

meticulousCraftman avatar Jan 08 '19 10:01 meticulousCraftman

@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 avatar Apr 15 '19 04:04 sachin2404

@sachin2404 Tried doing it still it is taking forever to get data

divatemangesh avatar Feb 27 '20 07:02 divatemangesh

@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 ----> 1 trading_days = nse.get_hist().index 2 trading_days = list(trading_days.map(lambda x: x.date())) 3 day = trading_days[-1] ... -> 3363 raise KeyError(key) from err 3364 3365 if is_scalar(key) and isna(key) and not self.hasnans:

KeyError: 'Date'

vennelakantis avatar Jun 21 '22 02:06 vennelakantis