pub fn price_with_svi(
params: SVIParams,
market_data: Vec<MarketDataRow>,
fixed_params: FixedParameters,
) -> Vec<PricingResult>Expand description
Price European options using calibrated SVI model parameters.
This function takes pre-calibrated SVI parameters and applies them to price a set of options using the Black-Scholes framework with SVI-derived implied volatilities. The pricing is efficient and suitable for real-time applications.
§Arguments
params- Calibrated SVI parameters containing the time to expiration and model coefficientsmarket_data- Option contracts to price (can be same or different from calibration data)fixed_params- Market parameters including risk-free rate and dividend yield
§Returns
Vector of PricingResult containing option details, model prices, and implied volatilities.
Results are sorted by strike price in ascending order.
§Pricing Methodology
- Log-moneyness calculation:
k = ln(K/S)for each option - SVI implied volatility:
σ(k) = sqrt(w(k)/t)wherew(k)is SVI total variance - Black-Scholes pricing: European option price using SVI-derived volatility
- Result compilation: Organized results with validation and error handling
§Example
use surface_lib::{
price_with_svi, MarketDataRow, FixedParameters,
models::svi::svi_model::SVIParams
};
// Create SVI parameters (typically from calibration)
let svi_params = SVIParams {
t: 0.0274, // ~10 days to expiration
a: 0.04, // Base variance
b: 0.2, // Slope factor
rho: -0.3, // Negative skew
m: 0.0, // ATM at log-moneyness 0
sigma: 0.2, // Curvature
};
// Market parameters
let fixed_params = FixedParameters {
r: 0.02, // 2% risk-free rate
q: 0.0, // No dividend yield
};
// Price options
let pricing_results = price_with_svi(svi_params, market_data, fixed_params);
for result in &pricing_results {
println!("Strike {}: Price ${:.2}, IV {:.1}%",
result.strike_price,
result.model_price,
result.model_iv * 100.0);
}§Error Handling
The function uses robust error handling:
- Invalid pricing results default to zero price and implied volatility
- Time mismatches between SVI parameters and market data are handled gracefully
- Non-finite or negative volatilities are caught and logged
§Performance Notes
- Pricing scales linearly with the number of options
- Typical performance: 10,000+ options per second on modern hardware
- Memory usage is minimal with in-place calculations