Search code examples
bloomberg

@BFxForward() in the Bloomberg python api


I've used https://github.com/691175002/BLPInterface as a wrapper to the terribly-documented (and non-supported by Bloomberg Help) Bloomberg python API. I use it to pull price histories, etc.

Lately I've needed to pull specific FX date values. In excel I do that as =@BFxForward("usdjpy",J10, "BidOutright") where J10 is a date.

I would like to pull this information via the Bloomberg Python API (or even better, with the BLPInterace wrapper) but it's not clear how to do it. I've seen someone ask a similar question for a .Net implementation, but the only answer cited page 207 of a developers guide. Every developer guide I can find on bloomberg is well less than 200 pages, and none of it mentions pulling fx values.

Wondering if anyone can point me at some examples or resources to build on to get this ?


Solution

  • It does take some finding, to be sure, but I tracked it down via the Bloomi Terminal. The way I found the information is as follows (for future reference):

    • Type DAPI in the Bloomberg Terminal
    • Choose 'Additional Resources' in the left hand panel
    • Choose 'Help Page for DAPI' in the right hand panel, and a window pops up
    • Choose 'Constructing Formulas' in the left hand panel
    • Choose 'FX Broken Dates Forwards Syntax' in the right hand panel

    Or paste this link into Bloomi: {LPHP DAPI:0:1 2277846 }

    There are a lot of different examples and options (FX fwds are not my area of expertise), but simply using this format for the ticker seems to work:

    ccy1/ccy2 mm/dd/yy Curncy

    and then the field PX_BID. You can try this in a BDP call in Excel, for example:

    =BDP("EUR/GBP 08/08/22 Curncy","PX_BID")

    When it comes to Python, perhaps try using the xbbg python package (other wrappers are available): it does a good job of hiding all the intricacies of the low-level API.

    Here's a code sample using xbbg, that pulls back the forward fx rate in the example:

    from xbbg import blp
    from datetime import datetime
    
    ccy1 = 'EUR'
    ccy2 = 'GBP'
    fwdDate = datetime(2022,8,8)
    
    ticker = '{0:}/{1:} {2:} Curncy'.format(ccy1,ccy2,fwdDate.strftime('%m/%d/%y'))
    
    df = blp.bdp(ticker,'PX_BID')
    
    print(df)
    

    Output:

                              px_bid
    EUR/GBP 08/08/22 Curncy  0.85344
    

    EDIT: Looking at the OP's choice of Bloomi wrapper, the xbbg call could possibly be replaced by:

    blp.referenceRequest(ticker, 'PX_BID')