Error message:
Cannot find exchange info for ZSIU3 INDEX'
code:
from xbbg import blp
from datetime import datetime, timedelta
blp.bdib('ZSIU3 INDEX', '2023-07-05 00:00:00',ref = 'EUX-Eurex')
(mentioned in the index in ref section of the above command using BBG)
anyone knows a better way to get the prices?
code:
from xbbg import blp
from datetime import datetime, timedelta
blp.bdib('ZSIU3 INDEX', '2023-07-05 00:00:00',ref = 'EUX-Eurex')
I am pretty sure there are similar questions with answers on SO, but at the risk of duplication ...
The bdib
function in xbbg
tries to take away the complexity of specifying timezones when asking for intra-day data. The underlying Bloomberg API only deals with UTC times. xbbg
uses an "exchange" string to identify the timezone and hours of operation.
xbbg
has a number of configuration files in the package directory (your_python_install/Lib/site-packages/xbbg/markets
) one of which is exch.yml
. If you look in this file, you will see entries in the form:
FuturesCBOE:
tz: America/New_York
allday: [1800, 1700]
Every exchange you want to use should have an entry in this file. The as-supplied file does not include "EUX-Eurex" (hence the error you get), so you have to add it yourself, and give it a name (I've used the existing pattern, but you can choose what you want).
FuturesEuropeEurex:
tz: Europe/Berlin
allday: [210, 2200]
(I realize Eurex is in Frankfurt but it seems xbbg
only understands capital cities).
The allday
session is the default, and you can get this info from Bloomberg, which tells me the exchange hours (for EUX-Eurex
) are 02:10-22:00.
Depending on where you have installed Python you may need Admin privilege to edit exch.yml
and also the first time you run your code (as the file gets "pickled" into the cache).
If you add this entry, then this code will work:
from xbbg import blp
from datetime import datetime, timedelta
blp.bdib('ZSIU3 INDEX', datetime(2023,7,5),ref = 'FuturesEuropeEurex')
and yield something like:
ZSIU3 INDEX
open high low close volume num_trds value
2023-07-05 11:10:00+02:00 7xxx.0 7xxx.0 7xxx.0 7xxx.0 1 1 7xxx.0
2023-07-05 11:16:00+02:00 7xxx.0 7xxx.0 7xxx.0 7xxx.0 1 1 7xxx.0
2023-07-05 12:39:00+02:00 7xxx.0 7xxx.0 7xxx.0 7xxx.0 24 1 1xxx.0
2023-07-05 13:28:00+02:00 7xxx.0 7xxx.0 7xxx.0 7xxx.0 30 1 2xxx.0
2023-07-05 13:29:00+02:00 7xxx.0 7xxx.0 7xxx.0 7xxx.0 15 1 1xxx.0
2023-07-05 13:40:00+02:00 7xxx.0 7xxx.0 7xxx.0 7xxx.0 28 1 2xxx.0
NB Bloomberg only stores 6 months of intraday data, so you may need to change dates and/or tickers to run this sample. One drawback of bdib
as implemented is that you can only retrieve one day of data at a time, even though the Bloomberg API allows the specification of start and end UTC datetimes. So it is swings and roundabouts depending on your use-case.
As an aside, you can map tickers to exchanges using the assets.yml
file but you will still need the exchange info.