About US Treasury Yield Curve

The US Treasury Yield Curve datasets tracks the yield curve rate from the US Department of the Treasury. The data starts in January 1990 and is delivered on a daily frequency. This dataset is calculated from composites of indicative, bid-side market quotations (not actual transactions) obtained by the Federal Reserve Bank of New York at or near 3:30 PM Eastern Time (ET) each trading day.


About Treasury Department

The Treasury Department is the executive agency responsible for promoting economic prosperity and ensuring the financial security of the United States. The Department is responsible for a wide range of activities such as advising the President on economic and financial issues, encouraging sustainable economic growth, and fostering improved governance in financial institutions. The Department of the Treasury operates and maintains systems that are critical to the nation's financial infrastructure, such as the production of coin and currency, the disbursement of payments to the American public, revenue collection, and the borrowing of funds necessary to run the federal government.

Add US Treasury Yield Curve

Add Dataset Create Free QuantConnect Account

About QuantConnect

QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.


Algorithm Example

from AlgorithmImports import *
from QuantConnect.DataSource import *

class USTreasuryDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2000, 3, 1)
        self.set_end_date(2021, 6, 1)
        self.set_cash(100000)

        # Request SPY as the market representative for trading
        self.spy_symbol = self.add_equity("SPY", Resolution.HOUR).symbol

        # Requesting yield curve data for trade signal generation (inversion)
        self.yield_curve_symbol = self.add_data(USTreasuryYieldCurveRate, "USTYCR").symbol

        # Historical data
        history = self.history(USTreasuryYieldCurveRate, self.yield_curve_symbol, 60, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request")
        
        self.last_inversion = datetime.min

    def on_data(self, slice: Slice) -> None:
        # Trade only based on updated yield curve data
        if not slice.contains_key(self.yield_curve_symbol):
            return
        rates = slice[self.yield_curve_symbol]
        
        # We need the 10-year bond yield rate and 2-year bond yield rate for trade signal generation
        if not (rates.ten_year is not None and rates.two_year is not None):
            return
        
        # Only advance if a year has gone by, since the inversion signal indicates longer term market regime that will not revert in a short period
        if (self.time - self.last_inversion < timedelta(days=365)):
            return

        # Normally, 10y yield should be greater than 2y yield due to default risk accumulation
        # But if an inversion occurs, it means the market expects a recession in short term such that the near-expiry bond is more likely to default
        # if there is a yield curve inversion after not having one for a year, short sell SPY for two years for the expected down market
        if (not self.portfolio.invested and rates.two_year > rates.ten_year):
            self.debug(f"{self.time} - Yield curve inversion! Shorting the market for two years")
            self.set_holdings(self.spy_symbol, -0.5)
            self.last_inversion = self.time
            return
        
        # If two years have passed, liquidate our position in SPY assuming the market starts resilience
        if (self.time - self.last_inversion >= timedelta(days=365 * 2)):
            self.liquidate(self.spy_symbol)

Example Applications

The US Treasury Yield Curve dataset enables you to monitor the yields of bonds with numerous maturities in your strategies. Examples include the following strategies: