Class RealizedVolatilityRTIndicator
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.RealizedVolatilityRTIndicator
- All Implemented Interfaces:
Resettable, RTIndicator
Rolling Realized Volatility with O(1) per-tick updates.
Computes the standard deviation of log returns over a rolling window.
Each tick produces a log return r = ln(price / prevPrice), which
is stored in the window. Dual accumulators (sumR
and sumRSq) maintain the running variance of these returns.
Realized volatility is computed as:
RV = sqrt(sumRSq/n - (sumR/n)^2)
The first tick establishes the initial price — no return is produced, so the window starts filling from the second tick onward.
Annualization is supported via withAnnualizationFactor(double).
Common factors: sqrt(252) for daily, sqrt(52) for weekly,
sqrt(365*24*60) for per-minute crypto data. When set, the output
is RV * factor.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the current mean log return over the window.doubleReturns the current realized variance (squared realized volatility, before annualization).protected voidonEvict(double evicted) Called when the window evicts the oldest value.protected voidonReset()Called after window is cleared.doubleupdate(double price) 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
-
RealizedVolatilityRTIndicator
public RealizedVolatilityRTIndicator(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)Math.sqrt(52)— weekly bars
-
getMeanReturn
public double getMeanReturn()Returns the current mean log return over the window. -
getRealizedVariance
public double getRealizedVariance()Returns the current realized variance (squared realized volatility, before annualization). -
update
public double update(double price) - Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator
-