libitofin 0.51.0

A ground-up Rust port of QuantLib: quantitative-finance primitives for pricing, risk, and numerical methods.
Documentation
use crate::position::Position;

pub(super) struct NativeCase {
    pub(super) name: &'static str,
    pub(super) spot: f64,
    pub(super) rate: f64,
    pub(super) dividend: f64,
    pub(super) vol: f64,
    pub(super) strike: f64,
    pub(super) notional: f64,
    pub(super) days: i32,
    pub(super) position: Position,
    pub(super) dk: f64,
    pub(super) calls: &'static [f64],
    pub(super) puts: &'static [f64],
    pub(super) variance: f64,
    pub(super) npv: f64,
}

pub(super) const CASES: &[NativeCase] = &[
    NativeCase {
        name: "literature_smile",
        spot: 100.0,
        rate: 0.05,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 90,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 105.0, 110.0, 115.0, 120.0, 125.0, 130.0, 135.0],
        puts: &[
            50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0, 100.0,
        ],
        variance: 0.041888574232405745,
        npv: 93.27166913433874,
    },
    NativeCase {
        name: "flat_base",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04155755811455545,
        npv: 75.57626577562856,
    },
    NativeCase {
        name: "short",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Short,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04155755811455545,
        npv: -75.57626577562856,
    },
    NativeCase {
        name: "strike_bump",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.06,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04155755811455545,
        npv: -894.8692677728794,
    },
    NativeCase {
        name: "notional_double",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 100000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04155755811455545,
        npv: 151.1525315512571,
    },
    NativeCase {
        name: "dividend_positive",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.02,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04087676815063602,
        npv: 42.54278678711544,
    },
    NativeCase {
        name: "dividend_negative",
        spot: 100.0,
        rate: 0.03,
        dividend: -0.01,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04220078061487499,
        npv: 106.7868859012787,
    },
    NativeCase {
        name: "negative_rate",
        spot: 100.0,
        rate: -0.01,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.041802467800431266,
        npv: 91.02914514947159,
    },
    NativeCase {
        name: "boundary_90",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0],
        variance: 0.0415575581145554,
        npv: 75.5762657756262,
    },
    NativeCase {
        name: "boundary_110",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0],
        variance: 0.041557558114555325,
        npv: 75.57626577562249,
    },
    NativeCase {
        name: "unsorted_duplicate",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[150.0, 100.0, 120.0, 100.0, 140.0, 110.0, 130.0],
        puts: &[80.0, 100.0, 50.0, 70.0, 100.0, 60.0, 90.0],
        variance: 0.04155755811455545,
        npv: 75.57626577562856,
    },
    NativeCase {
        name: "short_maturity",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 7,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.11567195131702245,
        npv: 3781.4213275993393,
    },
    NativeCase {
        name: "zero_volatility",
        spot: 100.0,
        rate: 0.0,
        dividend: 0.0,
        vol: 0.0,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.0,
        npv: -2000.0,
    },
    NativeCase {
        name: "equal_variance_strike",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04155755811455545,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04155755811455545,
        npv: 0.0,
    },
    NativeCase {
        name: "live_updates",
        spot: 100.0,
        rate: 0.03,
        dividend: 0.0,
        vol: 0.2,
        strike: 0.04,
        notional: 50000.0,
        days: 365,
        position: Position::Long,
        dk: 5.0,
        calls: &[100.0, 110.0, 120.0, 130.0, 140.0, 150.0],
        puts: &[50.0, 60.0, 70.0, 80.0, 90.0, 100.0],
        variance: 0.04155755811455545,
        npv: 75.57626577562856,
    },
];