Skip to content

v0.17.3 — Black-76 + Garman-Kohlhagen Greeks

Latest

Choose a tag to compare

@joaquinbejar joaquinbejar released this 27 Apr 11:46
b46c958

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_b76
  • pub trait Black76Greeks mirroring the Black76 pricing trait
  • calculate_d_values_black_76 promoted pub(crate)pub
  • Formulas follow Hull (10th ed., Ch. 18). Theta keeps the + r·F·e^(-rT)·N(d1) term; rho uses the -T · price identity (the only place r appears in Black-76 is e^(-rT)).
  • 21 tests: delta range / parity (Δ_call − Δ_put = e^(-rT)), Γ > 0, ν > 0, Γ_call = Γ_put, ν_call = ν_put, ρ = -T · price / 100, BSM cross-check under S = 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_gk
  • pub trait GarmanKohlhagenGreeks mirroring the GarmanKohlhagen pricing trait
  • FX field mapping: risk_free_rate → r_d, dividend_yield → r_f, underlying_price → S.
  • Carry-adjusted b = r_d − r_f in d1/d2. Standalone implementation — does not delegate to BSM Greeks because those compute d1 from risk_free_rate only and then multiply by e^(-qT), mismatching d-values and discount factor when dividend_yield ≠ 0. Pricing kernels are unaffected (they include −q in 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 at q = 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_76 visibility 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-Priced and FX / Currency subgraphs added to the model-selection mermaid.
  • Garman-Kohlhagen module: review fixes (T=0 short-circuit + checked d_add in theta), escaped-Markdown link cleanup.