Quantopian zipline trading algorithm parameter optimization with Spearmint Bayesian Optimizer - Part 4

After about 90 minutes, spearmint appears to have found a pretty optimial solution as shown in Figure 7.

The best results found were :

   name: "timeperiod" int_val: 16

   name: "nbdevup" dbl_val: 1.81860351562

   name: "nbdevdn" dbl_val: 1.46997070312

 

We copy these results to the Quantopian algorithm (Figure 1) and run a backtest over the same period:

 

Optimized algo as run on Quantopian

 

The Quantopian backtest results of the optimized algorithm – 19.2% return over 12 months - are shown above.  The Sharpe ratio is an acceptable 1.77 with positive alpha (0.14). 

 

However, we caution again that this is the result of curve fitting.  Using different equities or different time periods would likely give disappointing results.  We have only efficiently found the optimal parameters for this particular combination of equity (SPY) and time period (2014).

 

Quantopian (and zipline) have many built-in metrics to show algorithm performance.  Figure 9 details a rolling 3 month return which shows the return of the optimized algorithm versus the benchmark.  The objective function that we used was to maximize the overall return.  With only minor code changes, a different objective could be selected.

 

Click Part 5 to read conclusions and next steps.  Or, back to Part 1 or Part 3 .