@Test public void test() { StrategyAnalysis.main(null); }
public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = MovingMomentumStrategy.buildStrategy(series); BarSeriesManager seriesManager = new BarSeriesManager(series); TradingRecord tradingRecord = seriesManager.run(strategy); TotalProfitCriterion totalProfit = new TotalProfitCriterion(); System.out.println("Total profit: " + totalProfit.calculate(series, tradingRecord)); System.out.println("Number of bars: " + new NumberOfBarsCriterion().calculate(series, tradingRecord)); System.out .println("Average profit (per bar): " + new AverageProfitCriterion().calculate(series, tradingRecord)); System.out.println("Number of trades: " + new NumberOfTradesCriterion().calculate(series, tradingRecord)); System.out.println( "Profitable trades ratio: " + new AverageProfitableTradesCriterion().calculate(series, tradingRecord)); System.out.println("Maximum drawdown: " + new MaximumDrawdownCriterion().calculate(series, tradingRecord)); System.out.println("Reward-risk ratio: " + new RewardRiskRatioCriterion().calculate(series, tradingRecord)); System.out.println("Total transaction cost (from $1000): " + new LinearTransactionCostCriterion(1000, 0.005).calculate(series, tradingRecord)); System.out.println("Buy-and-hold: " + new BuyAndHoldCriterion().calculate(series, tradingRecord)); System.out.println("Custom strategy profit vs buy-and-hold strategy profit: " + new VersusBuyAndHoldCriterion(totalProfit).calculate(series, tradingRecord)); }
StrategyAnalysis { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = MovingMomentumStrategy.buildStrategy(series); BarSeriesManager seriesManager = new BarSeriesManager(series); TradingRecord tradingRecord = seriesManager.run(strategy); TotalProfitCriterion totalProfit = new TotalProfitCriterion(); System.out.println("Total profit: " + totalProfit.calculate(series, tradingRecord)); System.out.println("Number of bars: " + new NumberOfBarsCriterion().calculate(series, tradingRecord)); System.out .println("Average profit (per bar): " + new AverageProfitCriterion().calculate(series, tradingRecord)); System.out.println("Number of trades: " + new NumberOfTradesCriterion().calculate(series, tradingRecord)); System.out.println( "Profitable trades ratio: " + new AverageProfitableTradesCriterion().calculate(series, tradingRecord)); System.out.println("Maximum drawdown: " + new MaximumDrawdownCriterion().calculate(series, tradingRecord)); System.out.println("Reward-risk ratio: " + new RewardRiskRatioCriterion().calculate(series, tradingRecord)); System.out.println("Total transaction cost (from $1000): " + new LinearTransactionCostCriterion(1000, 0.005).calculate(series, tradingRecord)); System.out.println("Buy-and-hold: " + new BuyAndHoldCriterion().calculate(series, tradingRecord)); System.out.println("Custom strategy profit vs buy-and-hold strategy profit: " + new VersusBuyAndHoldCriterion(totalProfit).calculate(series, tradingRecord)); } }
StrategyAnalysis { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = MovingMomentumStrategy.buildStrategy(series); BarSeriesManager seriesManager = new BarSeriesManager(series); TradingRecord tradingRecord = seriesManager.run(strategy); TotalProfitCriterion totalProfit = new TotalProfitCriterion(); System.out.println("Total profit: " + totalProfit.calculate(series, tradingRecord)); System.out.println("Number of bars: " + new NumberOfBarsCriterion().calculate(series, tradingRecord)); System.out .println("Average profit (per bar): " + new AverageProfitCriterion().calculate(series, tradingRecord)); System.out.println("Number of trades: " + new NumberOfTradesCriterion().calculate(series, tradingRecord)); System.out.println( "Profitable trades ratio: " + new AverageProfitableTradesCriterion().calculate(series, tradingRecord)); System.out.println("Maximum drawdown: " + new MaximumDrawdownCriterion().calculate(series, tradingRecord)); System.out.println("Reward-risk ratio: " + new RewardRiskRatioCriterion().calculate(series, tradingRecord)); System.out.println("Total transaction cost (from $1000): " + new LinearTransactionCostCriterion(1000, 0.005).calculate(series, tradingRecord)); System.out.println("Buy-and-hold: " + new BuyAndHoldCriterion().calculate(series, tradingRecord)); System.out.println("Custom strategy profit vs buy-and-hold strategy profit: " + new VersusBuyAndHoldCriterion(totalProfit).calculate(series, tradingRecord)); }  }
StrategyAnalysis { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = MovingMomentumStrategy.buildStrategy(series); BarSeriesManager seriesManager = new BarSeriesManager(series); TradingRecord tradingRecord = seriesManager.run(strategy); TotalProfitCriterion totalProfit = new TotalProfitCriterion(); System.out.println("Total profit: " + totalProfit.calculate(series, tradingRecord)); System.out.println("Number of bars: " + new NumberOfBarsCriterion().calculate(series, tradingRecord)); System.out .println("Average profit (per bar): " + new AverageProfitCriterion().calculate(series, tradingRecord)); System.out.println("Number of trades: " + new NumberOfTradesCriterion().calculate(series, tradingRecord)); System.out.println( "Profitable trades ratio: " + new AverageProfitableTradesCriterion().calculate(series, tradingRecord)); System.out.println("Maximum drawdown: " + new MaximumDrawdownCriterion().calculate(series, tradingRecord)); System.out.println("Reward-risk ratio: " + new RewardRiskRatioCriterion().calculate(series, tradingRecord)); System.out.println("Total transaction cost (from $1000): " + new LinearTransactionCostCriterion(1000, 0.005).calculate(series, tradingRecord)); System.out.println("Buy-and-hold: " + new BuyAndHoldCriterion().calculate(series, tradingRecord)); System.out.println("Custom strategy profit vs buy-and-hold strategy profit: " + new VersusBuyAndHoldCriterion(totalProfit).calculate(series, tradingRecord)); }  static void main(String[] args); }
StrategyAnalysis { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); Strategy strategy = MovingMomentumStrategy.buildStrategy(series); BarSeriesManager seriesManager = new BarSeriesManager(series); TradingRecord tradingRecord = seriesManager.run(strategy); TotalProfitCriterion totalProfit = new TotalProfitCriterion(); System.out.println("Total profit: " + totalProfit.calculate(series, tradingRecord)); System.out.println("Number of bars: " + new NumberOfBarsCriterion().calculate(series, tradingRecord)); System.out .println("Average profit (per bar): " + new AverageProfitCriterion().calculate(series, tradingRecord)); System.out.println("Number of trades: " + new NumberOfTradesCriterion().calculate(series, tradingRecord)); System.out.println( "Profitable trades ratio: " + new AverageProfitableTradesCriterion().calculate(series, tradingRecord)); System.out.println("Maximum drawdown: " + new MaximumDrawdownCriterion().calculate(series, tradingRecord)); System.out.println("Reward-risk ratio: " + new RewardRiskRatioCriterion().calculate(series, tradingRecord)); System.out.println("Total transaction cost (from $1000): " + new LinearTransactionCostCriterion(1000, 0.005).calculate(series, tradingRecord)); System.out.println("Buy-and-hold: " + new BuyAndHoldCriterion().calculate(series, tradingRecord)); System.out.println("Custom strategy profit vs buy-and-hold strategy profit: " + new VersusBuyAndHoldCriterion(totalProfit).calculate(series, tradingRecord)); }  static void main(String[] args);  }