@Test public void calculateWithNoBarsShouldReturn1() { series = new MockBarSeries(numFunction, 100, 95, 100, 80, 85, 70); AnalysisCriterion averageProfit = getCriterion(); assertNumEquals(1, averageProfit.calculate(series, new BaseTradingRecord())); }
@Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Num bars = numberOfBars.calculate(series, tradingRecord); if (bars.isEqual(series.numOf(0))) { return series.numOf(1); } return totalProfit.calculate(series, tradingRecord).pow(series.numOf(1).dividedBy(bars)); }
AverageProfitCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Num bars = numberOfBars.calculate(series, tradingRecord); if (bars.isEqual(series.numOf(0))) { return series.numOf(1); } return totalProfit.calculate(series, tradingRecord).pow(series.numOf(1).dividedBy(bars)); } }
AverageProfitCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Num bars = numberOfBars.calculate(series, tradingRecord); if (bars.isEqual(series.numOf(0))) { return series.numOf(1); } return totalProfit.calculate(series, tradingRecord).pow(series.numOf(1).dividedBy(bars)); }  }
AverageProfitCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Num bars = numberOfBars.calculate(series, tradingRecord); if (bars.isEqual(series.numOf(0))) { return series.numOf(1); } return totalProfit.calculate(series, tradingRecord).pow(series.numOf(1).dividedBy(bars)); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2); }
AverageProfitCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { Num bars = numberOfBars.calculate(series, tradingRecord); if (bars.isEqual(series.numOf(0))) { return series.numOf(1); } return totalProfit.calculate(series, tradingRecord).pow(series.numOf(1).dividedBy(bars)); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2);  }