For backtesting purposes, historical data (candles) are needed. These are fetched through an API and stored locally.
However, this data must match the data needed for a backtest exactly in terms of pair, timeframe and date.
Currently, when the data does not match your backtest needs (lets say that you are backtesting 1 day longer then you have data), the engine will erase all data it has, and download everything again.
This costs time and resources, so a check needs to be implemented that complements the existing data (if possible) so that it does matches the data needed for the backtest.
In other words, if the stored data is the correct pair and timeframe, but it is missing a few days/weeks/month, download only that period, instead of the full period
This functionality should be implemented somewhere here:
|
if not self.check_for_datafile_existence(pair, self.config['timeframe']): |
|
# datafile doesn't exist. Start downloading data, create datafile |
|
print("[INFO] Did not find datafile for %s" % pair) |
|
self.history_data[pair] = [] |
|
self.download_data_for_pair(pair, True) |
|
elif self.does_datafile_cover_backtesting_period(pair, self.config['timeframe']): |
|
# load data from datafile instead of exchange |
|
self.history_data[pair] = [] |
|
self.read_data_from_datafile(pair, self.config['timeframe']) |
|
elif not self.does_datafile_cover_backtesting_period(pair, self.config['timeframe']): |
|
# remove file, download data from exchange, create new datafile |
|
self.history_data[pair] = [] |
|
if self.check_for_datafile_existence(pair, self.config['timeframe']): |
|
self.delete_file(pair, self.config['timeframe']) |
|
self.download_data_for_pair(pair, True) |
Roughly the following checks should be followed: is there data -> is it for the right pair -> is it for the right timeframe -> does it covers the backtesting period -> download missing candles only