Class ParkinsonVolatilityRTIndicator

All Implemented Interfaces:
Resettable, RTIndicator

public class ParkinsonVolatilityRTIndicator extends AbstractWindowSeriesRTIndicator
Parkinson Volatility estimator with O(1) per-tick updates.

Uses the high-low range to estimate volatility, which is more efficient than close-to-close (Realized Volatility) because it captures intraday price movement. Parkinson (1980) showed this estimator is ~5x more efficient than the classical close-to-close estimator.

The Parkinson variance is:

  σ² = (1 / (4n * ln(2))) * Σ ln(H_i / L_i)²

Maintains a single accumulator (sumLogHLSq) over a window storing ln(H/L)² values. On eviction the accumulator is decremented.

Annualization is supported via withAnnualizationFactor(double).

  • Constructor Details

    • ParkinsonVolatilityRTIndicator

      public ParkinsonVolatilityRTIndicator(int periods)
  • Method Details

    • onEvict

      protected void onEvict(double evicted)
      Description copied from class: AbstractWindowSeriesRTIndicator
      Called when the window evicts the oldest value. Override to update accumulators.
      Overrides:
      onEvict in class AbstractWindowSeriesRTIndicator
    • onReset

      protected void onReset()
      Description copied from class: AbstractWindowSeriesRTIndicator
      Called after window is cleared. Override to zero accumulators.
      Overrides:
      onReset in class AbstractWindowSeriesRTIndicator
    • withAnnualizationFactor

      public ParkinsonVolatilityRTIndicator withAnnualizationFactor(double factor)
      Sets the annualization factor. The output is multiplied by this factor.

      Common values:

      • Math.sqrt(252) — daily bars (trading days/year)
      • Math.sqrt(365) — daily bars (calendar days/year)
    • getParkinsonVariance

      public double getParkinsonVariance()
      Returns the current Parkinson variance (squared volatility, before annualization).
    • update

      public double update(double newValue)
      Not supported — Parkinson requires high and low inputs. Use update(double, double).
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractRTIndicator
      Throws:
      UnsupportedOperationException - always
    • update

      public double update(double high, double low)
      Updates the indicator with a new (high, low) pair and returns the current Parkinson volatility.