Idirect-Tech / Breeze-Python-SDK

The official Python client library for the ICICI Securities trading APIs
MIT License
63 stars 30 forks source link

JSONDecodeError on calling get_historical_data_v2 #158

Closed Ramkumar-R closed 3 hours ago

Ramkumar-R commented 6 hours ago

get_historial_data_v2 after working fine so far has suddenly started timing out with JSONDecodeError since Friday 15th Nov.
Please see error below and advise. Thanks. -Ramkumar

JSONDecodeError Traceback (most recent call last) File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/requests/models.py:974, in Response.json(self, kwargs) 973 try: --> 974 return complexjson.loads(self.text, kwargs) 975 except JSONDecodeError as e: 976 # Catch JSON-related errors and raise as requests.JSONDecodeError 977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File ~/anaconda3/envs/ICICI/lib/python3.12/json/init.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 343 if (cls is None and object_hook is None and 344 parse_int is None and parse_float is None and 345 parse_constant is None and object_pairs_hook is None and not kw): --> 346 return _default_decoder.decode(s) 347 if cls is None:

File ~/anaconda3/envs/ICICI/lib/python3.12/json/decoder.py:337, in JSONDecoder.decode(self, s, _w) 333 """Return the Python representation of s (a str instance 334 containing a JSON document). 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end()

File ~/anaconda3/envs/ICICI/lib/python3.12/json/decoder.py:355, in JSONDecoder.raw_decode(self, 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)

During handling of the above exception, another exception occurred:

JSONDecodeError Traceback (most recent call last) File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:1191, in ApificationBreeze.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 1190 response = requests.get(url=url, params=url_params, headers=headers) -> 1191 response = response.json() 1192 return response

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/requests/models.py:978, in Response.json(self, **kwargs) 975 except JSONDecodeError as e: 976 # Catch JSON-related errors and raise as requests.JSONDecodeError 977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 978 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

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

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last) Cell In[34], line 1 ----> 1 Index1.updateLTHistory()

Cell In[24], line 46, in INDEX.updateLTHistory(self) 44 print(s + " :Updating from " + sdate + " to " + yesterday + " inclusive") 45 # **** PLEASE USE v2 ** ---> 46 data = breeze.get_historical_data_v2(interval="1day", from_date = sdate + "T00:00:00.000Z", 47 to_date= yesterday + "T15:30:00.000Z", stock_code=s, exchange_code="NSE", product_type="cash") 48 # ** 49 time.sleep(1)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:884, in BreezeConnect.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 882 def get_historical_data_v2(self, interval="", from_date="", to_date="", stock_code="", exchange_code="", product_type="", expiry_date="", right="", strike_price=""): 883 if self.api_handler: --> 884 return self.api_handler.get_historical_data_v2(interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:1194, in ApificationBreeze.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 1192 return response 1193 except Exception as e: -> 1194 self.error_exception(self.get_historical_data_v2.name,e)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:970, in ApificationBreeze.error_exception(self, func_name, error) 968 def error_exception(self,func_name,error): 969 message = "{0}() Error".format(func_name) --> 970 raise Exception(message).with_traceback(error.traceback)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:1191, in ApificationBreeze.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 1189 url = config.BREEZE_NEW_URL + api_endpoint.HIST_CHART.value 1190 response = requests.get(url=url, params=url_params, headers=headers) -> 1191 response = response.json() 1192 return response 1193 except Exception as e:

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/requests/models.py:978, in Response.json(self, kwargs) 974 return complexjson.loads(self.text, kwargs) 975 except JSONDecodeError as e: 976 # Catch JSON-related errors and raise as requests.JSONDecodeError 977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 978 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

Exception: get_historical_data_v2() Error

Idirect-Tech commented 3 hours ago

Dear Client,

Could you please check now as we are getting proper response while calling get_historical_Data_V2() endpoint?

[E29CF836]

Thanks & Regards,

Hiten Solanki,

Team Breeze API,

ICICI Securities


From: Ramkumar Ramaswamy @.> Sent: Monday, November 18, 2024 7:17 AM To: Idirect-Tech/Breeze-Python-SDK @.> Cc: Subscribed @.***> Subject: [Idirect-Tech/Breeze-Python-SDK] JSONDecodeError on calling get_historical_data_v2 (Issue #158)

CAUTION: This email originated from outside the organization! Do not click links, open attachments or reply, unless you recognize the sender's email address! Use 'Report suspicious Email' button in the toolbar to report Phishing mails. Beware!

get_historial_data_v2 after working fine so far has suddenly started timing out with JSONDecodeError since Friday 15th Nov. Please see error below and advise. Thanks. -Ramkumar

JSONDecodeError Traceback (most recent call last) File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/requests/models.py:974, in Response.json(self, kwargs) 973 try: --> 974 return complexjson.loads(self.text, kwargs) 975 except JSONDecodeError as e: 976 # Catch JSON-related errors and raise as requests.JSONDecodeError 977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File ~/anaconda3/envs/ICICI/lib/python3.12/json/init.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 343 if (cls is None and object_hook is None and 344 parse_int is None and parse_float is None and 345 parse_constant is None and object_pairs_hook is None and not kw): --> 346 return _default_decoder.decode(s) 347 if cls is None:

File ~/anaconda3/envs/ICICI/lib/python3.12/json/decoder.py:337, in JSONDecoder.decode(self, s, _w) 333 """Return the Python representation of s (a str instance 334 containing a JSON document). 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end()

File ~/anaconda3/envs/ICICI/lib/python3.12/json/decoder.py:355, in JSONDecoder.raw_decode(self, 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)

During handling of the above exception, another exception occurred:

JSONDecodeError Traceback (most recent call last) File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:1191, in ApificationBreeze.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 1190 response = requests.get(url=url, params=url_params, headers=headers) -> 1191 response = response.json() 1192 return response

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/requests/models.py:978, in Response.json(self, **kwargs) 975 except JSONDecodeError as e: 976 # Catch JSON-related errors and raise as requests.JSONDecodeError 977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 978 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

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

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last) Cell In[34], line 1 ----> 1 Index1.updateLTHistory()

Cell In[24], line 46, in INDEX.updateLTHistory(self) 44 print(s + " :Updating from " + sdate + " to " + yesterday + " inclusive") 45 # **** PLEASE USE v2 ** ---> 46 data = breeze.get_historical_data_v2(interval="1day", from_date = sdate + "T00:00:00.000Z", 47 to_date= yesterday + "T15:30:00.000Z", stock_code=s, exchange_code="NSE", product_type="cash") 48 # ** 49 time.sleep(1)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:884, in BreezeConnect.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 882 def get_historical_data_v2(self, interval="", from_date="", to_date="", stock_code="", exchange_code="", product_type="", expiry_date="", right="", strike_price=""): 883 if self.api_handler: --> 884 return self.api_handler.get_historical_data_v2(interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:1194, in ApificationBreeze.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 1192 return response 1193 except Exception as e: -> 1194 self.error_exception(self.get_historical_data_v2.name,e)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:970, in ApificationBreeze.error_exception(self, func_name, error) 968 def error_exception(self,func_name,error): 969 message = "{0}() Error".format(func_name) --> 970 raise Exception(message).with_traceback(error.traceback)

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/breeze_connect/breeze_connect.py:1191, in ApificationBreeze.get_historical_data_v2(self, interval, from_date, to_date, stock_code, exchange_code, product_type, expiry_date, right, strike_price) 1189 url = config.BREEZE_NEW_URL + api_endpoint.HIST_CHART.value 1190 response = requests.get(url=url, params=url_params, headers=headers) -> 1191 response = response.json() 1192 return response 1193 except Exception as e:

File ~/anaconda3/envs/ICICI/lib/python3.12/site-packages/requests/models.py:978, in Response.json(self, kwargs) 974 return complexjson.loads(self.text, kwargs) 975 except JSONDecodeError as e: 976 # Catch JSON-related errors and raise as requests.JSONDecodeError 977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 978 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

Exception: get_historical_data_v2() Error

— Reply to this email directly, view it on GitHubhttps://github.com/Idirect-Tech/Breeze-Python-SDK/issues/158, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3TQZ43UCG2UUZGS5HZMZOL2BFBJ7AVCNFSM6AAAAABR6SDZWWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGY3DMOBTHA3TENA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Print this mail only if absolutely necessary. Save Paper. Save Trees." "The information contained in this e-mail and any attachments to this message are intended for the exclusive use of the intended recipient and may contain proprietary, confidential or legally privileged information. If you are not the intended recipient, please note that you are not authorised to disseminate, distribute or copy this e-mail or any parts of it or act upon/rely on the contents of this e-mail in any manner. Please notify the sender immediately by e-mail and destroy all copies of this e-mail and any attachments. Please also note that ICICI Bank or its subsidiaries and associated companies, (collectively "ICICI Group"), are unable to exercise control or ensure the integrity of/over the contents of the information contained in e-mail transmissions and that any views expressed in this e-mail are not endorsed by/binding on the ICICI Group unless the sender does so expressly with due authority of ICICI Group. Before opening any attachments please check them for viruses and defects and please note that ICICI Group accepts no liability or responsibility for any damage caused by any virus that may be transmitted by this email. Any unauthorized use of this email or any attachment(s) may be treated as infringement of right(s) including right of privacy under the applicable laws of India including Information and Technology Act, 2000. Thank you for your cooperation. Regulatory Disclosures are available on https://www.icicisecurities.com (for institutional business) and www.icicidirect.com (for retail business).

Ramkumar-R commented 3 hours ago

Thanks for attending to this. The api call is going through now.