Class CalmarRatioRTIndicator
- All Implemented Interfaces:
Resettable, RTIndicator
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the annualized return over the current window.doubleReturns the max drawdown within the current window.intbooleanisReady()Returns whether this indicator has received enough data to produce meaningful values.voidreset()doubleupdate(double price) withAnnualizationFactor(double factor) Sets the annualization factor for the return component.Methods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, withDisplayHint, withMeta
-
Constructor Details
-
CalmarRatioRTIndicator
public CalmarRatioRTIndicator(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
-
withAnnualizationFactor
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:
resetin interfaceResettable- Overrides:
resetin classAbstractRTIndicator
-
update
public double update(double price) - Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator
-