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")
The values
I16etc are the Bloomberg "Curve Id"s. These can be used in calls to the//blp/instrumentsAPI service, for acurveListRequest, by setting thecurveidfield in the request. This request will return the ticker for the curve ... in this caseYCGT0016 Index. It may be simpler to use the ticker rather than use the instruments lookup.I16is 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
bdsfunctionality, 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
bdsinxbbgto get the bulk data fieldCURVE_TENOR_RATES, and overriding theCURVE_DATEfield.eg:
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)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.