From the course: Practical Python for Algorithmic Trading

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Optimizing strategy parameters

Optimizing strategy parameters

- [Instructor] In previous tutorials, we used the regression model within the investment strategy. As the regression model forecasts a numerical value, we need to set the limit above which when to buy the stock, or below the limit, when to sell the stock. We chose one and minus five respectively. But we could have written any value in this line of code. Instead of using random numbers, we should try a lot of them at once and optimize the results, to have the maximum returns. In the right table, you can see how we tried from zero to minus 10 in the limit sell, and from zero to 10 in the limit buy. From which we can clearly see that the best combination is limit buy zero and limit sell minus one. So now it's time to uncover the lines of code that will get us to this nice table. Now the big question is, which are the lines of code that will optimize the backtesting strategy to get this nice table? Let's go with them…

Contents