NeuralGARCH<T>

Models & Types · AiDotNet.Finance.Volatility

Neural GARCH model for forecasting asset volatility.

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

Implements: IVolatilityModel<T>

For Beginners

GARCH is a popular statistical model for volatility. This neural version learns the same idea from data instead of fixed formulas. It looks at recent returns and predicts how bouncy prices will be next.

How It Works

NeuralGARCH extends the classic GARCH idea with a neural network, allowing non-linear relationships between recent returns and future volatility.

Example

// Create a Neural GARCH model for volatility forecasting
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.Regression,
    inputHeight: 60, inputWidth: 1, inputDepth: 1, outputSize: 1);
var model = new NeuralGARCH<double>(architecture);
            
// Or load a pre-trained ONNX model for volatility prediction
var onnxModel = new NeuralGARCH<double>(architecture, "neuralgarch.onnx");

Constructors

Constructor Summary
NeuralGARCH(NeuralNetworkArchitecture<T> architecture, NeuralGARCHOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) Creates a NeuralGARCH model in native mode for training.
NeuralGARCH(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, NeuralGARCHOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) Creates a NeuralGARCH model using a pretrained ONNX model.

Methods

Method Summary
Dictionary<string, T> GetFinancialMetrics() Gets overall financial metrics for the model.
Dictionary<string, T> GetVolatilityMetrics() Gets volatility-specific metrics.
ModelMetadata<T> GetModelMetadata() Returns metadata describing the model.
Tensor<T> CalculateRealizedVolatility(Tensor<T> highFrequencyReturns) Calculates realized volatility from high-frequency returns.
Tensor<T> ComputeCorrelationMatrix(Tensor<T> returns) Computes the correlation matrix.
Tensor<T> ComputeCovarianceMatrix(Tensor<T> returns) Computes the covariance matrix.
Tensor<T> EstimateCurrentVolatility(Tensor<T> recentReturns) Estimates the current volatility from recent returns.
Tensor<T> ForecastVolatility(Tensor<T> historicalReturns, int horizon) Forecasts future volatility.