Treasury Rates
Retrieve daily, weekly, monthly, quarterly or yearly US Treasury yields for four maturities, 13 weeks, 5 years, 10 years and 30 years, from FinancialModelingPrep or, as a free alternative, YahooFinance. With the default divide_ohlc_by of 100 the yields are returned as decimals (0.042 is 4.2%).
A week, month, quarter or year holds the first (Open), highest, lowest and last (Close) yield of the period. The risk free rate the Performance, Risk and Models modules use for such a period is instead the average of the daily yields within it, which approximates what a holder earned over the period rather than where the yield happened to close at its end.
Also known as: US Treasury yields, yield curve, treasury rates.
Treasury Rates in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_treasury_data as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2025-01-01",
end_date="2025-12-31",
)
toolkit.get_treasury_data(period="monthly")["Close"]
Or, after setting up the Finance Toolkit MCP, ask:
What were the monthly closing yields of the 13-week, 5-year, 10-year and 30-year US Treasuries in each month of 2025?
Which returns:
| Date | 13 Week | 5 Year | 10 Year | 30 Year |
|---|---|---|---|---|
| 2025-01 | 0.0419 | 0.0436 | 0.0457 | 0.0481 |
| 2025-02 | 0.0419 | 0.0403 | 0.0423 | 0.0452 |
| 2025-03 | 0.0419 | 0.0398 | 0.0425 | 0.0461 |
| 2025-04 | 0.0419 | 0.0375 | 0.0418 | 0.0468 |
| 2025-05 | 0.0423 | 0.0398 | 0.0442 | 0.0493 |
| 2025-06 | 0.0419 | 0.038 | 0.0423 | 0.0478 |
| 2025-07 | 0.0424 | 0.0396 | 0.0436 | 0.0489 |
| 2025-08 | 0.0404 | 0.037 | 0.0423 | 0.0492 |
| 2025-09 | 0.0385 | 0.0373 | 0.0415 | 0.0473 |
| 2025-10 | 0.0372 | 0.0372 | 0.041 | 0.0467 |
| 2025-11 | 0.037 | 0.036 | 0.0402 | 0.0466 |
| 2025-12 | 0.0355 | 0.0372 | 0.0416 | 0.0484 |
Parameters
get_treasury_data accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The interval at which the treasury data should be returned - daily, weekly, monthly, quarterly, or yearly. Defaults to “daily”. | "weekly" |
fill_nan | bool | Defines whether to forward fill NaN values. This defaults to True to prevent holes in the dataset. This is especially relevant for technical indicators. | False |
risk_free_rate | str | None | One maturity to return (‘13w’, ‘5y’, ‘10y’ or ‘30y’). Defaults to None, which returns all four. The Toolkit’s own risk free rate stays the maturity set on the Toolkit either way. | "5y" |
divide_ohlc_by | int | float | None | A value to divide the yields by. Treasury yields are published in percent, so this defaults to 100 to return decimals. | 1 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding set on the Toolkit. | 2 |
show_errors | bool | Whether to report retrieval errors. Defaults to False. | True |
enforce_source | str | None | Forces this specific call to use a given source, either “FinancialModelingPrep” or “YahooFinance”. This takes precedence over the source set on the Toolkit itself. Defaults to None, which falls back to the Toolkit’s own enforce_source. | "YahooFinance" |