Finding Bond Price and Yield Data Sources for Python
Summary
The document discusses ways to obtain bond data for Python workflows, distinguishing US Treasury information, broader bond coverage, and yield series. It points to the Treasury's developer API for Treasury data and identifies Bloomberg or Refinitiv as commercial sources for corporate and other bonds. A Bloomberg data service is mentioned as a possible source of limited indicative bond information, with uncertainty about whether it remains available.
For yield-only work, the response suggests retrieving series from FRED through Pandas Datareader and gives examples of Treasury yields across maturities over a date range. This is a practical sourcing overview rather than an evaluation of data quality, coverage, update frequency, or licensing. The discussion does not establish that any one source is suitable for every bond universe or research use.
Key ideas
- US Treasury data can be obtained from the Treasury's developer API.
- Commercial services are cited for corporate bonds and broader bond coverage.
- FRED yield series can be accessed in Python with Pandas Datareader.
- The document does not compare source quality, coverage, or licensing in detail.
Tags
Full text
# Get bonds data in python # Get bonds data in python Anyone knows a way of getting trustworthy bonds data in python? I know that for stock there is yfinance package but it doesnt include bonds. Thx ## Answer by Dimitri Vulis (score 1) https://quant.stackexchange.com/a/79334 For US treasuries, treasurydirect.gov provides a rest API: https://www.treasurydirect.gov/legal-information/developers/web-api-security/ For corporates and everything else, you need either Bloomberg or Reuters / Refinitiv / LSEG. Bloomberg used to be kind enough to provide a free API in FIGI https://bsym.bloomberg.com/api that allowed you to get some indicative data for a limited number of bonds at a time. It may have been retired. ## Answer by NC520 (score 0) https://quant.stackexchange.com/a/79354 If you are interested in just yields, you can use FRED and Pandas Datareader. ``` # Import the libraries import numpy as np import pandas as pd import pandas_datareader as pdr import datetime # Time range start = datetime.date(2000, 1, 1) end = datetime.date.today() # Import the data yields = ['DGS3MO', 'DGS1', 'DGS10'] df_yields = pdr.DataReader(yields, 'fred', start, end) ```
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.