Class VolatilityForecaster

java.lang.Object
com.quantfinlib.ml.VolatilityForecaster

public final class VolatilityForecaster extends Object
Machine Learning Risk Forecasting: predicts forward realized volatility from a return series using gradient-boosted trees over engineered features (multi-horizon realized vol, momentum, and shock magnitude), and maps the forecast to a 0-100 risk score.

fit(double[]) is in-sample: 150 boosting rounds with no early stopping will fit noise, and riskScore(double[]) ranks against the training targets. Before relying on the model, run validate(double[], double): it fits on the first part of the series and scores out-of-sample forecasts against two baselines the model must beat, RiskMetrics EWMA (λ = 0.94) and HAR-RV on squared returns. Trees are invariant to monotone feature scaling, so no scaling is applied.

  • Constructor Details

    • VolatilityForecaster

      public VolatilityForecaster(int horizon)
      Parameters:
      horizon - forward window (in periods) whose realized vol is predicted
  • Method Details

    • weekly

      public static VolatilityForecaster weekly()
    • fit

      public VolatilityForecaster fit(double[] returns)
      Trains on a historical return series (needs at least ~3 months of data).
    • forecast

      public double forecast(double[] returns)
      Forecast of next-horizon-period volatility (per-period units).
    • riskScore

      public double riskScore(double[] returns)
      Risk score in [0, 100]: the percentile of the forecast within the realised volatilities of the training sample (an in-sample reference distribution).
    • validate

      public VolatilityForecaster.Validation validate(double[] returns, double trainFraction)
      Time-split validation. A fresh model with this forecaster's horizon is fitted on returns[0, split) with split = floor(trainFraction·n); every later date t with a full forward window is then forecast from returns[0, t) only, as are the EWMA and HAR-RV baselines (HAR fitted on the training squared returns). The target is the sample stdev of returns[t, t+horizon). This forecaster's own fitted state is not changed.