Does not load index data
Opened this issue · 2 comments
Nemexot commented
Issue description
Any operations with the index returns an error
Example Code
import datetime
import pandas as pd
from dateutil.relativedelta import relativedelta
from jugaad_data.nse import index_raw
# Get from and to dates
to_date = datetime.date.today()
from_date = to_date - relativedelta(years=3)
print(from_date, to_date)
# Fetch the index data
raw_index_data = index_csv(symbol="NIFTY 50",
from_date=from_date,
to_date=to_date)
Error snippet
2021-03-16 2024-03-16
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-19-e0e446968775> in <cell line: 12>()
10
11 # Fetch the index data
---> 12 raw_index_data = index_csv(symbol="NIFTY 50",
13 from_date=from_date,
14 to_date=to_date)
8 frames
/usr/local/lib/python3.10/dist-packages/jugaad_data/nse/history.py in _index(self, symbol, from_date, to_date)
311 }
312 r = self._post_json("index_history", params=params)
--> 313 return json.loads(self.r.json()['d'])
314
315 def index_raw(self, symbol, from_date, to_date):
KeyError: 'd'
devfinwiz commented
Faced similar issues related to indices modules across many libraries. It is because nse made modifications to its request payload a few days back and the code isn't updated for the same.
You can track this alternative api for various stuff and not just data gathering: https://github.com/devfinwiz/Fin-Maestro-Kin
It is presently in it's early stages of development. Active work on it is in progress. Once this is deployed, you can simply send your request to specific endpoints to receive results.
divyankm commented
+1 Facing Same error for Equity data
from jugaad_data.nse import index_csv, index_df
import json
# Download as pandas dataframe
df = index_df(symbol="NIFTY 50", from_date=date(2020,1,1),
to_date=date(2020,1,30))
print(df.head())
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
[<ipython-input-7-11a563af62bc>](https://localhost:8080/#) in <cell line: 5>()
3
4 # Download as pandas dataframe
----> 5 df = index_df(symbol="NIFTY 50", from_date=date(2020,1,1),
6 to_date=date(2020,1,30))
7
8 frames
[/usr/local/lib/python3.10/dist-packages/jugaad_data/nse/history.py](https://localhost:8080/#) in _index(self, symbol, from_date, to_date)
311 }
312 r = self._post_json("index_history", params=params)
--> 313 return json.loads(self.r.json()['d'])
314
315 def index_raw(self, symbol, from_date, to_date):
KeyError: 'd'