Access and chart US Treasury Curve data
Full documentation can be found at treasury-curves.readthedocs.io
Selecting and plotting data
Using the Developer API found at treasury.gov, one can find yield curves dating back to the 90's.
Access data for a particular date using curves("2022-08-08").
curves will find the nearest valid date (weekday) and returns a pandas dataframes of all curves
available on that date or nearest to it. calling curves() will use the current date.
Optionally specify curves(allow_missing=True) to keep years with missing data.
Alternatively, you can retrieve all data by calling download().
Once you have the data, it is possible to plot out the yield curves with
plot(curves_data, start="2022-01-01", end="2022-05-03", num_years=1).
Specify the number of years, or pick a start and end date to sample from, as the chart would otherwise
become inundated with yield curve data.
Save your data in a spreadsheet using export(curves_data, file_extension="csv") and specify
"csv" or "xlsx" to determine the file type.
Using treasurycurves from the Command Line
Install through pip:
pip install treasury-curves
Once installing, you can run the entrypoint:
treasury --help
Use the module directly:
import treasury
Working inside the repository
python treasury.py --help
usage: treasury.py [-h] [-a] [-s START] [-e END] [-d DATE] [-y YEARS] [-p] [-o OUTPUT]
treasurycurves - query and analyze US Treasury yield data
optional arguments:
-h, --help show this help message and exit
-a, --allowna Allow NaN values
-s START, --start START
Year to start analysis
-e END, --end END Year to end analysis. If equal to start, analyze curves for the year
-d DATE, --date DATE Date in YYYY-MM-DD to analyze
-y YEARS, --years YEARS
Num years before end to analyze
-p, --plot Plot yield curves
-o OUTPUT, --output OUTPUT
File extension to save data (csv or xlsx), leave empty to avoid saving file
Metadata
Release files for treasurycurves 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| treasurycurves-1.0.4.tar.gz | 6.3 kB | Without provenance | Details for treasurycurves-1.0.4.tar.gz |
Release files / treasurycurves-1.0.4.tar.gz
| Download URL | treasurycurves-1.0.4.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42de80f1970509a2f9deb8da50c7fdbf7d4ddfc4e4e60383a7c91fb05e857ab8
|
|
BLAKE2b-256 checksum How to use checksums |
a53421ee6e5c1e1cdca6c271591d6967b5cd43935a36e570c09b0cfb36c0388d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.5
|
Security for treasurycurves 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.