v2.0.0-beta.3
Third beta of stochastic-rs v2 — pricing-engine architecture, full DistributionExt
coverage, and the workspace publishing pipeline. 15 commits since beta.2.
Highlights
Pricing-engine architecture (PR #24)
New Instrument / PricingEngine trait split decouples payoffs from
the (model, market, method) triple that prices them. Engines hold
reactive Handles to spot, vol, rates, and dividends, so prices follow
market updates automatically.
let opt = EuropeanOption::new_tau(100.0, OptionType::Call, 1.0);
let engine = AnalyticBSEngine::new(spot, vol, rate, div);
let r = engine.calculate(&opt);
println!("NPV = {}, Δ = {}", r.npv(), r.greeks().unwrap().delta);
// Swap the engine without touching the instrument:
let heston = AnalyticHestonEngine::new(spot, params, rate, div);
let r2 = heston.calculate(&opt);New components in stochastic-rs-quant:
- Instruments —
EuropeanOption,DigitalOption(cash-or-nothing,
asset-or-nothing),TotalReturnSwap(TRS) with full continuous-time
risk-neutral derivation. - Engines —
AnalyticBSEngine,AnalyticHestonEnginewired through
BSMPricer/CashOrNothingPricer/AssetOrNothingPricer. - Market plumbing —
MarketObserver(edge-triggered stale flag) and
Cached<T>(lazy recompute on market notify) for derived market quantities. - FX module —
FxDeltaConvention(Spot / Forward / SpotPremiumAdjusted /
ForwardPremiumAdjusted), ATM straddle conventions, FX smile construction
(Reiswich-Wystup / Castagna / Clark). - Variance swap — pricing extended (~+300 lines).
Distributions — full DistributionExt coverage, statrs removed
16 distributions now ship real closed-form DistributionExt impls
(characteristic function, pdf, cdf, moments) instead of the 0.0 stubs from
beta.2:
alpha_stable, beta, binomial, cauchy, chi_square, exp, gamma, geometric,
hypergeometric, inverse_gauss, normal_inverse_gauss, pareto, poisson,
studentt, uniform, weibull
New stochastic-rs-distributions::special module ships self-contained
ln_gamma (Lanczos), ndtri (Acklam), norm_cdf, etc. — no statrs,
no external dependency on distribution / special-function crates.
statrs has been removed from the workspace entirely.
SeedExt takes &self
SeedExt::rng and SeedExt::derive now take &self (state moved to atomic
interior mutability) so ProcessExt::sample(&self) can advance the seed
without an outer &mut. Deterministic and Unseeded both updated.
Workspace publishing
New publish.sh publishes all sub-crates topologically, then the umbrella.
Skips already-published versions so it's safe to re-run after a partial
failure. stochastic-rs-py is excluded (placeholder cdylib).
./publish.sh # publish for real
./publish.sh --dry-run # validate without uploading
./publish.sh --allow-dirty # publish with uncommitted changesFixes
- BSM implied volatility (
taubug) —implied_volatilitywas passing
tau_in_daysto the IV solver and ignoring discounting. Now passes
tau_in_years, the forwardS·exp(b·τ), and the undiscounted price.
Round-trip tested across strikes, maturities, and sigmas. The buggy
TimeExt::calculate_tau_in_dayshas been removed. - Feature propagation —
cuda-native,accelerate,gpu,metal,
gpu-cuda,gpu-wgpunow correctly propagate from the umbrella to
stochastic-rs-stochastic. docs.rsbuild — replacedall-features = true(failed on docs.rs
due to native GPU SDKs / system OpenBLAS / pyo3 link) with an explicit
feature list (openblas,ai,yahoo).maturinbuild —pyproject.tomlnow points at
stochastic-rs-py/Cargo.tomlsomaturin build/developwork from
the workspace root.- GBM lognormal negative values — diffusion path could produce
negatives under specific parameter combinations; fixed in
stochastic-rs-stochastic::diffusion::gbm. - Greeks consistency —
GreeksExt::greeks()overridden for
GbmMalliavinGreeksandHestonMalliavinGreeksto return mutually
consistent estimators from a single shared MC simulation instead of four
independent ones.
Breaking changes
Calibrator::calibratenow returnsResult<Self::Output, Self::Error>
instead ofSelf::Output. The convention in this crate is
Error = anyhow::Error. Successful return does not imply
convergence — inspectCalibrationResult::convergedon theOkvalue.CalibrationResultgainediterations(),message(), andmax_error()
defaults. Existing impls compile unchanged; override where the data is
available.SeedExt::rngandSeedExt::derivetake&selfinstead of&mut self.
Call sites that bound amutseed local can drop themut.TimeExt::calculate_tau_in_daysremoved (it was the source of the BSM
IV bug). Usecalculate_tau_in_years/tau_or_from_dates.
Crates published
All sub-crates are now on crates.io at 2.0.0-beta.3:
stochastic-rs-core, stochastic-rs-distributions, stochastic-rs-stochastic,
stochastic-rs-copulas, stochastic-rs-stats, stochastic-rs-quant,
stochastic-rs-ai, stochastic-rs-viz, and the umbrella stochastic-rs.
Full Changelog: v2.0.0-beta.2...v2.0.0-beta.3
What's Changed
Full Changelog: v2.0.0-beta.2...v2.0.0-beta.3