Class EwmaVolatility
java.lang.Object
com.quantfinlib.volatility.EwmaVolatility
Exponentially weighted moving average variance (RiskMetrics Technical
Document, J.P. Morgan 1996, ch. 5):
h_t = λ h_{t-1} + (1-λ) r_{t-1}²
on raw (not demeaned) returns. Reacts to volatility regime changes far
faster than a rolling window.
Seeding is causal. variances(double[]) has no prior estimate,
so for t >= 1 it uses the bias-corrected weights
h_t = Σ_{k<t} (1−λ)λ^{t−1−k} r_k² / (1 − λ^t), which use only
returns before period t; h_0 has no information at all and is set
to h_1 = r_0², the one entry that sees its own period's return.
variances(double[], double) takes an explicit prior variance
(from a training window) and runs the plain recursion from it. The
earlier full-sample seed leaked the whole sample into every early
estimate.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleannualizedVol(double[] returns, int periodsPerYear) doublelatestVol(double[] returns) One-step-ahead volatility forecast (per period) for the period after the last return, with the same bias-corrected causal weights asvariances(double[]).static EwmaVolatilityThe classic RiskMetrics daily decay (λ = 0.94).double[]variances(double[] returns) Conditional variance series aligned with returns:variances[i]is the estimate for period i, formed from information up to i-1.double[]variances(double[] returns, double seedVariance) Conditional variances from an explicit prior:h_0 = seedVariance, then the plain recursion.
-
Constructor Details
-
EwmaVolatility
public EwmaVolatility(double lambda)
-
-
Method Details
-
riskMetrics
The classic RiskMetrics daily decay (λ = 0.94). -
variances
public double[] variances(double[] returns) Conditional variance series aligned with returns:variances[i]is the estimate for period i, formed from information up to i-1. -
variances
public double[] variances(double[] returns, double seedVariance) Conditional variances from an explicit prior:h_0 = seedVariance, then the plain recursion.- Parameters:
seedVariance- variance estimate for period 0 formed before the sample starts, > 0 and finite
-
latestVol
public double latestVol(double[] returns) One-step-ahead volatility forecast (per period) for the period after the last return, with the same bias-corrected causal weights asvariances(double[]). -
annualizedVol
public double annualizedVol(double[] returns, int periodsPerYear)
-