NeuralStressTest<T>
Models & Types · AiDotNet.Finance.Risk
Neural network model for generating and evaluating stress test scenarios.
Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → RiskModelBase<T> → NeuralStressTest<T>
For Beginners
Neural Stress Testing learns to predict how a portfolio behaves under extreme market conditions. Unlike traditional stress testing which uses fixed historical scenarios, this model can generate new, plausible crisis scenarios (like a “Deep Fake” market crash) to test portfolio resilience against events that haven’t happened yet.
Example
// Define architecture for stress test scenario generation (10 market factors)
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.Regression,
inputSize: 10, outputSize: 1);
// Training mode: learns to generate plausible extreme market scenarios
var model = new NeuralStressTest<double>(architecture);
// Parameterless constructor with default architecture
var defaultModel = new NeuralStressTest<double>();
Constructors
| Constructor | Summary |
|---|---|
NeuralStressTest() |
Initializes a new instance of the NeuralStressTest model. |
NeuralStressTest(NeuralNetworkArchitecture<T> architecture, NeuralStressTestOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
|
NeuralStressTest(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, NeuralStressTestOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Initializes a new instance from ONNX. |
Methods
| Method | Summary |
|---|---|
T CalculateRisk(Tensor<T> input) |
Calculates aggregate risk across generated stress scenarios. |
Tensor<T> AdjustForRisk(Tensor<T> action, T riskBudget) |
Adjusts action based on stress test results. |
Tensor<T> StressTest(Tensor<T> input, Tensor<T> stressScenarios) |
Generates stress scenarios for the given input state. |