Class RangeVolatility

java.lang.Object
com.quantfinlib.volatility.RangeVolatility

public final class RangeVolatility extends Object
RANGE-BASED volatility estimators — the free lunch hiding inside every OHLC bar: the high-low range carries far more information about the day's variance than the close alone, so a range estimator reaches a given precision with several times fewer bars than close-to-close. Four classics, in increasing order of what they use:
  • Parkinson (1980) — range only: sigma^2 = mean( ln(H/L)^2 ) / (4 ln 2). About 4.9x more efficient than close-to-close under driftless GBM; biased UP by drift (it books trend as range) and DOWN by discrete sampling (the observed high underestimates the true high).
  • Garman-Klass (1980) — range plus open/close: sigma^2 = mean( 0.5 ln(H/L)^2 - (2 ln 2 - 1) ln(C/O)^2 ). Roughly 7.4x efficient; still assumes zero drift.
  • Rogers-Satchell (1991) — drift-INDEPENDENT: sigma^2 = mean( ln(H/C) ln(H/O) + ln(L/C) ln(L/O) ). The one to reach for on trending series.
  • Yang-Zhang (2000) — adds the OVERNIGHT gap the others ignore: sigma^2 = sigma_o^2 + k sigma_c^2 + (1-k) sigma_rs^2 with sigma_o^2 the sample variance of open-over-prior-close log returns, sigma_c^2 the sample variance of close-over-open log returns, sigma_rs^2 the Rogers-Satchell term, and k = 0.34 / (1.34 + (m+1)/(m-1)) over m periods — the weighting that minimizes the estimator's variance. Drift independent AND jump-aware; the practical default for daily bars on markets that close.

All methods return ANNUALIZED volatility (not variance): sqrt(perPeriodVariance * periodsPerYear), with the annualization factor supplied by the caller (252 for daily bars, 52 for weekly, ...) — this class does not choose your calendar. Estimates are computed over the full arrays passed in; slice (BarSeries.slice(int, int)) for rolling windows. Static, deterministic, research lane.

  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    garmanKlass(double[] open, double[] high, double[] low, double[] close, double periodsPerYear)
    Garman-Klass estimator, annualized.
    static double
    garmanKlass(BarSeries bars, double periodsPerYear)
    Garman-Klass over a whole BarSeries.
    static double
    parkinson(double[] high, double[] low, double periodsPerYear)
    Parkinson estimator from highs/lows, annualized.
    static double
    parkinson(BarSeries bars, double periodsPerYear)
    Parkinson over a whole BarSeries.
    static double
    rogersSatchell(double[] open, double[] high, double[] low, double[] close, double periodsPerYear)
    Rogers-Satchell (drift-independent) estimator, annualized.
    static double
    rogersSatchell(BarSeries bars, double periodsPerYear)
    Rogers-Satchell over a whole BarSeries.
    static double
    yangZhang(double[] open, double[] high, double[] low, double[] close, double periodsPerYear)
    Yang-Zhang estimator, annualized.
    static double
    yangZhang(BarSeries bars, double periodsPerYear)
    Yang-Zhang over a whole BarSeries.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parkinson

      public static double parkinson(double[] high, double[] low, double periodsPerYear)
      Parkinson estimator from highs/lows, annualized.
    • parkinson

      public static double parkinson(BarSeries bars, double periodsPerYear)
      Parkinson over a whole BarSeries.
    • garmanKlass

      public static double garmanKlass(double[] open, double[] high, double[] low, double[] close, double periodsPerYear)
      Garman-Klass estimator, annualized.
    • garmanKlass

      public static double garmanKlass(BarSeries bars, double periodsPerYear)
      Garman-Klass over a whole BarSeries.
    • rogersSatchell

      public static double rogersSatchell(double[] open, double[] high, double[] low, double[] close, double periodsPerYear)
      Rogers-Satchell (drift-independent) estimator, annualized.
    • rogersSatchell

      public static double rogersSatchell(BarSeries bars, double periodsPerYear)
      Rogers-Satchell over a whole BarSeries.
    • yangZhang

      public static double yangZhang(double[] open, double[] high, double[] low, double[] close, double periodsPerYear)
      Yang-Zhang estimator, annualized. Uses bars 1..n-1 as the estimation periods (bar 0 only supplies the prior close for the first overnight return), so it needs at least 3 bars for the sample variances to exist.
    • yangZhang

      public static double yangZhang(BarSeries bars, double periodsPerYear)
      Yang-Zhang over a whole BarSeries.