Overview

Getting started

Add the crate, construct a typed PricingInputs, and price a contract with full Greeks — in a few lines.

Add the dependency

FerroRisk is a standard Cargo dependency:

cargo add ferro-risk

The default build enables the simd feature, routing the hot kernels through pulp's runtime-dispatched SIMD. Building with --no-default-features drops pulp and runs the always-present scalar implementations instead.

Price your first contract

Every pricing entry point takes a typed PricingInputs and a named PricingModel. Nothing is implicit — time is in years, rates are continuously compounded.

use ferro_risk::{ExerciseStyle, OptionType, PricingInputs, PricingModel, price};

let inputs = PricingInputs {
    option_type: OptionType::Call,
    exercise_style: ExerciseStyle::European,
    spot: 100.0,
    strike: 100.0,
    time_to_expiry: 30.0 / 365.0, // years
    rate: 0.05,                   // continuously compounded
    dividend_yield: 0.0,
    volatility: 0.20,
};

let premium = price(&inputs, PricingModel::BlackScholesMerton)?;
println!("premium = {premium:.4}");
# Ok::<(), ferro_risk::FerroRiskError>(())

…and read all ten Greeks

Swap price for greeks_all to get the price plus the complete first- and second-order Greek surface, computed on one shared evaluation path:

use ferro_risk::{greeks_all, PricingModel};

let g = greeks_all(&inputs, PricingModel::BlackScholesMerton)?;
println!("delta {}  gamma {}  vega {}", g.delta, g.gamma, g.vega);
# Ok::<(), ferro_risk::FerroRiskError>(())
Errors

Pricing entry points return Result<_, FerroRiskError>. Out-of-range inputs return InvalidInput; unsupported model/exercise pairings return UnsupportedModelExerciseCombination. Batch APIs isolate errors per contract rather than failing the whole call.

Where to go next