3 stable releases
| 1.1.0 | May 5, 2026 |
|---|---|
| 1.0.1 | Apr 24, 2026 |
#544 in Finance
79 downloads per month
Used in curvekit-cli
210KB
3.5K
SLoC
curvekit — US Treasury yield curve and SOFR overnight rate for Rust.
Fetches parquet files on demand from GitHub raw, caches them locally with ETag revalidation, and falls back to stale cache on network errors. No API keys. Offline after the first successful fetch of each year file.
Quick start — one-off scripts
use curvekit::Tenor;
#[tokio::main]
async fn main() -> curvekit::Result<()> {
// Free functions — no client setup needed
let curve = curvekit::treasury_curve_for("2020-03-20").await?;
let r = curvekit::treasury_rate_at("2020-03-20", Tenor::Y10).await?;
let today = curvekit::treasury_today().await?;
let sofr = curvekit::sofr_today().await?;
println!("10Y on 2020-03-20: {r:.6}");
println!("Latest Treasury: {}", today.date);
println!("Latest SOFR: {:.4}%", sofr.rate * 100.0);
Ok(())
}
Client pattern — connection pool + cache reuse
use curvekit::{Curvekit, Date, Tenor};
#[tokio::main]
async fn main() -> curvekit::Result<()> {
let client = Curvekit::new(); // infallible, no ?
// Any date form — ISO string, compact u32, tuple, NaiveDate
let curve = client.treasury_curve("2020-03-20").await?;
let curve = client.treasury_curve(20200320u32).await?;
let curve = client.treasury_curve((2020i32, 3u32, 20u32)).await?;
let curve = client.treasury_curve(Date::today_et()).await?;
let r = client.treasury_rate("2020-03-20", Tenor::Y10).await?;
// Blocking from sync code — no async runtime needed
let curve = client.treasury_curve_blocking(20200320u32)?;
Ok(())
}
Major types
Curvekit— stateful client; create once, call many times.Date— ergonomic date wrapper; accepts strings, integers, tuples.YieldCurve— Treasury yield curve for a single date. All rates are continuously compounded.SofrDay— a single SOFR overnight observation.TermStructure— combined Treasury + SOFR view for a date.Tenor— typed constants for standard maturity labels (Tenor::Y10, etc.).Error— unified error type; match on this, never on sub-types.
Environment overrides
| Variable | Effect |
|---|---|
CURVEKIT_BASE_URL |
Replace the GitHub raw origin URL |
CURVEKIT_CACHE_DIR |
Override ~/.cache/curvekit/ |
Modules
client—Curvekitasync client with blocking wrappers.date—Datenewtype for ergonomic date input.tenor—Tenorsemantic type for maturities.curve—YieldCurve,SofrDay,SofrRate,TermStructure.sources::bundled— synchronous reader from local parquet (CLIget).sources::parquet_io— parquet writer (CLIbackfill/append-today).sources::treasury— Treasury CSV fetcher (used by CLI).sources::sofr— NY Fed SOFR CSV fetcher (used by CLI).interpolation— linear interpolation between tenor knots.error— unifiedErrorenum andResultalias.
Dependencies
~20–45MB
~555K SLoC