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

The result of backtesting 30 years is different from 5 years? #159

Open
jacktang opened this issue Jun 3, 2024 · 5 comments
Open

The result of backtesting 30 years is different from 5 years? #159

jacktang opened this issue Jun 3, 2024 · 5 comments

Comments

@jacktang
Copy link

jacktang commented Jun 3, 2024

Hello, I play the etf demo and change the backtest_many code as below (for 5 years time window) since my laptop is not very high performance.

ress = sim.backtest_many(
    [make_policy(*key) for key in keys], parallel=True, start_time=pd.Timestamp.today() - pd.Timedelta(f'{365.24*5}d'))

And the plots

image

And the original one for around 30 years time window

image

The portfolio value trend is very similar, but the largest 7 assets are quite different. Especially for cash. Can you explain why it changes so much? Thanks!

@enzbus
Copy link
Collaborator

enzbus commented Jun 4, 2024

That's a good question, I hope it's not because Yahoo Finance data has changed in the meantime. Can you run the whole thing to try (it's monthly re-sampled, so it shouldn't be too bad). In general every back-test is path dependent so it will change based on the starting conditions, but this does seem like a large difference.

@jacktang
Copy link
Author

jacktang commented Jun 4, 2024

@enzbus I run the demo with 30 years time window, and the result is almost the same with the example page, below is the largest_growth_figure

image

@enzbus
Copy link
Collaborator

enzbus commented Jun 4, 2024

Yeah, if read the code carefully you'll see that example actually runs many back-test sweeping over hyper-parameters, so each one will have different allocations.

@jacktang
Copy link
Author

jacktang commented Jun 4, 2024

It is interesting :) I'd like to read the code deeply. BTW, is there any verbose option for debugging or output more detail logging?

@enzbus
Copy link
Collaborator

enzbus commented Jun 4, 2024

Yes, adding this two lines at the start should suffice:

import logging
logging.basicConfig(level='INFO')

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