Alternative Data

US Department of Treasury

US Department of Treasury

Updated August 30, 2019: This data source is only supported in backtesting

Introduction

QuantConnect hosts daily treasury yield curve rate data starting from 1998-01-01. The data is sourced directly from the U.S. Department of the Treasury.

Also known as "Constant Maturity Treasury" (CMT) rates, these market yields are 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 each trading day.

Usage

US Treasury Yield Curve Rate data is one of the simplest alternative data sources in QuantConnect. Add the line below and save a reference to your symbol object.

Requesting Data

Select Language:
// Add U.S. Treasury yield curve rates data.
var rates = AddData<USTreasuryYieldCurveRate>("USTYCR").Symbol;
# Add U.S. Treasury yield curve rates data.
self.rates = self.AddData(USTreasuryYieldCurveRate, "USTYCR").Symbol

Accessing Data

Data can be accessed the normal way via the Slice events. Slice events deliver unique articles to your algorithm as they happen. In addition, because this data source can only be added once in your algorithm, we recommend that you save the Symbol relating to this data source when you add it to your algorithm.

All fields contained in USTreasuryYieldCurveRate are decimal, and can provide data for various yield curve rates relating to the length of treasuries. Properties available are: OneMonth, TwoMonth, ThreeMonth, SixMonth, OneYear, TwoYear, ThreeYear, FiveYear, SevenYear, TenYear, TwentyYear, and ThirtyYear.

Historical Data

You can request for historical custom data in your algorithm. To learn more about historical data requests, please visit the Historical Data documentation page. The following example gets U.S. Treasury yield curve rate historical data using the History API.

// Add yield curve rate data
var rates = AddData<USTreasuryYieldCurveRate>("USTYCR").Symbol;
// Request 60 days of history with the USTreasuryYieldCurveRate custom data Symbol.
var history = History<USTreasuryYieldCurveRate>(rates, 60, Resolution.Daily);
# Add yield curve rate data
rates = self.AddData(USTreasuryYieldCurveRate, "USTYCR").Symbol
# Request 60 days of history with the USTreasuryYieldCurveRate custom data Symbol.
history = self.History(USTreasuryYieldCurveRate, rates, 60, Resolution.Daily)

Data Properties

Demonstration

The following demonstration adds yield curve rate data to the algorithm and trades the ticker SPY depending on whether the 2-year rate is greater than the 10-year rate

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.

Pricing

Application ContextSubscription Fee
All ApplicationsFree

You can also see our Tutorials and Videos. You can also get in touch with us via Chat.

Did you find this page helpful?

Contribute to the documentation: