Crate simm_rs

Crate simm_rs 

Source
Expand description

§SIMM-RS: Standard Initial Margin Model Calculator

A high-performance Rust implementation of the ISDA SIMM (Standard Initial Margin Model) for calculating initial margin requirements on non-cleared derivatives.

§What is SIMM?

SIMM (Standard Initial Margin Model) is a standardized methodology developed by ISDA (International Swaps and Derivatives Association) in 2013 for calculating the appropriate level of initial margin (IM) for non-cleared derivatives. It emerged as a response to lessons learned from the Global Financial Crisis, particularly the defaults of Lehman Brothers and AIG, which highlighted the need for proper margining of derivative exposures.

Initial margin functions as a reserve to cover potential future exposure during the margin period of risk, capturing funding costs when rehypothecation is restricted.

§Core Principles

The SIMM methodology is built on six fundamental principles:

  1. Shock Application: Stress scenarios applied to derivative portfolios
  2. Aggregation Methodology: Systematic approach to combining risks
  3. 99% Confidence Interval: Loss estimation at 99th percentile
  4. 10-Day Time Horizon: Risk measurement over a 10-day closeout period
  5. Sensitivities-Based Approach: Uses Greeks (Delta, Vega, Curvature) rather than full revaluation for computational efficiency
  6. Collateral Haircuts: Includes adjustments for collateral valuation

§Risk Classification

SIMM segments derivative instruments into six primary risk classes:

  • GIRR (General Interest Rate Risk): Interest rate derivatives
  • FX (Foreign Exchange): Currency derivatives
  • Equity: Equity and equity index derivatives
  • Commodity: Commodity derivatives (energy, metals, agriculture, etc.)
  • Credit Qualifying: Investment-grade credit derivatives
  • Credit Non-Qualifying: Non-investment-grade credit derivatives

Each risk class is further subdivided into buckets (e.g., currencies for IR/FX, sectors for equities, commodity types, credit ratings for spreads).

§Calculation Methodology

The SIMM calculation combines three distinct margin components:

§1. Delta Margin

First-order sensitivity to underlying price changes. Captures the linear relationship between derivative value and the underlying asset price.

§2. Vega Margin

Sensitivity to changes in implied volatility. Measures exposure to volatility shifts in option-based derivatives.

§3. Curvature Margin

Second-order convexity effects (Gamma). Captures non-linear price relationships, particularly important for deep out-of-the-money options.

The methodology employs a delta-normal approximation with the formula: VaR = |Delta₀| × (α × σ × S₀)

where α represents the standard normal deviate for the 99% confidence level.

§SIMM Versions

This library supports multiple SIMM versions:

  • SIMM 2.5: Released for compliance with initial margin regulations
  • SIMM 2.6: Updated risk weights and correlations
  • SIMM 2.7: Latest version with refined parameters

§Library Architecture

The library is organized into several key modules:

  • agg_margins: Aggregation of margins across risk classes and products
  • agg_sensitivities: Calculation of K factors (delta, vega, curvature)
  • margin_risk_class: Risk class-specific margin calculations
  • file_utils: CSV/JSON file handling and test utilities
  • simm_utils: Core utilities for CRIF processing
  • v2_5, v2_6, v2_7: Version-specific risk weights and correlations

§Usage Example

use simm_rs::{SIMM, EngineConfig, V2_5, parse_csv_from_string};

// Create configuration for SIMM 2.5
let cfg = EngineConfig {
    weights_and_corr_version: "2_5".to_string(),
    calculation_currency: "USD".to_string(),
    exchange_rate: 1.0,
};

// Load CRIF data (Common Risk Interchange Format)
let crif_csv = std::fs::read_to_string("portfolio.csv").unwrap();
let crif = parse_csv_from_string(&crif_csv).unwrap();

// Calculate SIMM
let wnc = V2_5;  // Weights and correlations for version 2.5
let simm = SIMM::from_crif(crif, &cfg, &wnc).unwrap();

println!("Total SIMM: {:.2}", simm.simm);

§CRIF Format

The Common Risk Interchange Format (CRIF) is a standardized CSV format for representing derivative sensitivities:

ColumnDescription
ProductClassRatesFX, Rates, Credit, Equity, Commodity
RiskTypeRisk_IRCurve, Risk_FX, Risk_CreditQ, etc.
QualifierCurrency, issuer name, equity ticker, etc.
BucketRisk bucketing (e.g., credit rating, sector)
Label1Tenor or maturity (e.g., 1y, 5y, 10y)
Label2Additional label (often empty or sub-curve)
AmountSensitivity amount in reporting currency
AmountCurrencyCurrency of the amount
AmountUSDEquivalent amount in USD

§Economic Context

MVA (Margin Valuation Adjustment) represents the funding cost associated with posting initial margin. This is a critical consideration in derivatives pricing, as dealers must fund margin requirements through short-term borrowing, introducing funding spread costs beyond the risk-free rate.

§Testing and Validation

The library includes comprehensive test suites covering 481 test cases per SIMM version, validating calculations against ISDA SIMM reference implementations. Backtesting employs the failure rate method, ensuring margin adequacy at the 99% confidence level.

§References

Re-exports§

pub use file_utils::parse_csv_from_string;

Modules§

file_utils

Structs§

EngineConfig
MarginByRiskClass
MarginByRiskClass calculator
SIMM
Main SIMM calculator
V2_5
SIMM version 2.5 parameter set
V2_6
SIMM version 2.6 parameter set
V2_7
SIMM version 2.7 parameter set

Traits§

WeightsAndCorr

Functions§

calc_simm
k_curvature
Compute curvature capital charge K for a given risk class and bucket
k_delta
Compute delta capital charge K for a given risk class and bucket
k_vega
Compute vega capital charge K for a given risk class and bucket

Type Aliases§

Crif
Type alias for CRIF data (Common Risk Interchange Format) First row is the header, subsequent rows are data