Expand description
§Live BSM state — engineering for streaming underliers
Holds one European contract’s BSM inputs and exposes set_* mutators so your
market-data loop does not rebuild parameter graphs on every tick.
§Trading perspective
On each underlier print, risk wants fresh Δ/Γ for every open option. On each option quote, vol traders update IV from mid and recompute vega/theta. This type is the per-contract scratchpad for that loop — not the book itself.
§Engineering perspective
HashMap<OptionKey, BsmState> // in YOUR engine
on_underlier_tick(s):
for state in map.values_mut() {
state.set_spot(s)?;
let g = state.greeks()?; // or throttle / rayon
aggregate_risk(g);
}
on_option_quote(key, mid):
map[key].set_vol_from_price(mid)?;Combine with TA on the same symbol:
on_1m_bar → equity.ta.push(...)
on_spot → options[*].set_spot(s)Both pipelines are sync math. Concurrency is optional and outside this crate
(rayon over keys, async tasks that only deliver messages).
§Example
use finance_solution::derivatives::{BsmParams, BsmState, OptionType};
let p = BsmParams::atm_one_year(100.0, 0.05, 0.20);
let mut opt = BsmState::new(p, OptionType::Call).unwrap();
// underlier tick:
opt.set_spot(101.5).unwrap();
let g = opt.greeks().unwrap();
assert!(g.delta > 0.0);
// mark IV from mid:
opt.set_vol_from_price(11.0).unwrap();
assert!(opt.params().vol > 0.0);Structs§
- BsmState
- Mutable European option under BSM (spot / vol / time / strike updates).