alpha-xone / xbbg

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

XBBG mapping new tickers #23

Closed sapre101 closed 3 years ago

sapre101 commented 3 years ago

hi there, great package for simple access to BBG, many thanks!

i've adding many new commodity tickers to the assets/exch.yml files successfully.

e.g. assets:

tickers: [SM] exch: CBT freq: Q is_fut: True for SM1 Comdty

however, i have a number of tickers with a slightly "strange" format: W 1 Comdty, C 1 Comdty etc

if i try the below, mapping, it doesnt work. I've also tried [W ] (with a space after), which doesnt work either.

tickers: [W] exch: CBT freq: Q is_fut: True i think its because of the space "W 1 Comdty", whereas the normal format for generic tickers seems to be "W1 Comdty"

any ideas would be much appreciated!!!

thanks

alpha-xone commented 3 years ago

You can try putting the list of tickers together:

tickers: [SM, W, C] exch: CBT freq: Q is_fut: True

sapre101 commented 3 years ago

thanks. i tried that and still the same error unfortunately. (tried also with a space after "W "). error message as below:

2020-12-11 09:01:11,486:xbbg.const.exch_info:ERROR:required exchange info cannot be found in C 1 Comdty ... Traceback (most recent call last):

File "", line 1, in bbg()

File "C:\m_PyFolioProject\untitled0.py", line 24, in bbg b=blp.bdtick('C 1 Comdty', dt='2020-12-04',)

File "C:\myPythonVenv\lib\site-packages\xbbg\blp.py", line 306, in bdtick dt=dt, ticker=ticker, session=session, tz=exch.tz, **kwargs

File "C:\myPythonVenv\lib\site-packages\pandas\core\generic.py", line 5139, in getattr return object.getattribute(self, name)

AttributeError: 'Series' object has no attribute 'tz'

alpha-xone commented 3 years ago

you can try using ref to go around the issue temporarily:

blp.bdtick('C 1 Comdty', dt='2020-12-04', ref='SM1 Comdty')

What's the exchange info you added to exch.yml? Would probably add into the next release as well.

sapre101 commented 3 years ago

ok great, yes that works. i can use this work around for 3 tickers impacted.

below is the exchange details for CBOT (SM, W, C etc):

many thanks

CBT: tz: America/New_York allday: [1800, 1700] day: [800, 1700]