@Test public void calculateWithOneTrade() { MockBarSeries series = new MockBarSeries(numFunction, 100, 105); Trade trade = new Trade(Order.buyAt(0, series), Order.sellAt(1, series)); AnalysisCriterion buyAndHold = getCriterion(); assertNumEquals(105d / 100, buyAndHold.calculate(series, trade)); }
@Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return series.getBar(series.getEndIndex()).getClosePrice() .dividedBy(series.getBar(series.getBeginIndex()).getClosePrice()); }
BuyAndHoldCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return series.getBar(series.getEndIndex()).getClosePrice() .dividedBy(series.getBar(series.getBeginIndex()).getClosePrice()); } }
BuyAndHoldCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return series.getBar(series.getEndIndex()).getClosePrice() .dividedBy(series.getBar(series.getBeginIndex()).getClosePrice()); }  }
BuyAndHoldCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return series.getBar(series.getEndIndex()).getClosePrice() .dividedBy(series.getBar(series.getBeginIndex()).getClosePrice()); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2); }
BuyAndHoldCriterion extends AbstractAnalysisCriterion { @Override public Num calculate(BarSeries series, TradingRecord tradingRecord) { return series.getBar(series.getEndIndex()).getClosePrice() .dividedBy(series.getBar(series.getBeginIndex()).getClosePrice()); }  @Override Num calculate(BarSeries series, TradingRecord tradingRecord); @Override Num calculate(BarSeries series, Trade trade); @Override boolean betterThan(Num criterionValue1, Num criterionValue2);  }