archive config to the model folder, filter out features before returning dataframe to strategy (to alleviate frequi issues)`
This commit is contained in:
parent
051b99791d
commit
68bafa9517
@ -2,7 +2,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import gc
|
import gc
|
||||||
import logging
|
import logging
|
||||||
# import sys
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -109,6 +109,7 @@ class IFreqaiModel(ABC):
|
|||||||
logger.info(f'Training {len(self.dh.training_timeranges)} timeranges')
|
logger.info(f'Training {len(self.dh.training_timeranges)} timeranges')
|
||||||
dh = self.start_backtesting(dataframe, metadata, self.dh)
|
dh = self.start_backtesting(dataframe, metadata, self.dh)
|
||||||
|
|
||||||
|
dataframe = self.remove_features_from_df(dataframe)
|
||||||
return self.return_values(dataframe, dh)
|
return self.return_values(dataframe, dh)
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
@ -413,6 +414,18 @@ class IFreqaiModel(ABC):
|
|||||||
self.full_path = Path(self.config['user_data_dir'] /
|
self.full_path = Path(self.config['user_data_dir'] /
|
||||||
"models" /
|
"models" /
|
||||||
str(self.freqai_info.get('identifier')))
|
str(self.freqai_info.get('identifier')))
|
||||||
|
self.full_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
shutil.copy(self.config['config_files'][0], Path(self.full_path,
|
||||||
|
self.config['config_files'][0]))
|
||||||
|
|
||||||
|
def remove_features_from_df(self, dataframe: DataFrame) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Remove the features from the dataframe before returning it to strategy. This keeps it
|
||||||
|
compact for Frequi purposes.
|
||||||
|
"""
|
||||||
|
to_keep = [col for col in dataframe.columns
|
||||||
|
if not col.startswith('%') or col.startswith('%%')]
|
||||||
|
return dataframe[to_keep]
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
def retrain_model_on_separate_thread(self, new_trained_timerange: TimeRange, pair: str,
|
def retrain_model_on_separate_thread(self, new_trained_timerange: TimeRange, pair: str,
|
||||||
|
Loading…
Reference in New Issue
Block a user