Class ParkinsonVolatilityRTIndicator
java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractWindowSeriesRTIndicator
com.wualabs.qtsurfer.engine.indicators.statistics.pro.volatility.ParkinsonVolatilityRTIndicator
- All Implemented Interfaces:
Resettable, RTIndicator
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the current Parkinson variance (squared volatility, before annualization).protected voidonEvict(double evicted) Called when the window evicts the oldest value.protected voidonReset()Called after window is cleared.doubleupdate(double newValue) Not supported — Parkinson requires high and low inputs.doubleupdate(double high, double low) Updates the indicator with a new (high, low) pair and returns the current Parkinson volatility.withAnnualizationFactor(double factor) Sets the annualization factor.Methods inherited from class AbstractWindowSeriesRTIndicator
getPeriods, isReady, reset, window, windowSizeMethods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, withDisplayHint, withMeta
-
Constructor Details
-
ParkinsonVolatilityRTIndicator
public ParkinsonVolatilityRTIndicator(int periods)
-
-
Method Details
-
onEvict
protected void onEvict(double evicted) Description copied from class:AbstractWindowSeriesRTIndicatorCalled when the window evicts the oldest value. Override to update accumulators.- Overrides:
onEvictin classAbstractWindowSeriesRTIndicator
-
onReset
protected void onReset()Description copied from class:AbstractWindowSeriesRTIndicatorCalled after window is cleared. Override to zero accumulators.- Overrides:
onResetin classAbstractWindowSeriesRTIndicator
-
withAnnualizationFactor
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. Useupdate(double, double).- Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator- 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.
-