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

Figure 5 is the spearmint configuration file and can be downloaded here :

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

 

quant@QUANT2-> pwd

/home/quant/spearmint-master/spearmint/examples/BBANDS

 

quant@QUANT2-> cat config.pb

language: PYTHON

name:     "BBANDS"

 

variable {

 name: "timeperiod"

 type: INT

 size: 1

 min:  10

 max:  25

}

 

variable {

 name: "nbdevup"

 type: FLOAT

 size: 1

 min:  0.50

 max:  2.50

}

 

variable {

 name: "nbdevdn"

 type: FLOAT

 size: 1

 min:  0.50

 max:  2.50

}

 

 

Figure 5 : config.pb – spearmint experiment configuration file

 

Figure 5 shows the language, file name and defines the three parameters we wish to explore.  Note that we can define both integers (line 10, timeperiod) as well as floating point numbers (nbdevup and nbdevdn) and constrain the search.

 

Finally, we must start the spearmint optimizer with the script in Figure 6 which can be downloaded here .

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

quant@QUANT2-> pwd

/home/quant/spearmint-master/spearmint/examples/BBANDS

 

quant@QUANT2-> cat RunOptimizer.sh

#!/bin/bash

HOMX=/home/quant

cd $HOMX/spearmint-master/spearmint/bin

./spearmint -w                  \

   ../examples/BBANDS/config.pb \

   --driver=local               \

   --port=9999                  \

   --max-concurrent=3           \

   --method=RandomChooser      \

   --method-args=noiseless=1

exit

 

Figure 6 : RunOptimizer.sh script to run experiments

 

The script in figure 6 will start the optimizer.  You connect to the spearmint monitor using a web browser http://localhost:9999 .  On my platform, and with this algorithm, I had the best success using “method=RandomChooser” and reasonable run times with 3 concurrent experiments at once.

 

Click Part 4 to see the results of the optimizer.  Or back to Part 1 or Part 2 .