add priority metadata to pairs to avoid a sync of train time + train period

This commit is contained in:
robcaulk 2022-05-24 12:58:53 +02:00
parent 059c285425
commit 255d35976e
3 changed files with 25 additions and 2 deletions

View File

@ -56,5 +56,18 @@ class FreqaiDataDrawer:
model_filename = self.pair_dict[metadata['pair']]['model_filename'] = ''
coin_first = self.pair_dict[metadata['pair']]['first'] = True
trained_timestamp = self.pair_dict[metadata['pair']]['trained_timestamp'] = 0
self.pair_dict[metadata['pair']]['priority'] = 1
return model_filename, trained_timestamp, coin_first
def set_pair_dict_info(self, metadata: dict) -> None:
pair_in_dict = self.pair_dict.get(metadata['pair'])
if pair_in_dict:
return
else:
self.pair_dict[metadata['pair']] = {}
self.pair_dict[metadata['pair']]['model_filename'] = ''
self.pair_dict[metadata['pair']]['first'] = True
self.pair_dict[metadata['pair']]['trained_timestamp'] = 0
self.pair_dict[metadata['pair']]['priority'] = 1
return

View File

@ -109,7 +109,10 @@ class IFreqaiModel(ABC):
# FreqaiDataKitchen is reinstantiated for each coin
if self.live:
if not self.training_on_separate_thread:
self.data_drawer.set_pair_dict_info(metadata)
if (not self.training_on_separate_thread and
self.data_drawer.pair_dict[metadata['pair']]['priority'] == 1):
self.dh = FreqaiDataKitchen(self.config, self.data_drawer,
self.live, metadata["pair"])
dh = self.start_live(dataframe, metadata, strategy, self.dh)
@ -212,6 +215,7 @@ class IFreqaiModel(ABC):
else:
logger.info("FreqAI training a new model on background thread.")
self.data_drawer.pair_dict[metadata['pair']]['priority'] = 1
self.model = dh.load_data(coin=metadata['pair'])
@ -319,6 +323,9 @@ class IFreqaiModel(ABC):
dh.set_new_model_names(metadata, new_trained_timerange)
# set this coin to lower priority to allow other coins in white list to get trained
self.data_drawer.pair_dict[metadata['pair']]['priority'] = 0
dh.save_data(self.model, coin=metadata['pair'])
self.training_on_separate_thread = False
@ -344,6 +351,7 @@ class IFreqaiModel(ABC):
dh.set_new_model_names(metadata, new_trained_timerange)
self.data_drawer.pair_dict[metadata['pair']]['first'] = False
dh.save_data(self.model, coin=metadata['pair'])
self.retrain = False

View File

@ -51,7 +51,9 @@ class CatboostPredictionModel(IFreqaiModel):
:returns:
:model: Trained model which can be used to inference (self.predict)
"""
logger.info("--------------------Starting training--------------------")
logger.info('--------------------Starting training'
f'{metadata["pair"]} --------------------')
# create the full feature list based on user config info
dh.training_features_list = dh.find_features(unfiltered_dataframe)