@Test public void cashFlowValue() { BarSeries sampleBarSeries = new MockBarSeries(numFunction, 3d, 2d, 5d, 1000d, 5000d, 0.0001d, 4d, 7d, 6d, 7d, 8d, 5d, 6d); TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, sampleBarSeries), Order.sellAt(2, sampleBarSeries), Order.buyAt(6, sampleBarSeries), Order.sellAt(8, sampleBarSeries), Order.buyAt(9, sampleBarSeries), Order.sellAt(11, sampleBarSeries)); CashFlow cashFlow = new CashFlow(sampleBarSeries, tradingRecord); assertNumEquals(1, cashFlow.getValue(0)); assertNumEquals(2d / 3, cashFlow.getValue(1)); assertNumEquals(5d / 3, cashFlow.getValue(2)); assertNumEquals(5d / 3, cashFlow.getValue(3)); assertNumEquals(5d / 3, cashFlow.getValue(4)); assertNumEquals(5d / 3, cashFlow.getValue(5)); assertNumEquals(5d / 3, cashFlow.getValue(6)); assertNumEquals(5d / 3 * 7d / 4, cashFlow.getValue(7)); assertNumEquals(5d / 3 * 6d / 4, cashFlow.getValue(8)); assertNumEquals(5d / 3 * 6d / 4, cashFlow.getValue(9)); assertNumEquals(5d / 3 * 6d / 4 * 8d / 7, cashFlow.getValue(10)); assertNumEquals(5d / 3 * 6d / 4 * 5d / 7, cashFlow.getValue(11)); assertNumEquals(5d / 3 * 6d / 4 * 5d / 7, cashFlow.getValue(12)); sampleBarSeries = new MockBarSeries(numFunction, 5d, 6d, 3d, 7d, 8d, 6d, 10d, 15d, 6d); tradingRecord = new BaseTradingRecord(Order.buyAt(4, sampleBarSeries), Order.sellAt(5, sampleBarSeries), Order.buyAt(6, sampleBarSeries), Order.sellAt(8, sampleBarSeries)); CashFlow flow = new CashFlow(sampleBarSeries, tradingRecord); assertNumEquals(1, flow.getValue(0)); assertNumEquals(1, flow.getValue(1)); assertNumEquals(1, flow.getValue(2)); assertNumEquals(1, flow.getValue(3)); assertNumEquals(1, flow.getValue(4)); assertNumEquals("0.75", flow.getValue(5)); assertNumEquals("0.75", flow.getValue(6)); assertNumEquals("1.125", flow.getValue(7)); assertNumEquals("0.45", flow.getValue(8)); }
@Override public Num getValue(int index) { return values.get(index); }
CashFlow implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } }
CashFlow implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } CashFlow(BarSeries barSeries, Trade trade);  CashFlow(BarSeries barSeries, TradingRecord tradingRecord);  CashFlow(BarSeries barSeries, TradingRecord tradingRecord, int finalIndex); }
CashFlow implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } CashFlow(BarSeries barSeries, Trade trade);  CashFlow(BarSeries barSeries, TradingRecord tradingRecord);  CashFlow(BarSeries barSeries, TradingRecord tradingRecord, int finalIndex); @Override Num getValue(int index); @Override BarSeries getBarSeries(); @Override Num numOf(Number number); int getSize(); }
CashFlow implements Indicator<Num> { @Override public Num getValue(int index) { return values.get(index); } CashFlow(BarSeries barSeries, Trade trade);  CashFlow(BarSeries barSeries, TradingRecord tradingRecord);  CashFlow(BarSeries barSeries, TradingRecord tradingRecord, int finalIndex); @Override Num getValue(int index); @Override BarSeries getBarSeries(); @Override Num numOf(Number number); int getSize();  }