Skip to main content

solver/models/
mod.rs

1#![doc = include_str!("MODELS.md")]
2
3pub mod control;
4
5/// Terminal condition applied to the value function at expiry.
6#[derive(Clone, Copy, Debug, PartialEq)]
7pub enum TerminalCondition {
8    /// V(T, q, v) = 0 for all states.  The classic default.
9    Zero,
10    /// V(T, q, v) = -|q| * base_spread.  The agent crosses the spread to flatten
11    /// its book with market orders, paying one half-spread per unit of inventory.
12    LiquidationCost,
13}
14
15/// Abramowitz & Stegun 26.2.17 rational approximation for the standard normal CDF.
16/// Absolute error < 7.5e-8.  Used by coupled BSDE models for Bernoulli fill simulation.
17pub(crate) fn normal_cdf(x: f64) -> f64 {
18    const P: f64 = 0.2316419;
19    const B: [f64; 5] = [
20        0.319381530,
21        -0.356563782,
22        1.781477937,
23        -1.821255978,
24        1.330274429,
25    ];
26    let t = 1.0 / (1.0 + P * x.abs());
27    let poly = t * (B[0] + t * (B[1] + t * (B[2] + t * (B[3] + t * B[4]))));
28    let phi = (-x * x / 2.0).exp() / (2.0 * std::f64::consts::PI).sqrt();
29    let cdf = 1.0 - phi * poly;
30    if x >= 0.0 { cdf } else { 1.0 - cdf }
31}
32
33pub mod american_put;
34pub mod avellaneda;
35pub mod avellaneda_drift;
36pub mod avellaneda_hawkes;
37pub mod avellaneda_impact;
38pub mod avellaneda_lot_size;
39pub mod bilateral_hawkes;
40pub mod bilateral_hawkes_order_flow_imbalance;
41pub mod heston;
42pub mod heston_hawkes;
43pub mod kelly_hjb;
44pub mod lq_regulator;
45pub mod market_making;
46pub mod merton;
47pub mod merton_jump;
48pub mod merton_jump_lognormal;
49pub mod stationary_avellaneda;
50pub mod stationary_lq;