Class VolatilityForecaster
java.lang.Object
com.quantfinlib.ml.VolatilityForecaster
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOut-of-sample comparison: RMSE (per-period vol units) of the model and of the two baselines over the same forecast dates. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfit(double[] returns) Trains on a historical return series (needs at least ~3 months of data).doubleforecast(double[] returns) Forecast of next-horizon-period volatility (per-period units).doubleriskScore(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(double[] returns, double trainFraction) Time-split validation.static VolatilityForecasterweekly()
-
Constructor Details
-
VolatilityForecaster
public VolatilityForecaster(int horizon) - Parameters:
horizon- forward window (in periods) whose realized vol is predicted
-
-
Method Details
-
weekly
-
fit
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
Time-split validation. A fresh model with this forecaster's horizon is fitted onreturns[0, split)withsplit = floor(trainFraction·n); every later date t with a full forward window is then forecast fromreturns[0, t)only, as are the EWMA and HAR-RV baselines (HAR fitted on the training squared returns). The target is the sample stdev ofreturns[t, t+horizon). This forecaster's own fitted state is not changed.
-