From 7dfbd432d1de6f9b6a3df6b69cb9654c4e047bd5 Mon Sep 17 00:00:00 2001 From: robcaulk Date: Mon, 27 Jun 2022 11:35:33 +0200 Subject: [PATCH] fix config saving bug, assign priorities to pairs in scanning, sleep the scanning loop to reduce CPU usage --- freqtrade/freqai/freqai_interface.py | 17 ++++++++--------- freqtrade/templates/FreqaiExampleStrategy.py | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py index 7ab412fb0..82a390a49 100644 --- a/freqtrade/freqai/freqai_interface.py +++ b/freqtrade/freqai/freqai_interface.py @@ -4,6 +4,7 @@ import gc import logging import shutil import threading +import time from abc import ABC, abstractmethod from pathlib import Path from typing import Any, Dict, Tuple @@ -90,10 +91,6 @@ class IFreqaiModel(ABC): self.live = strategy.dp.runmode in (RunMode.DRY_RUN, RunMode.LIVE) self.data_drawer.set_pair_dict_info(metadata) - # For live, we may be training new models on a separate thread while other pairs still need - # to inference their historical models. Here we use a training queue system to handle this - # and we keep the flag self.training_on_separate_threaad in the current object to help - # determine what the current pair will do if self.live: self.dh = FreqaiDataKitchen(self.config, self.data_drawer, self.live, metadata["pair"]) @@ -122,16 +119,18 @@ class IFreqaiModel(ABC): strategy: IStrategy = The user defined strategy class """ while 1: + time.sleep(1) for pair in self.config.get('exchange', {}).get('pair_whitelist'): - if self.data_drawer.pair_dict[pair]['priority'] != 1: - continue - dh = FreqaiDataKitchen(self.config, self.data_drawer, - self.live, pair) (model_filename, trained_timestamp, _, _) = self.data_drawer.get_pair_dict_info(pair) + if self.data_drawer.pair_dict[pair]['priority'] != 1: + continue + dh = FreqaiDataKitchen(self.config, self.data_drawer, + self.live, pair) + file_exists = False dh.set_paths(pair, trained_timestamp) @@ -416,7 +415,7 @@ class IFreqaiModel(ABC): 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])) + Path(self.config['config_files'][0]).name)) def remove_features_from_df(self, dataframe: DataFrame) -> DataFrame: """ diff --git a/freqtrade/templates/FreqaiExampleStrategy.py b/freqtrade/templates/FreqaiExampleStrategy.py index 5893bf9ac..95fdba316 100644 --- a/freqtrade/templates/FreqaiExampleStrategy.py +++ b/freqtrade/templates/FreqaiExampleStrategy.py @@ -47,7 +47,7 @@ class FreqaiExampleStrategy(IStrategy): stoploss = -0.05 use_exit_signal = True startup_candle_count: int = 300 - can_short = True + can_short = False linear_roi_offset = DecimalParameter( 0.00, 0.02, default=0.005, space="sell", optimize=False, load=True