Class CalmarRatioRTIndicator

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

public class CalmarRatioRTIndicator extends AbstractRTIndicator
Rolling Calmar Ratio with O(1) per-tick updates.

Measures the risk-adjusted return relative to the maximum drawdown over the rolling window:

  Calmar = annualizedReturn / maxDrawdown

The annualized return is computed from the cumulative log return over the window: (sumR / n) * annualizationFactor. The max drawdown is tracked by maintaining a running peak over cumulative returns within the window.

Since max drawdown within a rolling window cannot be maintained incrementally (evicting the oldest value may remove the peak), this indicator stores log returns in a WindowSeriesStore and recomputes the window max drawdown in O(n) when the window rolls.

Returns 0 when max drawdown is zero (no decline in window).

  • Constructor Details

    • CalmarRatioRTIndicator

      public CalmarRatioRTIndicator(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
    • withAnnualizationFactor

      public CalmarRatioRTIndicator withAnnualizationFactor(double factor)
      Sets the annualization factor for the return component. Default is 252 (daily bars → annual return).

      The mean per-period return is multiplied by this factor.

    • getAnnualizedReturn

      public double getAnnualizedReturn()
      Returns the annualized return over the current window.
    • getMaxDrawdown

      public double getMaxDrawdown()
      Returns the max drawdown within 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