Closed marinPh closed 3 months ago
When doing a bit of debugging I found that the error comes from the fact that:
for msg in self._receive_events(): d = msg['element']['IntradayBarResponse']
in pdplb.py line 677
every d is a empty and retrieves nothing.
I think there are limits on this history you can pull from the Bloomberg api
On Mon, Aug 12, 2024 at 4:47 AM marinPh @.***> wrote:
When doing a bit of debugging I found that the error comes from the fact that: for msg in self._receive_events(): d = msg['element']['IntradayBarResponse'] in pdplb.py line 677 every d is a empty and retrieves nothing.
— Reply to this email directly, view it on GitHub https://github.com/matthewgilbert/pdblp/issues/105#issuecomment-2283416658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASKGAS5ZV4OEBG7RJW4S63ZRBZDVAVCNFSM6AAAAABMLWQJCWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBTGQYTMNRVHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Yes I think there is, it does not however give any error if the endTime is before the max history, but still only gives the price inside the threshold
The issue is until what date does the API requests data. However, an error of pdblp saying that the wanted date has no data because of the threshold could help
Code Sample, a copy-pastable example if possible
Problem description
I want to get every 2 hours the trades, but I want it from 260 days to 250 days before now, (very base case the goal is to have bigger interval). But I got the error :
KeyError Traceback (most recent call last) Cell In[4], line 11 9 #print(f"index{code},fields{str(field)}") 10 print(startstring,endstring) ---> 11 prices = con.bdib(f'CO2 Comdty', startstring,endstring,'TRADE',120) 12 prices.columns = map(lambda x : 'CO' + x,prices.columns)
File ~\AppData\Roaming\Python\Python310\site-packages\pdblp\pdblp.py:686, in BCon.bdib(self, ticker, start_datetime, end_datetime, event_type, interval, elms) 683 for bar in d['barData']['barTickData']: 684 data.append(bar['barTickData']) --> 686 data = pd.DataFrame(data).set_index('time').sort_index().loc[:, flds] 687 return data
File c:\Projects\Anaconda39\lib\site-packages\pandas\util_decorators.py:331, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, *kwargs)
325 if len(args) > num_allow_args:
326 warnings.warn(
327 msg.format(arguments=_format_argument_list(allow_args)),
328 FutureWarning,
329 stacklevel=find_stack_level(),
330 )
--> 331 return func(args, **kwargs)
File c:\Projects\Anaconda39\lib\site-packages\pandas\core\frame.py:6012, in DataFrame.set_index(self, keys, drop, append, inplace, verify_integrity) 6009 missing.append(col) 6011 if missing: -> 6012 raise KeyError(f"None of {missing} are in the columns") 6014 if inplace: 6015 frame = self
KeyError: "None of ['time'] are in the columns"
Expected Output
a panda with the columns open,close,high,low,volume,numevents and indices every hour between those 2 intervals
Version Information
0.1.8