Closed-form Greeks for the two pricing models added in v0.17.2 (Black-76 and Garman–Kohlhagen). Pricing kernels shipped first; this release closes the analytics surface for futures/forwards and FX options.
Decimal end-to-end via d_mul/d_sub/d_div. tracing::instrument on every entry point. Quantity scales linearly; Side::Short flips delta only — gamma/vega/theta/rho stay sign-agnostic, matching the BSM module convention. Vega ÷ 100 (per 1 % vol), theta ÷ 365 (per calendar day), rho ÷ 100 (per 1 % rate). Only OptionType::European accepted — American / Bermuda / exotic return GreeksError::Pricing(UnsupportedOptionType).
Added
Black-76 Greeks (PR #402, closes #400) — src/greeks/black_76.rs:
delta_b76,gamma_b76,vega_b76,theta_b76,rho_b76pub trait Black76Greeksmirroring theBlack76pricing traitcalculate_d_values_black_76promotedpub(crate)→pub- Formulas follow Hull (10th ed., Ch. 18). Theta keeps the
+ r·F·e^(-rT)·N(d1)term; rho uses the-T · priceidentity (the only placerappears in Black-76 ise^(-rT)). - 21 tests: delta range / parity (
Δ_call − Δ_put = e^(-rT)),Γ > 0,ν > 0,Γ_call = Γ_put,ν_call = ν_put,ρ = -T · price / 100, BSM cross-check underS = F·e^(-rT),q = 0(1e-9), Hull ATM reference (Δ ≈ 0.5132), error paths. examples/examples_pricing/src/bin/black_76_greeks.rs— 6-month crude-oil futures walkthrough.
Garman–Kohlhagen Greeks (PR #403, closes #401) — src/greeks/garman_kohlhagen.rs:
delta_gk,gamma_gk,vega_gk,theta_gk,rho_domestic_gk,rho_foreign_gkpub trait GarmanKohlhagenGreeksmirroring theGarmanKohlhagenpricing trait- FX field mapping:
risk_free_rate → r_d,dividend_yield → r_f,underlying_price → S. - Carry-adjusted
b = r_d − r_find1/d2. Standalone implementation — does not delegate to BSM Greeks because those computed1fromrisk_free_rateonly and then multiply bye^(-qT), mismatching d-values and discount factor whendividend_yield ≠ 0. Pricing kernels are unaffected (they include−qin the drift). Fixing BSM Greeks tracked separately. - 18 tests: delta range
(0, e^(-r_f·T))/(-e^(-r_f·T), 0), spot delta-parityΔ_call − Δ_put = e^(-r_f·T),Γ > 0,ν > 0,Γ_call = Γ_put,ν_call = ν_put, rho signs (long call: +ρ_d, -ρ_f; long put: -ρ_d, +ρ_f), bit-exact BSM equivalence atq = 0, theta vs 1-day numerical bump, Wystup-style FX reference (S=0.98, K=1.00, r_d=5 %, r_f=4 %, T=4/12, σ=10 %) → Δ ≈ 0.3909. examples/examples_pricing/src/bin/garman_kohlhagen_greeks.rs— 6-month EUR/USD walkthrough.
Changed
greeks/utils.rs:calculate_d_values_black_76visibility bumped.greeks/mod.rs: registers the two new modules.lib.rs: doc index updated.
Docs
- README bumped to v0.17.3 with both pricing modules listed;
Forward-PricedandFX / Currencysubgraphs added to the model-selection mermaid. - Garman-Kohlhagen module: review fixes (T=0 short-circuit + checked
d_addin theta), escaped-Markdown link cleanup.