pythonpandasdataframebloombergpdblp

Python / pdblp: Easiest way to pull a single historical request?


I have recently started using the pdblp module documented here. However, I find myself spending a lot of time trying to just manipulate the dataframes.

For example, the following code gives:

import pdblp as bbg

con = bbg.BCon(port=8194, timeout=5000, debug=False)
con.debug = False
con.start()
EURUSD = con.bdh('EURUSD Curncy', 'PX_LAST', monthEnd, monthEnd)
print(EURUSD)

The result is

ticker     EURUSD Curncy
field            PX_LAST
date                    
2019-11-29        1.1018

However, whats the easierst way to get EURUSD = 1.1018


Solution

  • In [1]: from xbbg import blp
    In [2]: blp.bdh('EURUSD Curncy', end_date='2019-11-30').iloc[-1, 0]
    Out[2]: 1.1018
    

    Reference: xbbg