@Test public void calculateSellTrade() { int holdingPeriod = 2; Order entry = Order.sellAt(0, DoubleNum.valueOf(100), DoubleNum.valueOf(1), transactionModel); Order exit = Order.buyAt(holdingPeriod, DoubleNum.valueOf(110), DoubleNum.valueOf(1), transactionModel); Trade trade = new Trade(entry, exit, transactionModel, new ZeroCostModel()); Num costFromBuy = entry.getCost(); Num costFromSell = exit.getCost(); Num costsFromModel = transactionModel.calculate(trade, holdingPeriod); assertNumEquals(costsFromModel, costFromBuy.plus(costFromSell)); assertNumEquals(costsFromModel, DoubleNum.valueOf(2.1)); assertNumEquals(costFromBuy, DoubleNum.valueOf(1)); }
public Num calculate(Trade trade, int currentIndex) { return this.calculate(trade); }
LinearTransactionCostModel implements CostModel { public Num calculate(Trade trade, int currentIndex) { return this.calculate(trade); } }
LinearTransactionCostModel implements CostModel { public Num calculate(Trade trade, int currentIndex) { return this.calculate(trade); } LinearTransactionCostModel(double feePerTrade); }
LinearTransactionCostModel implements CostModel { public Num calculate(Trade trade, int currentIndex) { return this.calculate(trade); } LinearTransactionCostModel(double feePerTrade); Num calculate(Trade trade, int currentIndex); Num calculate(Trade trade); Num calculate(Num price, Num amount); boolean equals(CostModel otherModel); }
LinearTransactionCostModel implements CostModel { public Num calculate(Trade trade, int currentIndex) { return this.calculate(trade); } LinearTransactionCostModel(double feePerTrade); Num calculate(Trade trade, int currentIndex); Num calculate(Trade trade); Num calculate(Num price, Num amount); boolean equals(CostModel otherModel);  }