Crates.io | oxidiviner-garch |
lib.rs | oxidiviner-garch |
version | 0.3.3 |
created_at | 2025-05-19 18:56:25.182788+00 |
updated_at | 2025-05-19 20:51:32.171753+00 |
description | GARCH models for volatility forecasting and risk modeling in financial time series |
homepage | https://github.com/rustic-ml/OxiDiviner |
repository | https://github.com/rustic-ml/OxiDiviner |
max_upload_size | |
id | 1680262 |
size | 90,965 |
A Rust implementation of Generalized Autoregressive Conditional Heteroskedasticity (GARCH) models for time series analysis and volatility forecasting.
GARCH models are widely used for analyzing and forecasting volatility in financial time series data. This crate provides a robust implementation of GARCH(p,q) models, suitable for financial analysis, risk management, and econometric modeling.
Add this to your Cargo.toml
:
[dependencies]
oxidiviner-garch = "0.1.0"
use oxidiviner_garch::GARCHModel;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a GARCH(1,1) model
let mut model = GARCHModel::new(1, 1, None)?;
// Sample time series data
let data = vec![0.1, 0.2, -0.3, 0.1, -0.2, 0.3, -0.1, 0.4, -0.2, 0.1];
// Fit the model
model.fit(&data, None)?;
// Display model parameters
println!("{}", model);
// Forecast future volatility (5 steps ahead)
let forecast = model.forecast_variance(5)?;
println!("Volatility forecast: {:?}", forecast);
Ok(())
}
The GARCH(p,q) model is defined as:
y_t = μ + ε_t
ε_t = σ_t * z_t, where z_t ~ N(0,1)
σ²_t = ω + Σ(i=1 to p) α_i * ε²_{t-i} + Σ(j=1 to q) β_j * σ²_{t-j}
Where:
Licensed under the MIT License. See LICENSE for details.