Hope all of you are doing well. I'm having some trouble with dynamically adding data into Python from Bloomberg using blp and the "BEST_FPERIOD_OVERRIDE". I imported blp already, and used bquery through: bquery = blp.BlpQuery().start().
So, ultimately depending on what I override in Python for "BEST_FPERIOD_OVERRIDE" such as "27Y" or "25Y" which I found as an override function within "BEST_PE_RATIO", and I want the data to change accordingly. Here is my code:
KBCTest = bquery.bdh(
securities="KBC BB Equity",
fields="BEST_PE_RATIO",
start_date="20230510",
end_date= "20230515",
overrides={"BEST_FPERIOD_OVERRIDE": "FY2027"} # Assuming "27Y" meant fiscal year 2027
)
I have no idea what to do, any help would be appreciated.
These should be the typical parameters for bquery.bdh, create_historical_query(securities, fields, start_date, end_date, overrides, options).
I've tried everything.
As the OP may have already discovered, the definition of which overrides are valid for a Bloomberg field can be found in the Terminal.
eg KBC BB Equity FLDS <Go>
and searching for BEST_FPERIOD_OVERRIDE
which tells us that the code 27Y
will return Fiscal year 2027
.
Then it is a case of correctly specifying the parameters for securities (a list), fields (a list) and overrides (a list of tuples) in the bdh
call, eg:
from blp import blp
bquery = blp.BlpQuery().start()
KBCTest = bquery.bdh(
securities=['KBC BB Equity'],
fields=['BEST_PE_RATIO'],
start_date='20230510',
end_date= '20230515',
overrides=[('BEST_FPERIOD_OVERRIDE','27Y')]
)
which returns:
date security BEST_PE_RATIO
0 2023-05-10 KBC BB Equity x.206
1 2023-05-11 KBC BB Equity x.194
2 2023-05-12 KBC BB Equity x.273
3 2023-05-15 KBC BB Equity x.288