Treasury Yield Curve
Prediction market positions tie up capital that could earn risk-free yield in Treasuries. When rates are high, a trade needs more edge to justify the opportunity cost. Horizon’s treasury module provides a live yield curve feed (via FRED), yield-adjusted Kelly sizing, breakeven edge calculation, and collateral optimization. All math is in Rust.Overview
Yield-Adjusted Kelly
hz.yield_adjusted_kelly() reduces Kelly size by the risk-free rate opportunity cost.Opportunity Cost
hz.opportunity_cost() and hz.breakeven_edge() quantify the hurdle rate for a trade.Live Yield Feed
TreasuryFeed polls FRED for the full yield curve (1M through 30Y).Collateral Optimizer
hz.collateral_optimizer() adjusts capital allocation based on curve steepness.Core Functions
All math runs in Rust. Every output is guarded against NaN/Inf.hz.yield_adjusted_kelly
Standard Kelly fraction minus the annualized opportunity cost of locked capital.| Parameter | Type | Default | Description |
|---|---|---|---|
prob | float | required | Estimated probability of the event |
price | float | required | Current market price |
rfr | float | required | Risk-free rate (annualized decimal) |
duration_days | float | required | Expected holding period in days |
fraction | float | 0.5 | Kelly fraction (0.5 = half-Kelly) |
hz.yield_adjusted_kelly_size
Convert yield-adjusted Kelly fraction to a dollar position size.| Parameter | Type | Default | Description |
|---|---|---|---|
prob | float | required | Estimated probability |
price | float | required | Market price |
rfr | float | required | Risk-free rate |
duration_days | float | required | Holding period in days |
bankroll | float | required | Total bankroll |
fraction | float | 0.5 | Kelly fraction |
max_size | float | inf | Maximum position size cap |
hz.opportunity_cost
Dollar cost of locking capital at the risk-free rate.| Parameter | Type | Description |
|---|---|---|
notional | float | Capital locked in the position |
rfr | float | Risk-free rate (annualized) |
duration_days | float | Holding period in days |
hz.breakeven_edge
Minimum edge required to beat the risk-free rate.| Parameter | Type | Description |
|---|---|---|
rfr | float | Risk-free rate |
duration_days | float | Holding period in days |
Feed
TreasuryFeed
Polls the Federal Reserve Economic Data (FRED) API for yield curve data.| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | FRED_API_KEY env var | FRED API key |
series_ids | list[str] | 9 standard maturities | Treasury series to fetch |
primary_series | str | "DGS10" | Series used as main price |
interval | float | 300.0 | Poll interval in seconds |
price= primary series yield (decimal)bid= short-term yield (DGS3MO)ask= long-term yield (DGS30)volume_24h= curve slope in basis points (long - short)
Pipeline Functions
hz.yield_adjusted_sizer
Size positions using yield-adjusted Kelly each cycle.| Parameter | Type | Default | Description |
|---|---|---|---|
rfr_feed | str | "treasury" | Feed name for the yield data |
duration_days | float | 30.0 | Expected holding period |
fraction | float | 0.5 | Kelly fraction |
bankroll | float | 10000.0 | Total bankroll |
max_size | float | 1000.0 | Maximum position size |
hz.opportunity_cost_filter
Skip trades where edge does not justify the opportunity cost.| Parameter | Type | Default | Description |
|---|---|---|---|
rfr_feed | str | "treasury" | Feed name for yield data |
duration_days | float | 30.0 | Holding period |
min_edge_multiple | float | 2.0 | Required multiple of breakeven edge |
hz.collateral_optimizer
Adjusts capital allocation based on yield curve steepness.| Parameter | Type | Default | Description |
|---|---|---|---|
rfr_feed | str | "treasury" | Feed name |
max_utilization | float | 0.8 | Maximum capital utilization |
Examples
Yield-Aware Market Making
Mathematical Background
Yield-Adjusted Kelly
Yield-Adjusted Kelly
Standard Kelly: f = (p - q) / (b - 1)* where p is probability, q = 1-p, and b is the payout odds.Yield adjustment subtracts the annualized opportunity cost:f_adj = max(0, f - rfr * duration / 365) * fraction*When the risk-free rate is high relative to the edge, the adjusted fraction drops to zero, meaning the trade is not worth taking.
Breakeven Edge
Breakeven Edge
The minimum edge that justifies locking capital:breakeven = rfr * duration / 365At 5% rates and a 30-day hold, the breakeven is about 0.41%. Any edge below that is better invested in T-bills.
Opportunity Cost
Opportunity Cost
Dollar cost of capital deployment:cost = notional * rfr * duration / 365This represents the forgone interest on the locked collateral.