Skip to content

v2.0.0-beta.3

Choose a tag to compare

@dancixx dancixx released this 29 Apr 21:43
· 187 commits to main since this release
d3d14bb

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:

  • InstrumentsEuropeanOption, DigitalOption (cash-or-nothing,
    asset-or-nothing), TotalReturnSwap (TRS) with full continuous-time
    risk-neutral derivation.
  • EnginesAnalyticBSEngine, AnalyticHestonEngine wired through
    BSMPricer / CashOrNothingPricer / AssetOrNothingPricer.
  • Market plumbingMarketObserver (edge-triggered stale flag) and
    Cached<T> (lazy recompute on market notify) for derived market quantities.
  • FX moduleFxDeltaConvention (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 changes

Fixes

  • BSM implied volatility (tau bug)implied_volatility was passing
    tau_in_days to the IV solver and ignoring discounting. Now passes
    tau_in_years, the forward S·exp(b·τ), and the undiscounted price.
    Round-trip tested across strikes, maturities, and sigmas. The buggy
    TimeExt::calculate_tau_in_days has been removed.
  • Feature propagationcuda-native, accelerate, gpu, metal,
    gpu-cuda, gpu-wgpu now correctly propagate from the umbrella to
    stochastic-rs-stochastic.
  • docs.rs build — replaced all-features = true (failed on docs.rs
    due to native GPU SDKs / system OpenBLAS / pyo3 link) with an explicit
    feature list (openblas, ai, yahoo).
  • maturin buildpyproject.toml now points at
    stochastic-rs-py/Cargo.toml so maturin build / develop work 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 consistencyGreeksExt::greeks() overridden for
    GbmMalliavinGreeks and HestonMalliavinGreeks to return mutually
    consistent estimators from a single shared MC simulation instead of four
    independent ones.

Breaking changes

  • Calibrator::calibrate now returns Result<Self::Output, Self::Error>
    instead of Self::Output. The convention in this crate is
    Error = anyhow::Error. Successful return does not imply
    convergence — inspect CalibrationResult::converged on the Ok value.
  • CalibrationResult gained iterations(), message(), and max_error()
    defaults. Existing impls compile unchanged; override where the data is
    available.
  • SeedExt::rng and SeedExt::derive take &self instead of &mut self.
    Call sites that bound a mut seed local can drop the mut.
  • TimeExt::calculate_tau_in_days removed (it was the source of the BSM
    IV bug). Use calculate_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