backtesting_from_live_saved_files - code refactoring
This commit is contained in:
parent
b01e4e3dbf
commit
913749c81b
@ -81,7 +81,7 @@ To save the models generated during a particular backtest so that you can start
|
||||
|
||||
### Backtest live models
|
||||
|
||||
FreqAI allow you to reuse ready models through the backtest parameter `--freqai-backtest-live-models`. This can be useful when you want to reuse models generated in dry/run for comparison or other study. For that, you must set `"purge_old_models"` to `True` in the config.
|
||||
FreqAI allow you to reuse ready models through the backtest parameter `--freqai-backtest-live-models`. This can be useful when you want to reuse models generated in dry/run for comparison or other study. For that, you must set `"purge_old_models"` to `False` in the config.
|
||||
|
||||
The `--timerange` parameter must not be informed, as it will be automatically calculated through the training end dates of the models.
|
||||
|
||||
|
@ -1519,16 +1519,14 @@ class FreqaiDataKitchen:
|
||||
|
||||
pair_path = pair.split(":")[0].replace("/", "_").lower()
|
||||
file_name = f"live_backtesting_{pair_path}.feather"
|
||||
path_to_live_backtesting_file = Path(self.full_path /
|
||||
self.backtesting_live_model_path = Path(self.full_path /
|
||||
self.backtesting_live_model_folder_path /
|
||||
file_name)
|
||||
path_to_live_backtesting_bkp_file = Path(self.full_path /
|
||||
self.backtesting_live_model_bkp_path = Path(
|
||||
self.full_path /
|
||||
self.backtesting_live_model_folder_path /
|
||||
file_name.replace(".feather", ".backup.feather"))
|
||||
|
||||
self.backtesting_live_model_path = path_to_live_backtesting_file
|
||||
self.backtesting_live_model_bkp_path = path_to_live_backtesting_bkp_file
|
||||
|
||||
def save_backtesting_live_dataframe(
|
||||
self, dataframe: DataFrame, pair: str
|
||||
) -> None:
|
||||
@ -1566,15 +1564,12 @@ class FreqaiDataKitchen:
|
||||
return saved_dataframe
|
||||
else:
|
||||
raise OperationalException(
|
||||
"Saved pair file not found"
|
||||
"Saved live backtesting dataframe file not found."
|
||||
)
|
||||
|
||||
def get_timerange_from_backtesting_live_dataframe(
|
||||
self) -> TimeRange:
|
||||
def get_timerange_from_backtesting_live_dataframe(self) -> TimeRange:
|
||||
"""
|
||||
Returns timerange information based on a FreqAI model directory
|
||||
:param models_path: FreqAI model path
|
||||
|
||||
Returns timerange information based on live backtesting dataframe file
|
||||
:return: timerange calculated from saved live data
|
||||
"""
|
||||
all_assets_start_dates = []
|
||||
@ -1592,7 +1587,7 @@ class FreqaiDataKitchen:
|
||||
all_assets_start_dates.append(saved_dataframe.date.min())
|
||||
all_assets_end_dates.append(saved_dataframe.date.max())
|
||||
start_date = min(all_assets_start_dates)
|
||||
end_date = min(all_assets_end_dates)
|
||||
end_date = max(all_assets_end_dates)
|
||||
# add 1 day to string timerange to ensure BT module will load all dataframe data
|
||||
end_date = end_date + timedelta(days=1)
|
||||
backtesting_timerange = TimeRange(
|
||||
|
@ -334,8 +334,6 @@ class IFreqaiModel(ABC):
|
||||
FreqaiDataKitchen = Data management/analysis tool associated to present pair only
|
||||
"""
|
||||
pair = metadata["pair"]
|
||||
dk.return_dataframe = dataframe
|
||||
|
||||
dk.return_dataframe = dataframe
|
||||
self.dk.set_backtesting_live_dataframe_path(pair)
|
||||
saved_dataframe = self.dk.get_backtesting_live_dataframe()
|
||||
|
Loading…
Reference in New Issue
Block a user