@Test public void calculateWithOneTrade() { series = new MockBarSeries(numFunction, 100, 105); Trade trade = new Trade(Order.buyAt(0, series), Order.sellAt(1, series)); AnalysisCriterion average = getCriterion(); assertNumEquals(numOf(105d / 100).pow(numOf(0.5)), average.calculate(series, trade)); }
@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);  }