Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pricing Source override in BDH not working? #66

Open
truebrew opened this issue Aug 15, 2019 · 8 comments
Open

Pricing Source override in BDH not working? #66

truebrew opened this issue Aug 15, 2019 · 8 comments
Labels

Comments

@truebrew
Copy link

truebrew commented Aug 15, 2019

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

@matthewgilbert
Copy link
Owner

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.

@truebrew
Copy link
Author

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.

@matthewgilbert
Copy link
Owner

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.

flds

@truebrew
Copy link
Author

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.
imagen
And then I can see the PX_LAST I want to:
imagen

Compare that with the default BVAL pricing source:
imagen
And:
imagen

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

@matthewgilbert
Copy link
Owner

matthewgilbert commented Aug 20, 2019

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')])

@truebrew
Copy link
Author

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.

@truebrew
Copy link
Author

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.

@matthewgilbert
Copy link
Owner

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
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants