@Test public void test() { TradeCost.main(null); }
public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = buildShortSellingMomentumStrategy(series); double feePerTrade = 0.0005; double borrowingFee = 0.00001; CostModel transactionCostModel = new LinearTransactionCostModel(feePerTrade); CostModel borrowingCostModel = new LinearBorrowingCostModel(borrowingFee); BarSeriesManager seriesManager = new BarSeriesManager(series, transactionCostModel, borrowingCostModel); Order.OrderType entryOrder = Order.OrderType.SELL; TradingRecord tradingRecord = seriesManager.run(strategy, entryOrder); DecimalFormat df = new DecimalFormat("##.##"); System.out.println("------------ Borrowing Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println( "Borrowing cost for " + df.format(trade.getExit().getIndex() - trade.getEntry().getIndex()) + " periods is: " + df.format(trade.getHoldingCost().doubleValue()))); System.out.println("------------ Transaction Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println("Transaction cost for selling: " + df.format(trade.getEntry().getCost().doubleValue()) + " -- Transaction cost for buying: " + df.format(trade.getExit().getCost().doubleValue()))); }
TradeCost { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = buildShortSellingMomentumStrategy(series); double feePerTrade = 0.0005; double borrowingFee = 0.00001; CostModel transactionCostModel = new LinearTransactionCostModel(feePerTrade); CostModel borrowingCostModel = new LinearBorrowingCostModel(borrowingFee); BarSeriesManager seriesManager = new BarSeriesManager(series, transactionCostModel, borrowingCostModel); Order.OrderType entryOrder = Order.OrderType.SELL; TradingRecord tradingRecord = seriesManager.run(strategy, entryOrder); DecimalFormat df = new DecimalFormat("##.##"); System.out.println("------------ Borrowing Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println( "Borrowing cost for " + df.format(trade.getExit().getIndex() - trade.getEntry().getIndex()) + " periods is: " + df.format(trade.getHoldingCost().doubleValue()))); System.out.println("------------ Transaction Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println("Transaction cost for selling: " + df.format(trade.getEntry().getCost().doubleValue()) + " -- Transaction cost for buying: " + df.format(trade.getExit().getCost().doubleValue()))); } }
TradeCost { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = buildShortSellingMomentumStrategy(series); double feePerTrade = 0.0005; double borrowingFee = 0.00001; CostModel transactionCostModel = new LinearTransactionCostModel(feePerTrade); CostModel borrowingCostModel = new LinearBorrowingCostModel(borrowingFee); BarSeriesManager seriesManager = new BarSeriesManager(series, transactionCostModel, borrowingCostModel); Order.OrderType entryOrder = Order.OrderType.SELL; TradingRecord tradingRecord = seriesManager.run(strategy, entryOrder); DecimalFormat df = new DecimalFormat("##.##"); System.out.println("------------ Borrowing Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println( "Borrowing cost for " + df.format(trade.getExit().getIndex() - trade.getEntry().getIndex()) + " periods is: " + df.format(trade.getHoldingCost().doubleValue()))); System.out.println("------------ Transaction Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println("Transaction cost for selling: " + df.format(trade.getEntry().getCost().doubleValue()) + " -- Transaction cost for buying: " + df.format(trade.getExit().getCost().doubleValue()))); }  }
TradeCost { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = buildShortSellingMomentumStrategy(series); double feePerTrade = 0.0005; double borrowingFee = 0.00001; CostModel transactionCostModel = new LinearTransactionCostModel(feePerTrade); CostModel borrowingCostModel = new LinearBorrowingCostModel(borrowingFee); BarSeriesManager seriesManager = new BarSeriesManager(series, transactionCostModel, borrowingCostModel); Order.OrderType entryOrder = Order.OrderType.SELL; TradingRecord tradingRecord = seriesManager.run(strategy, entryOrder); DecimalFormat df = new DecimalFormat("##.##"); System.out.println("------------ Borrowing Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println( "Borrowing cost for " + df.format(trade.getExit().getIndex() - trade.getEntry().getIndex()) + " periods is: " + df.format(trade.getHoldingCost().doubleValue()))); System.out.println("------------ Transaction Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println("Transaction cost for selling: " + df.format(trade.getEntry().getCost().doubleValue()) + " -- Transaction cost for buying: " + df.format(trade.getExit().getCost().doubleValue()))); }  static void main(String[] args); }
TradeCost { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = buildShortSellingMomentumStrategy(series); double feePerTrade = 0.0005; double borrowingFee = 0.00001; CostModel transactionCostModel = new LinearTransactionCostModel(feePerTrade); CostModel borrowingCostModel = new LinearBorrowingCostModel(borrowingFee); BarSeriesManager seriesManager = new BarSeriesManager(series, transactionCostModel, borrowingCostModel); Order.OrderType entryOrder = Order.OrderType.SELL; TradingRecord tradingRecord = seriesManager.run(strategy, entryOrder); DecimalFormat df = new DecimalFormat("##.##"); System.out.println("------------ Borrowing Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println( "Borrowing cost for " + df.format(trade.getExit().getIndex() - trade.getEntry().getIndex()) + " periods is: " + df.format(trade.getHoldingCost().doubleValue()))); System.out.println("------------ Transaction Costs ------------"); tradingRecord.getTrades() .forEach(trade -> System.out.println("Transaction cost for selling: " + df.format(trade.getEntry().getCost().doubleValue()) + " -- Transaction cost for buying: " + df.format(trade.getExit().getCost().doubleValue()))); }  static void main(String[] args);  }