libitofin 0.39.0

A ground-up Rust port of QuantLib: quantitative-finance primitives for pricing, risk, and numerical methods.
Documentation
pub(super) struct NativeCase {
    pub name: &'static str,
    pub kind: &'static str,
    pub counts: [usize; 6],
    pub market: [f64; 6],
    pub tolerance: f64,
    pub short: bool,
    pub expected: [f64; 4],
    pub samples: usize,
    pub grid: [usize; 2],
}
pub(super) const CASES: &[NativeCase] = &[
    NativeCase {
        name: "literature_curve",
        kind: "variance_curve",
        counts: [90, 0, 250, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [
            0.040090029561945205,
            4.446321129440496,
            1.2154940192213251e-17,
            6.003002373444548e-13,
        ],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "flat_base",
        kind: "constant",
        counts: [90, 0, 250, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [
            0.03999999999999932,
            -3.3583968326640795e-11,
            2.2139355350102707e-17,
            1.0934040037345428e-12,
        ],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "short",
        kind: "constant",
        counts: [90, 0, 250, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.05, 50000.0],
        tolerance: 0.0,
        short: true,
        expected: [
            0.03999999999999932,
            493.87346038038316,
            2.2139355350102707e-17,
            -1.0934040037345428e-12,
        ],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "zero_volatility",
        kind: "constant",
        counts: [90, 0, 250, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.0, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [0.0, -1975.493841521398, 0.0, 0.0],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "negative_rate_dividend",
        kind: "constant",
        counts: [90, 0, 250, 1023, 0, 42],
        market: [100.0, -0.01, 0.02, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [
            0.03999999999999932,
            -3.4084520621788376e-11,
            2.2139355350102707e-17,
            1.1097006449852054e-12,
        ],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "explicit_steps",
        kind: "constant",
        counts: [3, 7, 0, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [
            0.03999999999999932,
            -3.398661015873493e-11,
            2.148819783980557e-17,
            1.0739684443931249e-12,
        ],
        samples: 1023,
        grid: [7, 6],
    },
    NativeCase {
        name: "minimum_grid",
        kind: "constant",
        counts: [3, 0, 1, 2, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [0.04000000000000001, 3.4680214447688706e-13, 0.0, 0.0],
        samples: 2,
        grid: [1, 1],
    },
    NativeCase {
        name: "tolerance",
        kind: "constant",
        counts: [90, 0, 250, 0, 2046, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 1e-08,
        short: false,
        expected: [
            0.03999999999999932,
            -3.3583968326640795e-11,
            2.2139355350102707e-17,
            1.0934040037345428e-12,
        ],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "curve_tolerance",
        kind: "variance_curve",
        counts: [90, 0, 250, 0, 2046, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 1e-08,
        short: false,
        expected: [
            0.040090029561945205,
            4.446321129440496,
            1.2154940192213251e-17,
            6.003002373444548e-13,
        ],
        samples: 1023,
        grid: [61, 61],
    },
    NativeCase {
        name: "external_fixed",
        kind: "external_local_vol",
        counts: [90, 7, 0, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: false,
        expected: [
            0.04005975191947983,
            2.950988723787132,
            1.7877206434025007e-05,
            0.8829077803505778,
        ],
        samples: 1023,
        grid: [7, 7],
    },
    NativeCase {
        name: "external_short",
        kind: "external_local_vol",
        counts: [90, 7, 0, 1023, 0, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 0.0,
        short: true,
        expected: [
            0.04005975191947983,
            -2.950988723787132,
            1.7877206434025007e-05,
            -0.8829077803505778,
        ],
        samples: 1023,
        grid: [7, 7],
    },
    NativeCase {
        name: "external_tolerance",
        kind: "external_local_vol",
        counts: [90, 7, 0, 0, 16368, 42],
        market: [100.0, 0.05, 0.0, 0.2, 0.04, 50000.0],
        tolerance: 1e-05,
        short: false,
        expected: [
            0.04003077786989111,
            1.5200373106256817,
            9.419172378344547e-06,
            0.46518792564120276,
        ],
        samples: 3638,
        grid: [7, 7],
    },
];