Class TailRatioRTIndicator
- All Implemented Interfaces:
Resettable, RTIndicator
Measures the asymmetry between the right (gain) tail and left (loss) tail of the return distribution:
TailRatio = percentile(0.95) / |percentile(0.05)|
A Tail Ratio > 1 indicates the right tail is fatter (larger gains than losses at the extremes). A ratio < 1 indicates fatter left tail (risk of large losses).
Internally computes log returns and maintains a circular buffer
(insertion order) plus a sorted array for O(1) percentile lookup with
O(n) sorted insertion/removal per tick. Configurable upper and lower
percentiles via withPercentiles(double, double).
Returns 0 when the window has fewer than 2 returns or when the lower percentile is zero.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the lower percentile value of the current window.intdoubleReturns the upper percentile value of the current window.booleanisReady()Returns whether this indicator has received enough data to produce meaningful values.voidreset()doubleupdate(double price) withPercentiles(double upper, double lower) Sets the upper and lower percentiles.Methods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, withDisplayHint, withMeta
-
Constructor Details
-
TailRatioRTIndicator
public TailRatioRTIndicator(int periods)
-
-
Method Details
-
getPeriods
public int getPeriods() -
isReady
public boolean isReady()Description copied from interface:RTIndicatorReturns whether this indicator has received enough data to produce meaningful values.During the warmup period,
RTIndicator.getValue()may return 0 or a partial estimate that should not be used for trading decisions. Once this method returnstrue, the indicator's output is statistically valid.The default implementation returns
truefor backward compatibility. Indicators with warmup requirements should override this method.For composite indicators (e.g. Bollinger Bands, MACD), readiness is determined by the slowest internal component.
- Returns:
trueif the indicator has completed its warmup period
-
withPercentiles
Sets the upper and lower percentiles. Default: 0.95 and 0.05. -
getUpperPercentile
public double getUpperPercentile()Returns the upper percentile value of the current window. -
getLowerPercentile
public double getLowerPercentile()Returns the lower percentile value of the current window. -
reset
public void reset()- Specified by:
resetin interfaceResettable- Overrides:
resetin classAbstractRTIndicator
-
update
public double update(double price) - Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator
-