Closed NoahKauffman closed 6 years ago
Please copy the actual output from your screen which is printed out when debug=True
into your message.
If you look at the docstring for bdh
you will see
Signature: con.bdh(tickers, flds, start_date, end_date, elms=[], ovrds=[], longdata=False)
Docstring:
Get tickers and fields, return pandas Dataframe with columns as
MultiIndex with levels "ticker" and "field" and indexed by "date".
If long data is requested return DataFrame with columns
["date", "ticker", "field", "value"].
Parameters
----------
tickers: {list, string}
String or list of strings corresponding to tickers
flds: {list, string}
String or list of strings corresponding to FLDS
start_date: string
String in format YYYYmmdd
end_date: string
String in format YYYYmmdd
elms: list of tuples
List of tuples where each tuple corresponds to the other elements
to be set, e.g. [("periodicityAdjustment", "ACTUAL")]
Refer to A.2.4 HistoricalDataRequest in the Developers Guide for
more info on these values
ovrds: list of tuples
List of tuples where each tuple corresponds to the override
field and value
longdata: boolean
Whether data should be returned in long data format or pivoted
elms
comes before ovrds
, so you are specifying an elms
in your call not ovrds
. You need to provide the key value pair, i.e.
con.bdh('IBM US EQUITY', 'TRAIL_12M_NET_SALES', '20020101', '20180319',
ovrds=[('FUND_PER', 'Y')])
Hi, I'm having a similar trouble when attempting to specify overrides. The excel function is =BDH("SPX Index","IVOL_DELTA","1/1/2016","12/31/2017","IVOL_DELTA_LEVEL=DELTA_LVL_25","IVOL_DELTA_PUT_OR_CALL=IVOL_PUT","IVOL_MATURITY=MATURITY_90D")
and my python proxy is:
import pdblp
import datetime
con = pdblp.BCon(debug=True, port=8194, timeout = 5000)
con.start()
start_date = datetime.datetime(2014,3,26).date().strftime('%Y%m%d')
end_date = datetime.datetime.today().strftime('%Y%m%d')
df = con.bdh('SPX Index', 'IVOL_DELTA', start_date, end_date, elms=[("calendarCodeOverride", 'US'),("IVOL_DELTA_LEVEL", "DELTA_LVL_25")])
con.close()
with output: NotFoundException: Sub-element '(null)' does not exist. (0x0006000d)
Should I use ovrds instead of elms? The appropiate api implementation according to BBG is among the lines of
override1.setElement("fieldId", "IVOL_DELTA_LEVEL") override1.setElement("value", "DELTA_LVL_25")
Thanks for your help!
Solved it, proper syntax is:
df = con.bdh('SPX Index', 'IVOL_DELTA', start_date, end_date,
ovrds=[("IVOL_DELTA_LEVEL","DELTA_LVL_25"),("IVOL_DELTA_PUT_OR_CALL","IVOL_PUT"),("IVOL_MATURITY","MATURITY_90D")],
elms=[("calendarCodeOverride", 'US')])
:)
I'm marking this as closed since it appears to be a syntax error.
Question RE override not working for following bdh call:
If you call this without the override, it returns quarterly data. In excel using either the override "FUND_PER=Y" correctly returns the results in yearly frequency.