edtechre / pybroker

Algorithmic Trading in Python with Machine Learning

Home Page:https://www.pybroker.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Walkforward questions

tsunamilx opened this issue · comments

Instead of "divided into windows number of equal sized time windows", is it possible to define a size for each window (e.g. a window for 6 months)?

And how can I integrate my custom made algo optimization with the walkforward method?

I have custom made trading strategy (strategy that basically outputs buy/sell signals) and I am using optuna (https://optuna.org/) to optimize the parameters for my strategy.

Now I'd like to backtest this:

  • for a window of 6 months data, run the optimization to get the "best" parameters and use them in my strategy for the next month
  • repeat every month till end

Basically like this (very similar to the walkforward method):
| 6 months : optimization | 1 month : strategy |
--------| 6 months : optimization | 1 month : strategy |
----------------| 6 months : optimization | 1 month : strategy |

Please advice.
Thanks.

Hi @tsunamilx,

Instead of "divided into windows number of equal sized time windows", is it possible to define a size for each window (e.g. a window for 6 months)?

No, but you can do the equivalent by using the number of windows you want for a chosen date range.

I have custom made trading strategy (strategy that basically outputs buy/sell signals) and I am using optuna (https://optuna.org/) to optimize the parameters for my strategy.

Now I'd like to backtest this:

for a window of 6 months data, run the optimization to get the "best" parameters and use them in my strategy for the next month
repeat every month till end

Looking at Optuna, you should be able to run your strategy in an objective function, and then return the metric from TestResult#metrics that you want to optimize on. You can use pyb.param to run your strategy with different param values.

Let me know if that helps!