pdblp
pdblp copied to clipboard
Pricing Source override in BDH not working?
Hi, Matt.
I have tried the following with many variations (i.e. PCS, PricingSource, pricingsource) and it doesn't seem to work. Any clues?
con = pdblp.BCon(timeout=5000)
con.start()
df = con.bdh(tickers=['AY24 Govt','AA21 Govt'], flds='PX_LAST', start_date='20190809', end_date='20190815',ovrds=[('PCS','BFUS')])
print(df)
I suspect the problem is in the ovrds field because when I run it without it, it works smoothly.
The error I get is:
Traceback (most recent call last):
File "c:/Users/tollobet/AppData/Local/Programs/Python/Python37/Scripts/Py/Argentina/AY24-AA21.py", line 14, in <module>
df = con.bdh(tickers=['AY24 Govt','AA21 Govt'], flds='PX_LAST', start_date='20190809', end_date='20190815',ovrds=[('PCS','BFUS')])
File "C:\Users\tollobet\AppData\Local\Programs\Python\Python37\lib\site-packages\pdblp\pdblp.py", line 275, in bdh
elms, ovrds)
File "C:\Users\tollobet\AppData\Local\Programs\Python\Python37\lib\site-packages\pdblp\pdblp.py", line 307, in _bdh_list
has_security_error = 'securityError' in d['securityData']
KeyError: 'securityData'
Thanks
It's helpful in theses cases to set debug=True
in your connection object, i.e. con.debug=True
, which lets you see the actual unparsed responses from Bloomberg. In your case this yields
pdblp.pdblp:INFO:Sending Request:
HistoricalDataRequest = {
securities[] = {
"AY24 Govt", "AA21 Govt"
}
fields[] = {
"PX_LAST"
}
startDate = "20190809"
endDate = "20190815"
overrides[] = {
overrides = {
fieldId = "PCS"
value = "BFUS"
}
}
}
pdblp.pdblp:INFO:Event Type: 'RESPONSE'
pdblp.pdblp:INFO:Message Received:
HistoricalDataResponse = {
responseError = {
source = "bbdbh6"
code = 27
category = "BAD_ARGS"
message = "Invalid override field id specified [nid:194] "
subcategory = "INVALID_OVERRIDE_FIELD"
}
}
So it appears that this override is not valid. I would either looks at FLDS in the terminal to try and find what the appropriate override is or discuss with the help desk since this is Bloomberg blpapi
specific.
Ok .Thank you. Bloomberg Support weren't very helpful.
BLOOMBERG HELP DESK : Unfortunately the Help Desk doesn't provide syntax support or creation for blpapi.
I don't see any overrides in FLDS, but the way I tried is how Excel manages it. I thought it would work as well. Well, thank you for your time. I'll post a solution later if I come up with one.
Yes the issue is the backend for the python API and Excel are not the same, so the FLDS uses in overrides are not identifcal to those in Excel. Possibly what you are looking for is PRICING_SOURCE
.
So, this didn't work. Although no error arises, the change in pricing source seems to make no difference. I found a way to make it work in FLDS but I'm not sure how to replicate it in pdblp.
The Pricing Source needs to be overwritten prior to calling the BDH function.
And then I can see the PX_LAST I want to:
Compare that with the default BVAL pricing source:
And:
Can you think of a way of doing this? I read the tutorial and saw no BDP function. Can this be called under the pdblp module? Thanks
The override being ignored is a feature / antifeature of the underlying blpapi Bloomberg API. If you set an override value which is not applicable (the actual value not the override field) then it just ignores the override. For something similar to BDP take a look at pdblp.BCon.ref
, which provides reference data. Something like
con.ref(tickers=['AY24 Govt','AA21 Govt'], flds='PX_LAST', ovrds=[('PRICING_SOURCE','BFUS')])
Are you saying that 'BFUS' is not valid or that 'PRICING_SOURCE' is not valid for 'PX_LAST'? I know for certain that 'BFUS' is a valid source. I'll see if I can find a workaround with the second function.
Best solution so far is to change the values in the terminal PCS menu. This forces you to use the same pricing source for all securities, but it's a start.
I am saying that when you make a HistoricalDataRequest
, setting BFUS
for PRICING_SOURCE
does not affect PX_LAST
. For example
Historical request without override
HistoricalDataRequest = {
securities[] = {
"AY24 Govt"
}
fields[] = {
"PX_LAST"
}
startDate = "20190815"
endDate = "20190815"
overrides[] = {
}
}
HistoricalDataResponse = {
securityData = {
security = "AY24 Govt"
eidData[] = {
}
sequenceNumber = 0
fieldExceptions[] = {
}
fieldData[] = {
fieldData = {
date = 2019-08-15
PX_LAST = 52.967000
}
}
}
}
Historical data request with override
HistoricalDataRequest = {
securities[] = {
"AY24 Govt"
}
fields[] = {
"PX_LAST"
}
startDate = "20190815"
endDate = "20190815"
overrides[] = {
overrides = {
fieldId = "PRICING_SOURCE"
value = "BFUS"
}
}
}
HistoricalDataResponse = {
securityData = {
security = "AY24 Govt"
eidData[] = {
}
sequenceNumber = 0
fieldExceptions[] = {
}
fieldData[] = {
fieldData = {
date = 2019-08-15
PX_LAST = 52.967000
}
}
}
}
whereas it does seem to affect the pricing when you make a ReferenceDataRequest
. I am unsure why this is.
Reference data without override
ReferenceDataRequest = {
securities[] = {
"AY24 Govt"
}
fields[] = {
"PX_LAST"
}
overrides[] = {
}
}
ReferenceDataResponse = {
securityData[] = {
securityData = {
security = "AY24 Govt"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 0
fieldData = {
PX_LAST = 46.076000
}
}
}
}
Reference data with override
ReferenceDataRequest = {
securities[] = {
"AY24 Govt"
}
fields[] = {
"PX_LAST"
}
overrides[] = {
overrides = {
fieldId = "PRICING_SOURCE"
value = "BFUS"
}
}
}
ReferenceDataResponse = {
securityData[] = {
securityData = {
security = "AY24 Govt"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 0
fieldData = {
PX_LAST = 46.100000
}
}
}
}