Description Usage Arguments Value Author(s) References Examples
Downloads US Treasury yield curve data from the US Treasury web site. This is a fix and heavy re-write (using regular expressions instead of XML) of R CRAN package ustyc function getYieldCurve. What is different is the following: (1) This function works on all of the treasury rate data found at https://home.treasury.gov/policy-issues/financing-the-government/interest-rate-statistics: the R CRAN package ustyc function getYieldCurve only works on "Daily Treasury Yield Curve Rates". (2) The function defaults are different than in the R CRAN package ustyc function getYieldCurve. (3) Instead of using functions from the R CRAN package "XML", because of the "need for speed", the R package "base" PCRE2 regular expression functions are used. (4) Interprets (with limits) from the (rich datatype) XML namespaces of http://schemas.microsoft.com/ado/2007/08/dataservices/metadata and http://schemas.microsoft.com/ado/2007/08/dataservices) into R.
1 2 3 4 5 6 | yieldCurve(
base = "http://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData",
year,
month,
IndexName
)
|
base |
String. Required. Default is the URL: See args(yieldCurve). The base URL for the data service, defaulting to http://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData. |
year |
String or Numeric. Default is none. The desired year number or NULL for all years. If none then the default is the current year. |
month |
String or Numeric. Default is none. The desired month number in the format (01(or 1) through 12) of Jan-Dec, or NULL for all months. If none then the default is the current month. |
IndexName |
String. Default is none. The column IndexName to be used in the URL. This is specific and in very different per each URL. See the examples. If none, then default is "NEW_DATE". |
xts object
Andre Mikulec (re-write)
Matt Barry (original)
GetYieldCurve - XML content does not seem to be XML #1 https://github.com/mrbcuda/ustyc/issues/1
Unknown IO error #2 https://github.com/mrbcuda/ustyc/issues/2
Interest Rate Statistics https://home.treasury.gov/policy-issues/financing-the-government/interest-rate-statistics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ## Not run:
# (1) Daily Treasury Yield Curve Rates
# https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield
# https://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData?$filter=month(NEW_DATE)%20eq%2012%20and%20year(NEW_DATE)%20eq%202020"
result <- yieldCurve()
# if the current date is in DEC 2020 (then the next example is the same)
result <- yieldCurve(year = 2020, month = 12)
result
# (1.5) Everything now and in history of Daily Treasury Yield Curve Rates
# https://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData
# result <- yieldCurve(year = NULL, month = NULL)
result
# (2) Daily Treasury Bill Rates Data
# https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=billrates
# https://data.treasury.gov/feed.svc/DailyTreasuryBillRateData?$filter=month(INDEX_DATE)%20eq%2012%20and%20year(INDEX_DATE)%20eq%202020
result <- yieldCurve("https://data.treasury.gov/feed.svc/DailyTreasuryBillRateData",
IndexName = "INDEX_DATE")
result
# (3) Daily Treasury Long Term Rate Data
# https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=longtermrate
# http://data.treasury.gov/feed.svc/DailyTreasuryLongTermRateData?$filter=month(QUOTE_DATE)%20eq%2012%20and%20year(QUOTE_DATE)%20eq%202020"
result <- yieldCurve("http://data.treasury.gov/feed.svc/DailyTreasuryLongTermRateData",
IndexName = "QUOTE_DATE")
result
# (4) Daily Treasury Real Yield Curve Rates
# https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=realyield
# https://data.treasury.gov/feed.svc/DailyTreasuryRealYieldCurveRateData?$filter=month(NEW_DATE)%20eq%2012%20and%20year(NEW_DATE)%20eq%202020"
result <- yieldCurve("https://data.treasury.gov/feed.svc/DailyTreasuryRealYieldCurveRateData",
IndexName = "NEW_DATE")
result
# (5) Daily Treasury Real Long-Term Rates
#
# Since 2000
# Long Term Real Rate Average: The Long-Term Real Rate Average is the
# unweighted average of bid real yields on all outstanding TIPS
# with remaing maturities of more than 10 years and is intended as a
# proxy for long-term real rates.
# https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=reallongtermrate
# https://data.treasury.gov/feed.svc/DailyTreasuryRealLongTermRateAverageData?$filter=month(QUOTE_DATE)%20eq%2012%20and%20year(QUOTE_DATE)%20eq%202020"
result <- yieldCurve("https://data.treasury.gov/feed.svc/DailyTreasuryRealLongTermRateAverageData",
IndexName = "QUOTE_DATE")
result
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.