@Test public void test() { WalkForward.main(null); }
public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); List<BarSeries> subseries = splitSeries(series, Duration.ofHours(6), Duration.ofDays(7)); Map<Strategy, String> strategies = buildStrategiesMap(series); AnalysisCriterion profitCriterion = new TotalProfitCriterion(); for (BarSeries slice : subseries) { System.out.println("Sub-series: " + slice.getSeriesPeriodDescription()); BarSeriesManager sliceManager = new BarSeriesManager(slice); for (Map.Entry<Strategy, String> entry : strategies.entrySet()) { Strategy strategy = entry.getKey(); String name = entry.getValue(); TradingRecord tradingRecord = sliceManager.run(strategy); Num profit = profitCriterion.calculate(slice, tradingRecord); System.out.println("\tProfit for " + name + ": " + profit); } Strategy bestStrategy = profitCriterion.chooseBest(sliceManager, new ArrayList<Strategy>(strategies.keySet())); System.out.println("\t\t--> Best strategy: " + strategies.get(bestStrategy) + "\n"); } }
WalkForward { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); List<BarSeries> subseries = splitSeries(series, Duration.ofHours(6), Duration.ofDays(7)); Map<Strategy, String> strategies = buildStrategiesMap(series); AnalysisCriterion profitCriterion = new TotalProfitCriterion(); for (BarSeries slice : subseries) { System.out.println("Sub-series: " + slice.getSeriesPeriodDescription()); BarSeriesManager sliceManager = new BarSeriesManager(slice); for (Map.Entry<Strategy, String> entry : strategies.entrySet()) { Strategy strategy = entry.getKey(); String name = entry.getValue(); TradingRecord tradingRecord = sliceManager.run(strategy); Num profit = profitCriterion.calculate(slice, tradingRecord); System.out.println("\tProfit for " + name + ": " + profit); } Strategy bestStrategy = profitCriterion.chooseBest(sliceManager, new ArrayList<Strategy>(strategies.keySet())); System.out.println("\t\t--> Best strategy: " + strategies.get(bestStrategy) + "\n"); } } }
WalkForward { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); List<BarSeries> subseries = splitSeries(series, Duration.ofHours(6), Duration.ofDays(7)); Map<Strategy, String> strategies = buildStrategiesMap(series); AnalysisCriterion profitCriterion = new TotalProfitCriterion(); for (BarSeries slice : subseries) { System.out.println("Sub-series: " + slice.getSeriesPeriodDescription()); BarSeriesManager sliceManager = new BarSeriesManager(slice); for (Map.Entry<Strategy, String> entry : strategies.entrySet()) { Strategy strategy = entry.getKey(); String name = entry.getValue(); TradingRecord tradingRecord = sliceManager.run(strategy); Num profit = profitCriterion.calculate(slice, tradingRecord); System.out.println("\tProfit for " + name + ": " + profit); } Strategy bestStrategy = profitCriterion.chooseBest(sliceManager, new ArrayList<Strategy>(strategies.keySet())); System.out.println("\t\t--> Best strategy: " + strategies.get(bestStrategy) + "\n"); } }  }
WalkForward { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); List<BarSeries> subseries = splitSeries(series, Duration.ofHours(6), Duration.ofDays(7)); Map<Strategy, String> strategies = buildStrategiesMap(series); AnalysisCriterion profitCriterion = new TotalProfitCriterion(); for (BarSeries slice : subseries) { System.out.println("Sub-series: " + slice.getSeriesPeriodDescription()); BarSeriesManager sliceManager = new BarSeriesManager(slice); for (Map.Entry<Strategy, String> entry : strategies.entrySet()) { Strategy strategy = entry.getKey(); String name = entry.getValue(); TradingRecord tradingRecord = sliceManager.run(strategy); Num profit = profitCriterion.calculate(slice, tradingRecord); System.out.println("\tProfit for " + name + ": " + profit); } Strategy bestStrategy = profitCriterion.chooseBest(sliceManager, new ArrayList<Strategy>(strategies.keySet())); System.out.println("\t\t--> Best strategy: " + strategies.get(bestStrategy) + "\n"); } }  static List<Integer> getSplitBeginIndexes(BarSeries series, Duration splitDuration); static BarSeries subseries(BarSeries series, int beginIndex, Duration duration); static List<BarSeries> splitSeries(BarSeries series, Duration splitDuration, Duration sliceDuration); static Map<Strategy, String> buildStrategiesMap(BarSeries series); static void main(String[] args); }
WalkForward { public static void main(String[] args) { BarSeries series = CsvTradesLoader.loadBitstampSeries(); List<BarSeries> subseries = splitSeries(series, Duration.ofHours(6), Duration.ofDays(7)); Map<Strategy, String> strategies = buildStrategiesMap(series); AnalysisCriterion profitCriterion = new TotalProfitCriterion(); for (BarSeries slice : subseries) { System.out.println("Sub-series: " + slice.getSeriesPeriodDescription()); BarSeriesManager sliceManager = new BarSeriesManager(slice); for (Map.Entry<Strategy, String> entry : strategies.entrySet()) { Strategy strategy = entry.getKey(); String name = entry.getValue(); TradingRecord tradingRecord = sliceManager.run(strategy); Num profit = profitCriterion.calculate(slice, tradingRecord); System.out.println("\tProfit for " + name + ": " + profit); } Strategy bestStrategy = profitCriterion.chooseBest(sliceManager, new ArrayList<Strategy>(strategies.keySet())); System.out.println("\t\t--> Best strategy: " + strategies.get(bestStrategy) + "\n"); } }  static List<Integer> getSplitBeginIndexes(BarSeries series, Duration splitDuration); static BarSeries subseries(BarSeries series, int beginIndex, Duration duration); static List<BarSeries> splitSeries(BarSeries series, Duration splitDuration, Duration sliceDuration); static Map<Strategy, String> buildStrategiesMap(BarSeries series); static void main(String[] args);  }