NSE file is unavailable or not yet updated
ArunTS96 opened this issue · 8 comments
C:\Users\Admin\Documents\Stocks\Code\PythonRS\eod2\src>pip install nse
Collecting nse
Downloading nse-0.2.6.post2-py3-none-any.whl.metadata (2.6 kB)
Requirement already satisfied: mthrottle>=0.0.1 in c:\python311\lib\site-packages (from nse) (0.0.1)
Requirement already satisfied: requests>=2.31.0 in c:\python311\lib\site-packages (from nse) (2.31.0)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\python311\lib\site-packages (from requests>=2.31.0->nse) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in c:\python311\lib\site-packages (from requests>=2.31.0->nse) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\python311\lib\site-packages (from requests>=2.31.0->nse) (2.0.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\python311\lib\site-packages (from requests>=2.31.0->nse) (2023.5.7)
Downloading nse-0.2.6.post2-py3-none-any.whl (21 kB)
Installing collected packages: nse
Successfully installed nse-0.2.6.post2
C:\Users\Admin\Documents\Stocks\Code\PythonRS\eod2\src>python init.py
NSE Holiday list updated
Downloading Files
RuntimeError('NSE file is unavailable or not yet updated.')
def __download(self, url: str, folder: Path):
'''Download a large file in chunks from the given url.
Returns pathlib.Path object of the downloaded file'''
fname = folder / url.split("/")[-1]
th.check()
with self.session.get(url, stream=True, timeout=15) as r:
contentType = r.headers.get('content-type')
if contentType and 'text/html' in contentType:
raise RuntimeError(
'NSE file is unavailable or not yet updated.')
with fname.open(mode='wb') as f:
for chunk in r.iter_content(chunk_size=1000000):
f.write(chunk)
return fname
Hi Arun,
Did you run this code today?
I ran mine today at 7pm and everything is working fine. Most likely you ran it before 7pm. In that case, rerun the script and all should be fine.
Downloading Files
Starting Data Sync
EOD sync complete
Index sync complete.
Makings adjustments for splits and bonus
Cleaning up files
0 files deleted
03 Jan 2024: Done
----------------------------------------------------
Regardless, check your EOD2 version, run py init.py -v
it should read version 5.1.0
. If not try updating the both the repo and eod2_data
If all else fails, open the meta.json
file in eod2_data
folder and let me know the last update date.
Hope your coding journey is going well. 😄
Hi, Benny.
Tried in a fresh setup
C:\TestEod2\eod2>python setup.py
eod2_data folder has data. Renaming folder to eod2_data_backup.
Downloading eod2_data from https://github.com/BennyThadikaran/eod2_data/archive/main.zip
Download success.
Extracting Zipfile to eod2_data
Done
C:\TestEod2\eod2>cd src
C:\TestEod2\eod2\src>python init.py
NSE Holiday list updated
Downloading Files
RuntimeError('NSE file is unavailable or not yet updated.')
C:\TestEod2\eod2\src>py init.py -v
EOD2 init.py: version 5.1.0
C:\TestEod2\eod2\src>
Will try it tomorrow morning from different network connection to rule out network issue.
Thanks for the quick response.
Oh ok you're not using git. I will test with setup.py
in the morning and get back.
Can you also tell me what the lastUpdate
is showing on eod2_data/meta.json
. I can replicate the issue better that way.
Thanks for bringing this up. 👍
Hi Arun, I see the problem now. I work on a fix and get back to you. Thanks again for reporting this.
This is a nasty little error. It occurs in defs.py:checkForHolidays
- Since 25th Dec 2023 was Christmas holiday, it tried to redownload the holiday list to confirm.
- Since it is 2024 now, NSE returned holidays for 2024 and not 2023
- 25-Dec-2023 was not found in the holiday list, so it proceeded to download the data, resulting in the error.
I update EOD2 on a daily basis, so never encountered the error.
Primary issues are:
- We cannot get the previous year holiday data.
- Some holiday dates can change from year to year. If user has not synced their data in a long time, risk of such an issue occuring is higher.
I will go ahead and sync the eod2_data
folder, so anyone affected by this issue can update the eod2_data
folder from the repo and move on.
Keep this issue open, I need to spend some time considering a fix.
eod2_data
is fully updated now upto 3rd Jan 2024. You can delete the eod2_data
folder in your local repo and run py setup.py
to get the latest data. Everything should work fine then.
For git users follow this instruction here update git repo and eod2_data
Awesome Benny. Missed updating during end of the year due to vacation. Thanks for the clear explanation. Will mark this as resolved.