IRiskModel<T>
Interfaces · AiDotNet.Finance.Interfaces
Interface for financial risk models that estimate potential losses.
Implements: IFinancialModel<T>
Known implementations: RiskModelBase<T>
For Beginners
Risk models help answer: “How much could I lose?”
Key Risk Measures:
- Value at Risk (VaR): Maximum loss at a given confidence level
- Conditional VaR (CVaR): Average loss when VaR is exceeded
- Expected Shortfall: Same as CVaR, also called tail risk
Example: If 95% VaR is $1M, there’s a 95% chance you won’t lose more than $1M today. The 5% CVaR tells you the average loss in the worst 5% of cases.
Why Use Neural Risk Models:
- Capture non-linear risk patterns
- Handle complex portfolio structures
- Adapt to changing market conditions
- Process high-dimensional data
How It Works
Risk models are essential for financial risk management, providing estimates of potential losses under various market conditions. This interface defines common methods for risk measurement, stress testing, and risk decomposition.
Properties
| Property | Summary |
|---|---|
double ConfidenceLevel { get; } |
Gets the confidence level for risk calculations (e.g., 0.95 for 95% VaR). |
int TimeHorizon { get; } |
Gets the time horizon for risk calculations in days. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetRiskMetrics() |
Gets risk-specific metrics for model evaluation. |
T CalculateCVaR(Tensor<T> portfolioReturns, Tensor<T> weights) |
Calculates Conditional Value at Risk (CVaR), also known as Expected Shortfall. |
T CalculateVaR(Tensor<T> portfolioReturns, Tensor<T> weights) |
Calculates Value at Risk (VaR) for the given portfolio. |
T EstimateExceedanceProbability(Tensor<T> portfolioReturns, Tensor<T> weights, T lossThreshold) |
Estimates the probability of a given loss being exceeded. |
Tensor<T> DecomposeRisk(Tensor<T> portfolioReturns, Tensor<T> weights) |
Decomposes total risk into component contributions. |
Tensor<T> StressTest(Tensor<T> portfolioWeights, Tensor<T> stressScenarios) |
Performs stress testing under specified scenarios. |