Field override for bdh() in pdblp

9.7k Views Asked by At

Bloomberg help isn't very helpful for their API. Can anyone please explain how to replace PX_LAST with the dividend adjusted price field. I have attempted the following but have been unsuccessful

import pdblp
con = pdblp.BCon()
con.start()

df2 = con.bdh(['NQ1 Index', 'DM1 Index'], ['PX_LAST'],
              '20061227', '20061231', elms=[("periodicityAdjustment", "ACTUAL")])
2

There are 2 best solutions below

0
On BEST ANSWER

The best place to look for this information is in the BLOOMBERG OPEN API – REFERENCE SERVICES & SCHEMAS GUIDE. To access this, from a Bloomberg Terminal go WAPI <GO> -> API Developer's Guide.

These are from page 20 BLOOMBERG OPEN API – REFERENCE SERVICES & SCHEMAS GUIDE

adjustmentSplit {TRUE, FALSE}

Adjust historical pricing and/or volume to reflect: Spin-Offs, Stock Splits/Consolidations, Stock Dividend/Bonus, Rights Offerings/ Entitlement.

adjustmentFollowDPDF {TRUE, FALSE}

Setting to true follows the DPDF BloombergProfessional service function. True is default setting for this option

An example of this is showing Apple with and without the split adjustment incorporated is.

import pdblp

con = pdblp.BCon().start()

con.bdh("AAPL US Equity", "PX_LAST", "20140604", "20140610",
        elms=[("adjustmentSplit", True)])

ticker     AAPL US Equity
field             PX_LAST
date                     
2014-06-04        92.1171
2014-06-05        92.4786
2014-06-06        92.2243
2014-06-09        93.7000
2014-06-10        94.2500

con.bdh("AAPL US Equity", "PX_LAST", "20140604", "20140610",
        elms=[("adjustmentSplit", False)])

ticker     AAPL US Equity
field             PX_LAST
date                     
2014-06-04         644.82
2014-06-05         647.35
2014-06-06         645.57
2014-06-09          93.70
2014-06-10          94.25
1
On

Can try out another wrapper library on top of pdblp: xbbg

It’s possible to use same overrides as in Excel and use kwargs directly. Before any adjustments:

from xbbg import blp

blp.bdh(
    'AAPL US Equity', 'Px_Last', '20140604', '20140610',
    CshAdjNormal=False, CshAdjAbnormal=False, CapChg=False,
)

Output:

ticker     AAPL US Equity
field             Px_Last
date                     
2014-06-04         644.82
2014-06-05         647.35
2014-06-06         645.57
2014-06-09          93.70
2014-06-10          94.25

Adjust for splits:

blp.bdh(
    'AAPL US Equity', 'Px_Last', '20140604', '20140610',
    CshAdjNormal=True, CshAdjAbnormal=True, CapChg=True,
)

Output:

ticker     AAPL US Equity
field             Px_Last
date                     
2014-06-04          85.12
2014-06-05          85.45
2014-06-06          85.22
2014-06-09          86.58
2014-06-10          87.09