jugaad-data icon indicating copy to clipboard operation
jugaad-data copied to clipboard

Option chain data downloading issue

Open thepraveen19 opened this issue 2 years ago • 1 comments

Issue description

Can't download option chain data. Screenshot attached.

Screenshot 2022-03-30 at 07 06 45

Example Code

from jugaad_data.nse import derivatives_csv, derivatives_df
df = derivatives_df(symbol="SBIN", from_date=date(2022,1,1), to_date=date(2022,2,24),
            expiry_date=date(2022,3,31), instrument_type="OPTSTK", option_type="CE", strike_price=500)
print(df.head())

Error snippet

JSONDecodeError                           Traceback (most recent call last)
[<ipython-input-42-2a115219c3d7>](https://eei938yvh5k-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20220328-060046-RC02_437851183#) in <module>()
      1 from jugaad_data.nse import derivatives_csv, derivatives_df
      2 df = derivatives_df(symbol="SBIN", from_date=date(2022,1,1), to_date=date(2022,2,24),
----> 3             expiry_date=date(2022,3,31), instrument_type="OPTSTK", option_type="CE", strike_price=500)
      4 print(df.head())

11 frames
[/usr/lib/python3.7/json/decoder.py](https://eei938yvh5k-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20220328-060046-RC02_437851183#) in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

thepraveen19 avatar Mar 30 '22 06:03 thepraveen19

As I tried to run the same code, I could fetch the data

image

please do check and let us know.

bpkapkar avatar Oct 15 '22 16:10 bpkapkar

This looks an issue with NSE website, if you make a lot of requests in short time, NSE will respond with error, which might not be json.. which might result in the error you saw.

There isnt anything we can do I believe, only thing we can do is try to play nice with NSEpy and throttle requests

sevakram avatar Jan 20 '23 11:01 sevakram