@Test public void cashFlowWithSellAndBuyOrders() { BarSeries sampleBarSeries = new MockBarSeries(numFunction, 2, 1, 3, 5, 6, 3, 20); TradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, sampleBarSeries), Order.sellAt(1, sampleBarSeries), Order.buyAt(3, sampleBarSeries), Order.sellAt(4, sampleBarSeries), Order.sellAt(5, sampleBarSeries), Order.buyAt(6, sampleBarSeries)); CashFlow cashFlow = new CashFlow(sampleBarSeries, tradingRecord); assertNumEquals(1, cashFlow.getValue(0)); assertNumEquals("0.5", cashFlow.getValue(1)); assertNumEquals("0.5", cashFlow.getValue(2)); assertNumEquals("0.5", cashFlow.getValue(3)); assertNumEquals("0.6", cashFlow.getValue(4)); assertNumEquals("0.6", cashFlow.getValue(5)); assertNumEquals("-2.8", cashFlow.getValue(6)); }
@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();  }