fix config saving bug, assign priorities to pairs in scanning, sleep the scanning loop to reduce CPU usage

This commit is contained in:
robcaulk 2022-06-27 11:35:33 +02:00
parent 68bafa9517
commit 7dfbd432d1
2 changed files with 9 additions and 10 deletions

View File

@ -4,6 +4,7 @@ import gc
import logging import logging
import shutil import shutil
import threading import threading
import time
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from pathlib import Path from pathlib import Path
from typing import Any, Dict, Tuple 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.live = strategy.dp.runmode in (RunMode.DRY_RUN, RunMode.LIVE)
self.data_drawer.set_pair_dict_info(metadata) 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: if self.live:
self.dh = FreqaiDataKitchen(self.config, self.data_drawer, self.dh = FreqaiDataKitchen(self.config, self.data_drawer,
self.live, metadata["pair"]) self.live, metadata["pair"])
@ -122,16 +119,18 @@ class IFreqaiModel(ABC):
strategy: IStrategy = The user defined strategy class strategy: IStrategy = The user defined strategy class
""" """
while 1: while 1:
time.sleep(1)
for pair in self.config.get('exchange', {}).get('pair_whitelist'): 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, (model_filename,
trained_timestamp, trained_timestamp,
_, _) = self.data_drawer.get_pair_dict_info(pair) _, _) = 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 file_exists = False
dh.set_paths(pair, trained_timestamp) dh.set_paths(pair, trained_timestamp)
@ -416,7 +415,7 @@ class IFreqaiModel(ABC):
str(self.freqai_info.get('identifier'))) str(self.freqai_info.get('identifier')))
self.full_path.mkdir(parents=True, exist_ok=True) self.full_path.mkdir(parents=True, exist_ok=True)
shutil.copy(self.config['config_files'][0], Path(self.full_path, 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: def remove_features_from_df(self, dataframe: DataFrame) -> DataFrame:
""" """

View File

@ -47,7 +47,7 @@ class FreqaiExampleStrategy(IStrategy):
stoploss = -0.05 stoploss = -0.05
use_exit_signal = True use_exit_signal = True
startup_candle_count: int = 300 startup_candle_count: int = 300
can_short = True can_short = False
linear_roi_offset = DecimalParameter( linear_roi_offset = DecimalParameter(
0.00, 0.02, default=0.005, space="sell", optimize=False, load=True 0.00, 0.02, default=0.005, space="sell", optimize=False, load=True