book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

Treasury Department

US Treasury Yield Curve

Introduction

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.

For more information about the US Treasury Yield Curve dataset, including CLI commands and pricing, see the dataset listing.

About the Provider

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.

Getting Started

The following snippet demonstrates how to request data from the US Treasury Yield Curve dataset:

Select Language:
self.dataset_symbol = self.add_data(USTreasuryYieldCurveRate, "USTYCR").symbol

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 1990
Coverage1 Dataset
Data DensitySparse
ResolutionDaily
TimezoneNew York

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:

  • Short selling SPY when the yield curve inverts
  • Buying short-term Treasuries and short selling long-term Treasuries when the yield curve becomes steeper (aka curve steepener trade)

For more example algorithms, see Examples.

Data Point Attributes

The US Treasury Yield Curve dataset provides USTreasuryYieldCurveRate objects, which have the following attributes:

Requesting Data

To add US Treasury Yield Curve data to your algorithm, call the add_data method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.

Select Language:
class QuiverCongressDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2020, 6, 1)
        self.set_cash(100000)

        self.dataset_symbol = self.add_data(USTreasuryYieldCurveRate, "USTYCR").symbol

Accessing Data

To get the current US Treasury Yield Curve data, index the current Slice with the dataset Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your dataset at every time step. To avoid issues, check if the Slice contains the data you want before you index it.

Select Language:
def on_data(self, slice: Slice) -> None:
    if slice.contains_key(self.dataset_symbol):
        data_point = slice[self.dataset_symbol]
        self.log(f"{self.dataset_symbol} one month value at {slice.time}: {data_point.one_month}")

Historical Data

To get historical US Treasury Yield Curve data, call the history method with the dataset Symbol. If there is no data in the period you request, the history result is empty.

Select Language:
# DataFrame
history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[USTreasuryYieldCurveRate](self.dataset_symbol, 100, Resolution.DAILY)

For more information about historical data, see History Requests.

Remove Subscriptions

To remove your subscription to US Treasury Yield Curve data, call the remove_security method.

Select Language:
self.remove_security(self.dataset_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:

  • Short selling SPY when the yield curve inverts
  • Buying short-term Treasuries and short selling long-term Treasuries when the yield curve becomes steeper (aka curve steepener trade)

For more example algorithms, see Examples.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: