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 *

class USTreasuryDataAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.SetStartDate(2000, 3, 1)
        self.SetEndDate(2021, 6, 1)
        self.SetCash(100000)

        self.spy_symbol = self.AddEquity("SPY", Resolution.Hour).Symbol

        # Requesting data
        self.yield_curve_symbol = self.AddData(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 OnData(self, slice: Slice) -> None:
        if not slice.ContainsKey(self.yield_curve_symbol):
            return
        
        rates = slice[self.yield_curve_symbol]
        
        # Check for None before using the values
        if not (rates.TenYear is not None and rates.TwoYear is not None):
            return
        
        # Only advance if a year has gone by
        if (self.Time - self.last_inversion < timedelta(days=365)):
            return
        
        # if there is a yield curve inversion after not having one for a year, short sell SPY for two years
        if (not self.Portfolio.Invested and rates.TwoYear > rates.TenYear):
            self.Debug(f"{self.Time} - Yield curve inversion! Shorting the market for two years")
            self.SetHoldings(self.spy_symbol, -0.5)
            self.last_inversion = self.Time
            return
        
        # If two years have passed, liquidate our position in SPY
        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: