RiskModelBase<T>

Base Classes · AiDotNet.Finance.Base

Base class for risk management models, providing common infrastructure for risk assessment.

Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → RiskModelBase<T>

Implements: IRiskModel<T>

Known derived types: NeuralCVaR<T>, NeuralStressTest<T>, NeuralVaR<T>, SAINT<T>, TabNet<T>, TabTransformer<T>

For Beginners

This is the “parent” for all risk models. It handles the boring stuff (like saving settings to a file or checking input shapes) so that specific models (like NeuralVaR) can focus on the actual math of predicting risk.

How It Works

This abstract base class implements the IRiskModel interface and provides the foundation for neural network-based risk models. It handles common tasks like model configuration, serialization, and basic metric tracking.

Properties

Property Summary
IRiskRatioCalculator<T> RiskRatioCalculator { get; set; } The risk-adjusted-performance calculator used by ComputeRiskRatios.
double ConfidenceLevel { get; } Gets the confidence level for risk calculations.
int TimeHorizon { get; } Gets the time horizon for risk calculations.

Methods

Method Summary
Dictionary<string, T> GetFinancialMetrics() Gets overall financial metrics for the model.
Dictionary<string, T> GetRiskMetrics() Gets metrics for risk model evaluation.
ModelInputShapeConstraint GetInputShapeConstraint() Declares the cross-sectional geometry a risk model accepts.
T CalculateCVaR(Tensor<T> portfolioReturns, Tensor<T> weights) Calculates Conditional Value at Risk (CVaR).
T CalculateRisk(Tensor<T> input) Calculates the primary risk metric for the given input.
T CalculateVaR(Tensor<T> portfolioReturns, Tensor<T> weights) Calculates Value at Risk (VaR).
T EstimateExceedanceProbability(Tensor<T> portfolioReturns, Tensor<T> weights, T lossThreshold) Estimates the probability of losses exceeding a threshold.
Tensor<T> AdjustForRisk(Tensor<T> action, T riskBudget) Adjusts a proposed action to satisfy risk constraints.
Tensor<T> DecomposeRisk(Tensor<T> portfolioReturns, Tensor<T> weights) Decomposes total risk into contributions from individual assets.
Tensor<T> StressTest(Tensor<T> portfolioWeights, Tensor<T> stressScenarios) Performs stress testing under specific scenarios.
ValueTuple<T, T, T> ComputeRiskRatios(IReadOnlyList<T> returns, double riskFreePerPeriod, int periodsPerYear) Scores a realized periodic return series with the configured RiskRatioCalculator, returning the annualized Sharpe, Sortino, and Calmar ratios.