Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Walkforward questions #125

Closed
tsunamilx opened this issue May 29, 2024 · 1 comment
Closed

Walkforward questions #125

tsunamilx opened this issue May 29, 2024 · 1 comment

Comments

@tsunamilx
Copy link

tsunamilx commented May 29, 2024

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.

@edtechre
Copy link
Owner

edtechre commented Jun 3, 2024

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!

@edtechre edtechre closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants