Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing data while pulling historical stock prices #41

Open
thebigdataplayer opened this issue Jan 18, 2023 · 2 comments
Open

Missing data while pulling historical stock prices #41

thebigdataplayer opened this issue Jan 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@thebigdataplayer
Copy link

Issue description

Below is the code for downloading historical stock data for a company to a CSV file

from datetime import date from jugaad_data.nse import stock_csv stock_csv(symbol="NATIONALUM", from_date=date(2020,1,1), to_date=date(2023,1,18), series="EQ", _output="D:\\Stock\\NALUM.csv")

NSE Symbol : NATIONALUM
From Date : 1/1/2020
To Date : 1/18/2023

This should've pulled the data for all the 760 trading days in that time range into the CSV file. However the data is missing for the time period 10/6/2021 to 31/5/2022

This isn't a standalone issue for this particular company. All of them have the same issue of missing data for a particular period within the expected time range
nationalum.txt
NALUM.csv

Example Code

from datetime import date
from jugaad_data.nse import stock_csv
            
# Download data and save to a csv file
stock_csv(symbol="NATIONALUM", from_date=date(2020,1,1),
            to_date=date(2023,1,18), series="EQ", output="D:\\Stock\\NALUM.csv")

Error snippet

Not an error. Missing data in the output file as explained in the description
@thebigdataplayer thebigdataplayer added the bug Something isn't working label Jan 18, 2023
@sevakram
Copy link
Contributor

Can you please help us with debugging.

  1. Can you please share the output of break_dates for the given date range, this function is in util.py
    https://github.com/jugaad-py/jugaad-data/blob/master/jugaad_data/util.py
    It is supposed to break the dates on month

  2. If the above step is ok, then please check if you are getting correct data from nse website for 1/6/2021 to 31/6/2021, 1/7/2021 to 30/7/2021.. randomly for few months

  3. If 2 is ok, check .cache folder in your home directory does it have data for those symbols

@vaibhavsegat
Copy link

I faced the same problem with the below input:

  1. 'symbol': BBOX
  2. 'from_date': 01-07-2021
  3. 'to_date': 31-07-2021
  4. 'series': EQ

With the below snippet, I got an empty DataFrame as a response.

from jugaad_data.nse import stock_df

df = stock_df('BBOX', from_date=from_date, to_date=to_date, series=series)

On looking at the data on the NSE website, I found that the series changed from EQ to BE on 2021-06-09 and onwards until 2021-11-22.
bbox_nse_data

This can be fixed by changing the interface of NSEHistory._stock to accept a tuple of series, i.e. def _stock(self, symbol, from_date, to_date, series=("EQ",)):, and its usages. See the below snippets. This can be made backwards compatible relatively easily by converting series if it is a string to a tuple of string.

jugaad_data_issue1

jugaad_data_fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants