I am trying to request several bundles of data through pythons Datastreamdsws module, the first request processes perfectly, but when I iterate for the second and subsequent try it fails with the following error.
get_bundle_data : Exception Occured (<class 'TypeError'>, TypeError("argument of type 'NoneType' is not iterable"), <traceback object at 0x000001D0E2929240>) Traceback (most recent call last): File "C:\Users\user\miniconda3\envs\test\lib\site-packages\DatastreamDSWS\DS_Response.py", line 209, in get_bundle_data if 'DataResponses' in json_Response: TypeError: argument of type 'NoneType' is not iterable None
I have tried adding in some sleep time(60 seconds) to help slow it down but regardless it still happens.
I understand I can run a single request but this seems faster and better for our workflow. So I want to make it work.
Is there a way to disconnect are reconnect? or some other alternative, because I can run the script, then rerun again immediately and it works fine.
Alternatively, is there a function in the new RD Library which could replace my request?
I note in the documentation for dsws bundle request that there is a maximum of 100x5. I am operating in that with all requests having 20 tickers and 5 fields (100) and a maximum of 5 requests (500).
Here is the code I am running:
reqs = for i in range(6): for i in range(len(ticker_str_list)): reqs.append(ds.post_user_request(tickers=ticker_str_list[i], fields=['P','ISOCUR','P.U','PI','RI'], start=calc_date, end=calc_date, kind=0) sd = ds.get_bundle_data(bundleRequest=reqs)
successful 'sd' output example which happens on first request:
[100 rows x 5 columns], Instrument Datatype Value Currency Dates 0 <JYPE.NS> P 2.45 IR 2022-09-13 1 <GIBG.F> P 93 E 2022-09-13 2 <0503.HK> P 1.17 K$ 2022-09-13 3 <4942.TW> P 37.15 TW 2022-09-13 4 <AMA.MC> P 51.44 E 2022-09-13 .. ... ... ... ... ... 95 <HCH.AX> RI 13.41 A$ 2022-09-13 96 <CHDRAUIB.MX> RI 176.72 MP 2022-09-13 97 <1972.HK> RI 154.58 K$ 2022-09-13 98 <NEXT.TO> RI 60.41 C$ 2022-09-13 99 <CRDE.PK> RI 84.23 U$ 2022-09-13