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)

        self.spy_symbol = self.add_equity("SPY", Resolution.HOUR).symbol

        # Requesting data
        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:
        if not slice.contains_key(self.yield_curve_symbol):
            return
        
        rates = slice[self.yield_curve_symbol]
        
        # Check for null before using the values
        if not (rates.ten_year is not None and rates.two_year 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.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
        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: