@Test public void returnsWithGaps() { BarSeries sampleBarSeries = new MockBarSeries(numFunction, 1d, 2d, 3d, 4d, 5d, 6d, 7d, 8d, 9d, 10d, 11d, 12d); TradingRecord tradingRecord = new BaseTradingRecord(Order.sellAt(2, sampleBarSeries), Order.buyAt(5, sampleBarSeries), Order.buyAt(8, sampleBarSeries), Order.sellAt(10, sampleBarSeries)); Returns returns = new Returns(sampleBarSeries, tradingRecord, Returns.ReturnType.LOG); assertNumEquals(NaN.NaN, returns.getValue(0)); assertNumEquals(0, returns.getValue(1)); assertNumEquals(0, returns.getValue(2)); assertNumEquals(-0.28768207245178085, returns.getValue(3)); assertNumEquals(-0.22314355131420976, returns.getValue(4)); assertNumEquals(-0.1823215567939546, returns.getValue(5)); assertNumEquals(0, returns.getValue(6)); assertNumEquals(0, returns.getValue(7)); assertNumEquals(0, returns.getValue(8)); assertNumEquals(0.10536051565782635, returns.getValue(9)); assertNumEquals(0.09531017980432493, returns.getValue(10)); assertNumEquals(0, returns.getValue(11)); }
@Override public Num getValue(int index) { return values.get(index); }
Returns implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } }
Returns implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } Returns(BarSeries barSeries, Trade trade, ReturnType type);  Returns(BarSeries barSeries, TradingRecord tradingRecord, ReturnType type); }
Returns implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } Returns(BarSeries barSeries, Trade trade, ReturnType type);  Returns(BarSeries barSeries, TradingRecord tradingRecord, ReturnType type); List<Num> getValues(); @Override Num getValue(int index); @Override BarSeries getBarSeries(); @Override Num numOf(Number number); int getSize(); void calculate(Trade trade); void calculate(Trade trade, int finalIndex); }
Returns implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } Returns(BarSeries barSeries, Trade trade, ReturnType type);  Returns(BarSeries barSeries, TradingRecord tradingRecord, ReturnType type); List<Num> getValues(); @Override Num getValue(int index); @Override BarSeries getBarSeries(); @Override Num numOf(Number number); int getSize(); void calculate(Trade trade); void calculate(Trade trade, int finalIndex);  }