US rates curve
All plugins

Plugin libraryInterest rates

Plugin

US rates curve

US Treasury yields from 3 months to 30 years, the real 10 year yield and the fed funds rate, with curve spreads and breakeven inflation, from the Treasury and the New York Fed.

Data sourceNetwork: home.treasury.gov, markets.newyorkfed.orgDesktop onlyv1.0.0

About

US rates move the dollar, gold and equity indices. The slope of the curve (10 years minus 2 years) has turned negative before most US recessions, and many traders read gold against the real yield. This plugin brings the curve into a backtest as daily feeds.

Before a run, it downloads the Treasury's daily par yield curve, real yield curve and bill rates, and the effective federal funds rate from the New York Fed, and writes one feed per series, named after the FRED series of the same data: us_dff (effective federal funds rate), us_dtb3 (13 week bill), us_dgs3mo, us_dgs2, us_dgs10, us_dgs30 (par yields), us_dfii10 (10 year real yield, TIPS), and three computed here: us_t10y2y (10 years minus 2 years), us_t10y3m (10 years minus 3 months) and us_t10yie (10 year breakeven inflation, nominal minus real). All in percent.

The data comes from the publishers themselves, both public and keyless.

Configuration

FieldTypeDefaultDescription
cache_daysRefetch after (days)number1Days before the plugin downloads the current year and the fed funds rate again. Within that time a run reads the cached feeds and needs no network.

Use it in a strategy

pythonbars = ctx.bars(1)
if bars:
    slope = ctx.data("us_t10y2y", bars[-1].ts)  # 10 year minus 2 year yield, in points
    if slope is not None and slope < 0:
        ctx.signal("EXIT")  # stand aside while the curve is inverted

The feeds are refreshed before a run whose strategy reads ctx.data, or when "Fetch external data (news and plugin feeds)" is ticked. A run on the server never fetches.

What it provides

us_dgs3mo, us_dgs2, us_dgs10, us_dgs30FeedTreasury par yields for 3 months, 2, 10 and 30 years in percent, from 1990 (the 30 year has no values from February 2002 to February 2006, when it was not issued).
us_dtb3FeedThe 13 week Treasury bill rate on a bank discount basis in percent, from 2002, as the Treasury publishes it.
us_dfii10FeedThe 10 year real yield (Treasury real yield curve, from TIPS) in percent, from 2003.
us_dffFeedThe effective federal funds rate of the New York Fed in percent, from July 2000.
us_t10y2y, us_t10y3m, us_t10yieFeedComputed on days both legs were published: 10 year minus 2 year yield, 10 year minus 3 month yield, and 10 year breakeven inflation (nominal minus real), in percentage points.

Data source and terms

PublisherU.S. Department of the Treasury, daily Treasury par yield curve, real yield curve and bill rates
TermsRead the terms
API keyNone needed
AttributionSource: U.S. Department of the Treasury
Rate limitOne small file per year and series type, about 90 for the whole history, paced a second apart; once the history is cached a refresh asks for the current year only (3 files).
PublisherFederal Reserve Bank of New York, Effective Federal Funds Rate (EFFR)
TermsRead the terms
API keyNone needed
AttributionThe EFFR is subject to the Terms of Use posted at newyorkfed.org.
Rate limitOne download of about 1.5 MB per refresh; automated access is allowed as long as it does not disrupt the site.

Hosts it may reach: home.treasury.gov, markets.newyorkfed.org

When values are known

The Treasury publishes a day's yields that evening and the New York Fed a day's EFFR at about 9:00 the next business morning. Each value is stored two US business days after the day it describes (federal holidays, Good Friday and one-off closures skipped) and carried forward over weekends and holidays, for at most 10 days. A bar on Monday reads Thursday's yields; Friday's arrive on Tuesday.

Limits

  • Daily closing values only: an intraday strategy sees rates that are two business days old, never the move of the day.
  • The fed funds rate starts in July 2000 (the New York Fed's own history); the bill rate starts in 2002, the real yield in 2003, the par yields in 1990.
  • us_dtb3 is the Treasury's own 13 week bill rate; FRED's DTB3 comes from the Fed's H.15 and can differ by a few basis points on some days.
  • The first fetch needs about 90 small files, and the Treasury sometimes takes 20 seconds per file. A refresh fetches the newest years first for at most 90 seconds and writes what it has; the older years follow on the next runs, so the early history can be missing at first. Finished years stay in the data cache, and the data stays on your machine.
OrionQuant