@Test public void cashFlowValue() { TimeSeries sampleTimeSeries = new MockTimeSeries(3d, 2d, 5d, 1000d, 5000d, 0.0001d, 4d, 7d, 6d, 7d, 8d, 5d, 6d); TradingRecord tradingRecord = new BaseTradingRecord( Order.buyAt(0), Order.sellAt(2), Order.buyAt(6), Order.sellAt(8), Order.buyAt(9), Order.sellAt(11)); CashFlow cashFlow = new CashFlow(sampleTimeSeries, tradingRecord); assertDecimalEquals(cashFlow.getValue(0), 1); assertDecimalEquals(cashFlow.getValue(1), 2d/3); assertDecimalEquals(cashFlow.getValue(2), 5d/3); assertDecimalEquals(cashFlow.getValue(3), 5d/3); assertDecimalEquals(cashFlow.getValue(4), 5d/3); assertDecimalEquals(cashFlow.getValue(5), 5d/3); assertDecimalEquals(cashFlow.getValue(6), 5d/3); assertDecimalEquals(cashFlow.getValue(7), 5d/3 * 7d/4); assertDecimalEquals(cashFlow.getValue(8), 5d/3 * 6d/4); assertDecimalEquals(cashFlow.getValue(9), 5d/3 * 6d/4); assertDecimalEquals(cashFlow.getValue(10), 5d/3 * 6d/4 * 8d/7); assertDecimalEquals(cashFlow.getValue(11), 5d/3 * 6d/4 * 5d/7); assertDecimalEquals(cashFlow.getValue(12), 5d/3 * 6d/4 * 5d/7); sampleTimeSeries = new MockTimeSeries(5d, 6d, 3d, 7d, 8d, 6d, 10d, 15d, 6d); tradingRecord = new BaseTradingRecord( Order.buyAt(4), Order.sellAt(5), Order.buyAt(6), Order.sellAt(8)); CashFlow flow = new CashFlow(sampleTimeSeries, tradingRecord); assertDecimalEquals(flow.getValue(0), 1); assertDecimalEquals(flow.getValue(1), 1); assertDecimalEquals(flow.getValue(2), 1); assertDecimalEquals(flow.getValue(3), 1); assertDecimalEquals(flow.getValue(4), 1); assertDecimalEquals(flow.getValue(5), "0.75"); assertDecimalEquals(flow.getValue(6), "0.75"); assertDecimalEquals(flow.getValue(7), "1.125"); assertDecimalEquals(flow.getValue(8), "0.45"); }
@Override public Decimal getValue(int index) { return values.get(index); }
CashFlow implements Indicator<Decimal> { @Override public Decimal getValue(int index) { return values.get(index); } }
CashFlow implements Indicator<Decimal> { @Override public Decimal getValue(int index) { return values.get(index); } CashFlow(TimeSeries timeSeries, Trade trade);  CashFlow(TimeSeries timeSeries, TradingRecord tradingRecord); }
CashFlow implements Indicator<Decimal> { @Override public Decimal getValue(int index) { return values.get(index); } CashFlow(TimeSeries timeSeries, Trade trade);  CashFlow(TimeSeries timeSeries, TradingRecord tradingRecord); @Override Decimal getValue(int index); @Override TimeSeries getTimeSeries(); int getSize(); }
CashFlow implements Indicator<Decimal> { @Override public Decimal getValue(int index) { return values.get(index); } CashFlow(TimeSeries timeSeries, Trade trade);  CashFlow(TimeSeries timeSeries, TradingRecord tradingRecord); @Override Decimal getValue(int index); @Override TimeSeries getTimeSeries(); int getSize();  }