@Test public void calculateSellTrade() { int holdingPeriod = 2; Order entry = Order.sellAt(0, DoubleNum.valueOf(100), DoubleNum.valueOf(1)); Order exit = Order.buyAt(holdingPeriod, DoubleNum.valueOf(110), DoubleNum.valueOf(1)); Trade trade = new Trade(entry, exit, new ZeroCostModel(), borrowingModel); Num costsFromTrade = trade.getHoldingCost(); Num costsFromModel = borrowingModel.calculate(trade, holdingPeriod); assertNumEquals(costsFromModel, costsFromTrade); assertNumEquals(costsFromModel, DoubleNum.valueOf(2)); }
public Num calculate(Num price, Num amount) { return price.numOf(0); }
LinearBorrowingCostModel implements CostModel { public Num calculate(Num price, Num amount) { return price.numOf(0); } }
LinearBorrowingCostModel implements CostModel { public Num calculate(Num price, Num amount) { return price.numOf(0); } LinearBorrowingCostModel(double feePerPeriod); }
LinearBorrowingCostModel implements CostModel { public Num calculate(Num price, Num amount) { return price.numOf(0); } LinearBorrowingCostModel(double feePerPeriod); Num calculate(Num price, Num amount); Num calculate(Trade trade); Num calculate(Trade trade, int currentIndex); boolean equals(CostModel otherModel); }
LinearBorrowingCostModel implements CostModel { public Num calculate(Num price, Num amount) { return price.numOf(0); } LinearBorrowingCostModel(double feePerPeriod); Num calculate(Num price, Num amount); Num calculate(Trade trade); Num calculate(Trade trade, int currentIndex); boolean equals(CostModel otherModel);  }