more cleanup

This commit is contained in:
robcaulk 2022-05-23 09:55:58 +02:00
parent 3587bd82e1
commit ee3cdd0ffe
2 changed files with 9 additions and 14 deletions

View File

@ -690,8 +690,7 @@ class FreqaiDataKitchen:
return full_timerange return full_timerange
def check_if_new_training_required(self, trained_timerange: TimeRange, def check_if_new_training_required(self, trained_timerange: TimeRange,
metadata: dict, metadata: dict) -> Tuple[bool, TimeRange]:
timestamp: int = 0) -> Tuple[bool, TimeRange, int]:
time = datetime.datetime.now(tz=datetime.timezone.utc).timestamp() time = datetime.datetime.now(tz=datetime.timezone.utc).timestamp()
@ -708,21 +707,19 @@ class FreqaiDataKitchen:
trained_timerange.stopts = int(time) trained_timerange.stopts = int(time)
retrain = True retrain = True
timestamp = trained_timerange.stopts
if retrain: if retrain:
coin, _ = metadata['pair'].split("/") coin, _ = metadata['pair'].split("/")
# set the new model_path # set the new model_path
self.model_path = Path(self.full_path / str("sub-train" + "-" + self.model_path = Path(self.full_path / str("sub-train" + "-" +
str(timestamp))) str(int(trained_timerange.stopts))))
self.model_filename = "cb_" + coin.lower() + "_" + str(timestamp) self.model_filename = "cb_" + coin.lower() + "_" + str(int(trained_timerange.stopts))
# this is not persistent at the moment TODO # this is not persistent at the moment TODO
self.freqai_config['live_trained_timerange'] = str(timestamp) self.freqai_config['live_trained_timerange'] = str(int(trained_timerange.stopts))
# enables persistence, but not fully implemented into save/load data yer # enables persistence, but not fully implemented into save/load data yer
self.data['live_trained_timerange'] = str(timestamp) self.data['live_trained_timerange'] = str(int(trained_timerange.stopts))
return retrain, trained_timerange, timestamp return retrain, trained_timerange
def download_new_data_for_retraining(self, timerange: TimeRange, metadata: dict) -> None: def download_new_data_for_retraining(self, timerange: TimeRange, metadata: dict) -> None:

View File

@ -64,7 +64,6 @@ class IFreqaiModel(ABC):
self.training_on_separate_thread = False self.training_on_separate_thread = False
self.retrain = False self.retrain = False
self.first = True self.first = True
self.timestamp = 0
if self.freqai_info['live_trained_timerange']: if self.freqai_info['live_trained_timerange']:
self.new_trained_timerange = TimeRange.parse_timerange( self.new_trained_timerange = TimeRange.parse_timerange(
self.freqai_info['live_trained_timerange']) self.freqai_info['live_trained_timerange'])
@ -157,10 +156,9 @@ class IFreqaiModel(ABC):
if not self.training_on_separate_thread: if not self.training_on_separate_thread:
# this will also prevent other pairs from trying to train simultaneously. # this will also prevent other pairs from trying to train simultaneously.
(self.retrain, (self.retrain,
self.new_trained_timerange) = self.dh.check_if_new_training_required(
self.new_trained_timerange, self.new_trained_timerange,
self.timestamp) = self.dh.check_if_new_training_required(self.new_trained_timerange, metadata)
metadata,
timestamp=self.timestamp)
else: else:
logger.info("FreqAI training a new model on background thread.") logger.info("FreqAI training a new model on background thread.")
self.retrain = False self.retrain = False