Fetch US Treasury yield curve data.

Forms a query to submit for US Treasury yield curve data, posting this query to the US Treasury web site's data feed service. By default the download includes data yield data for 12 products from January 1, 1990, some of which are NA during this span. The caller can pass parameters to limit the query to a certain year or year and month, but the full download is not especially large. The download data from the service is in XML format. The package's main function transforms that XML data into a numeric data frame with treasury product items (constant maturity yields for 12 kinds of bills, notes, and bonds) as columns and dates as row names. The function returns a list which includes an item for this data frame as well as query-related values for reference and the update date from the service.


R Package ustyc US Treasury Yield Curve

The main function in this R package forms a query to submit for US Treasury yield curve data, posting this query to the US Treasury web site's data feed service. By default the download includes data yield data for 12 products from January 1, 1990, some of which are NA during this span. The caller can pass parameters to limit the query to a certain year or year and month, but the full download is not especially large. The download data from the service is in XML format. This function transforms that data into a numeric data frame with treasury product items (constant maturity yields for 12 kinds of bills, notes, and bonds) as columns and dates as row names. The function returns a list which includes an item for this data frame as well as query-related values for reference and the update date from the service. The data frame can be used as-is or converted easily to a time series format such as xts.

require(ustyc)
yc <- getYieldCurve()
summary(yc)
head(yc$df)

The data frame might be converted to xts and plotted for example with lattice:

require(xts)
require(lattice)

xt = xts(yc$df,order.by=as.Date(rownames(yc$df)))
xyplot.ts(xt,scales=list(y=list(relation="same")),ylab="Yield (%)")

ploti

xyplot.ts(xt,superpose=TRUE,auto.key=list(columns=4),ylab="Yield (%)")

ploti

See the package vignette for examples of these plots.

References:

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ustyc")

1.0.0 by Matt Barry, 12 years ago


https://github.com/mrbcuda/ustyc


Report a bug at https://github.com/mrbcuda/ustyc/issues


Browse source code at https://github.com/cran/ustyc


Authors: Matt Barry <[email protected]>


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports XML, plyr

Suggests xts, lattice


See at CRAN