rdatabasebloomberg

export yield curve data from bloobmerg


Pretty new to R and bloomberg here. I need to export historical yield curve data for as many countries as possible. I a package that links to a bloomberg terminal.

I can't find a way to get the function to work, though. This is what I have so far. Again, ideally I want this for as many tickers as possible and going as far back as possible

library("Rblpapi")
# Connect to Bloomberg
blpConnect()
tickers <- c("I16", "I22", "I7")
data=bdh(tickers, 'PX_MID',start.date =  "2023-01-29")

Solution

  • The values I16 etc are the Bloomberg "Curve Id"s. These can be used in calls to the //blp/instruments API service, for a curveListRequest, by setting the curveid field in the request. This request will return the ticker for the curve ... in this case YCGT0016 Index. It may be simpler to use the ticker rather than use the instruments lookup.

    I16 is the "EUR German Sovereign Curve". Thus the curve is built from different bonds each day (as they roll down the curve). This is in contrast to a swap curve, when the ticker for each tenor doesn't change. This makes extracting the historic curve a little harder.

    I am not familiar with the R interface, but I think it has access to the bds functionality, though may require overrides to be specified in a different way. Here's the same process in Python:

    In Python

    One method is to use bds in xbbg to get the bulk data field CURVE_TENOR_RATES, and overriding the CURVE_DATE field.

    eg:

    from xbbg import blp
    from datetime import date
    
    curveTicker = 'YCGT0016 Index'
    bbgFld = 'CURVE_TENOR_RATES'
    
    histdate = date(2023,1,29)
    
    constituents = blp.bds(curveTicker,bbgFld,curve_date=histdate.strftime("%Y%m%d"))
    

    And this will give you the curve for the date nearest to (but before) the date you request. Thus you can access the historical curve, but it is not quick, as you have to call repeatedly for each day.

    As a shortcut, for a small sub-set of sovereigns (only 8: US, Germany, Japan, France, Italy, UK, Canada, and Spain) Bloomberg publishes a par spline curve, and you can pull out time-series of each of the constant-maturity tickers (using bdh)

    Bloomberg Ticker Example Rate
    RV0001P tenor BLC Curncy RV0001P 10Y BLP Curncy UST 10y par rate
    RV0005P tenor BLC Curncy RV0005P 6M BLP Curncy BTPS 6m par rate

    Personally, I use these par curves regularly for histories as they are smooth, remove coupon effects, and do not have the discontinuities when bonds roll.