import horizon as hz
# Historical data (you'd fetch these from your data source)
fed_prices = [0.55, 0.56, 0.57, 0.58, 0.57, 0.59, 0.60, 0.61, 0.62]
tlt_prices = [95.0, 95.5, 96.0, 96.5, 96.2, 97.0, 97.5, 98.0, 98.5]
# One-shot report
report = hz.compute_hedge_report(fed_prices, tlt_prices, window=8)
print(f"Hedge ratio: {report['hedge_ratio']:.4f}")
print(f"Effectiveness: {report['hedge_effectiveness']:.4f}")
print(f"Tracking error: {report['sensitivities']['tracking_error']:.4f}")
# Scenario analysis
scenarios = hz.run_scenario(
spot_position=1000, # 1000 contracts on Polymarket
spot_price=0.60, # current YES price
hedge_position=-50, # short 50 shares TLT
hedge_price=96.0, # current TLT price
spot_moves=[-0.20, -0.10, -0.05, 0.0, 0.05, 0.10, 0.20],
correlation=0.75,
)
print("\nScenario Analysis:")
for s in scenarios:
print(f" Spot {s['spot_move_pct']:+.0%}: "
f"Portfolio ${s['portfolio_pnl']:+.2f}, "
f"Unhedged ${s['unhedged_pnl']:+.2f}, "
f"Benefit ${s['hedge_benefit']:+.2f}")