ML backtest future dates #153
Replies: 1 comment
-
Managed to skip any training or testing on tickers with no samples, works ok |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When the test hits a stock where the start date is later than I have set the system throws an error and am unsure how to get around it as in a real trading situation new stocks would fall in to my criteria as they are listed. The test runs fine until it hits a ticker that has a later start date and maybe doesn't have the features available at that point, for example a moving average of 20 days isn't available on day one of the listing so when the model tries to train on it the data isn't there so would make sense to skip that stock, will try to build in as a filter to ensure enough data is present before anything hits the model.
I thought the warm up function would take care of this but doesn't seem to in this instance, or I'm doing it wrong - any help appreciated.
ValueError: Found array with 0 sample(s) (shape=(0, 32)) while a minimum of 1 is required by RandomForestClassifier.
start_date = '1/1/2014'
end_date = '1/9/2024'
Run the Walkforward Backtest
result = strategy.walkforward(
warmup=50,
windows=2,
train_size=0.5,
lookahead=1,
#calc_bootstrap=True,
disable_parallel=False
Beta Was this translation helpful? Give feedback.
All reactions