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.
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.
Requesting Data
To add US Treasury Yield Curve data to your algorithm, call the AddDataadd_data method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.
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
namespace QuantConnect.Algorithm.CSharp.AltData { public class USTreasuryYieldCurveDataAlgorithm : QCAlgorithm { private Symbol _datasetSymbol; public override void Initialize() { SetStartDate(2019, 1, 1); SetEndDate(2020, 6, 1); SetCash(100000); _datasetSymbol = AddData<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.
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}")
public override void OnData(Slice slice) { if (slice.ContainsKey(_datasetSymbol)) { var dataPoint = slice[_datasetSymbol]; Log($"{_datasetSymbol} one month value at {slice.Time}: {dataPoint.OneMonth}"); } }
Historical Data
To get historical US Treasury Yield Curve data, call the Historyhistory method with the dataset Symbol. If there is no data in the period you request, the history result is empty.
# DataFrame history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY) # Dataset objects history_bars = self.history[USTreasuryYieldCurveRate](self.dataset_symbol, 100, Resolution.DAILY)
var history = History<USTreasuryYieldCurveRate>(_datasetSymbol, 100, Resolution.Daily);
For more information about historical data, see History Requests.
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.