Class TailRatioRTIndicator

java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.statistics.pro.ratios.TailRatioRTIndicator
All Implemented Interfaces:
Resettable, RTIndicator

public class TailRatioRTIndicator extends AbstractRTIndicator
Rolling Tail Ratio with O(n) per-tick updates via sorted insertion.

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 Details

    • TailRatioRTIndicator

      public TailRatioRTIndicator(int periods)
  • Method Details

    • getPeriods

      public int getPeriods()
    • isReady

      public boolean isReady()
      Description copied from interface: RTIndicator
      Returns 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 returns true, the indicator's output is statistically valid.

      The default implementation returns true for 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:
      true if the indicator has completed its warmup period
    • withPercentiles

      public TailRatioRTIndicator withPercentiles(double upper, double lower)
      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:
      reset in interface Resettable
      Overrides:
      reset in class AbstractRTIndicator
    • update

      public double update(double price)
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractRTIndicator