alpha-xone / xbbg

An intuitive Bloomberg API
https://xbbg.readthedocs.io/
Apache License 2.0
246 stars 52 forks source link

bdp error when result involves arrays #21

Closed sob727 closed 3 years ago

sob727 commented 3 years ago

Hi,

I'm trying to use bdp to retrieve fields that typically return arrays (on the Terminal, under FLDS, such fields can be identified by the "Show Bulk Data" mention in the "Value" column.

Windows 10 Python 3.8.6 blpapi 3.15.2 xbbg 0.7.0

blp.bdp('TYA Index','FUT_CHAIN')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\S\PycharmProjects\test_bbg\venv\lib\site-packages\xbbg\blp.py", line 46, in bdp
    res
  File "C:\Users\S\PycharmProjects\test_bbg\venv\lib\site-packages\pandas\core\frame.py", line 7142, in unstack
    return unstack(self, level, fill_value)
  File "C:\Users\S\PycharmProjects\test_bbg\venv\lib\site-packages\pandas\core\reshape\reshape.py", line 418, in unstack
    return _unstack_frame(obj, level, fill_value=fill_value)
  File "C:\Users\S\PycharmProjects\test_bbg\venv\lib\site-packages\pandas\core\reshape\reshape.py", line 438, in _unstack_frame
    return _Unstacker(
  File "C:\Users\S\PycharmProjects\test_bbg\venv\lib\site-packages\pandas\core\reshape\reshape.py", line 120, in __init__
    self._make_selectors()
  File "C:\Users\S\PycharmProjects\test_bbg\venv\lib\site-packages\pandas\core\reshape\reshape.py", line 169, in _make_selectors
    raise ValueError("Index contains duplicate entries, cannot reshape")

The returned value doesn't sit well with the unstack function from pandas. Let me know if there's more info I can provide.

alpha-xone commented 3 years ago

Need to use blp.bds for bulk data

sob727 commented 3 years ago

I stand corrected. Thank you Sir.

kamilla2101 commented 1 year ago

have the same issue, exactly the same list of securities works for one source (fixed income) test = blp.bdp(isin,"PX_BID"), but doesn't work for another source. It shows:
`189 mask.put(selector, True) 191 if mask.sum() < len(self.index): --> 192 raise ValueError("Index contains duplicate entries, cannot reshape") 194 self.group_index = comp_index 195 self.mask = mask

ValueError: Index contains duplicate entries, cannot reshape`