@Test public void calculateWithOneTrade() { MockBarSeries series = new MockBarSeries(numFunction, 100, 105, 110, 100, 95, 105); Trade trade = new Trade(Order.buyAt(0, series), Order.sellAt(3, series)); assertNumEquals(1, getCriterion().calculate(series, trade)); }
@Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { long numberOfLosingTrades = tradingRecord.getTrades().stream().filter(Trade::isClosed) .filter(trade -> isBreakEvenTrade(series, trade)).count(); return series.numOf(numberOfLosingTrades); }
NumberOfBreakEvenTradesCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { long numberOfLosingTrades = tradingRecord.getTrades().stream().filter(Trade::isClosed) .filter(trade -> isBreakEvenTrade(series, trade)).count(); return series.numOf(numberOfLosingTrades); } }
NumberOfBreakEvenTradesCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { long numberOfLosingTrades = tradingRecord.getTrades().stream().filter(Trade::isClosed) .filter(trade -> isBreakEvenTrade(series, trade)).count(); return series.numOf(numberOfLosingTrades); }  }
NumberOfBreakEvenTradesCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { long numberOfLosingTrades = tradingRecord.getTrades().stream().filter(Trade::isClosed) .filter(trade -> isBreakEvenTrade(series, trade)).count(); return series.numOf(numberOfLosingTrades); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2); }
NumberOfBreakEvenTradesCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { long numberOfLosingTrades = tradingRecord.getTrades().stream().filter(Trade::isClosed) .filter(trade -> isBreakEvenTrade(series, trade)).count(); return series.numOf(numberOfLosingTrades); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2);  }