@Test public void calculateWithOneTrade() { MockBarSeries series = new MockBarSeries(numFunction, 100, 95, 100, 80, 85, 70); Trade t = new Trade(Order.buyAt(2, series), Order.sellAt(5, series)); AnalysisCriterion numberOfBars = getCriterion(); assertNumEquals(4, numberOfBars.calculate(series, t)); }
@Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return tradingRecord.getTrades().stream().filter(Trade::isClosed).map(t -> calculate(series, t)) .reduce(series.numOf(0), Num::plus); }
NumberOfBarsCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return tradingRecord.getTrades().stream().filter(Trade::isClosed).map(t -> calculate(series, t)) .reduce(series.numOf(0), Num::plus); } }
NumberOfBarsCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return tradingRecord.getTrades().stream().filter(Trade::isClosed).map(t -> calculate(series, t)) .reduce(series.numOf(0), Num::plus); }  }
NumberOfBarsCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return tradingRecord.getTrades().stream().filter(Trade::isClosed).map(t -> calculate(series, t)) .reduce(series.numOf(0), Num::plus); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2); }
NumberOfBarsCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return tradingRecord.getTrades().stream().filter(Trade::isClosed).map(t -> calculate(series, t)) .reduce(series.numOf(0), Num::plus); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2);  }