add automatic change to process_only_new_candles, fix flake8

This commit is contained in:
robcaulk 2022-09-17 16:37:39 +02:00
parent ff300d5c85
commit a7312dec03
2 changed files with 12 additions and 43 deletions

View File

@ -154,9 +154,14 @@ class IStrategy(ABC, HyperStrategyMixin):
from freqtrade.freqai.utils import download_all_data_for_training from freqtrade.freqai.utils import download_all_data_for_training
from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver
self.freqai = FreqaiModelResolver.load_freqaimodel(self.config) self.freqai = FreqaiModelResolver.load_freqaimodel(self.config)
if not self.process_only_new_candles:
logger.warning('User set process_only_new_candles to false, '
'FreqAI requires true. Changing to true.')
self.process_only_new_candles = True
if spice_rack: if spice_rack:
import types import types
from freqtrade.freqai.utils import auto_populate_any_indicators from freqtrade.freqai.utils import auto_populate_any_indicators
self.populate_any_indicators = types.MethodType( # type: ignore self.populate_any_indicators = types.MethodType( # type: ignore
auto_populate_any_indicators, self) auto_populate_any_indicators, self)
@ -186,9 +191,9 @@ class IStrategy(ABC, HyperStrategyMixin):
self.freqai = DummyClass() # type: ignore self.freqai = DummyClass() # type: ignore
def setup_freqai_spice_rack(self, config: dict) -> Dict[str, Any]: def setup_freqai_spice_rack(self, config: dict) -> Dict[str, Any]:
import difflib
import json import json
from pathlib import Path from pathlib import Path
import difflib
auto_config = config.get('freqai_config', 'lightgbm_config.json') auto_config = config.get('freqai_config', 'lightgbm_config.json')
with open(Path('freqtrade') / 'freqai' / 'spice_rack' with open(Path('freqtrade') / 'freqai' / 'spice_rack'
/ auto_config) as json_file: / auto_config) as json_file:

View File

@ -1,11 +1,9 @@
import logging import logging
from functools import reduce
import pandas as pd
import talib.abstract as ta import talib.abstract as ta
from pandas import DataFrame from pandas import DataFrame
from freqtrade.strategy import DecimalParameter, IntParameter, IStrategy, merge_informative_pair from freqtrade.strategy import IStrategy
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -19,42 +17,8 @@ class freqai_test_spice_rack(IStrategy):
minimal_roi = {"0": 0.1, "240": -1} minimal_roi = {"0": 0.1, "240": -1}
plot_config = {
"main_plot": {},
"subplots": {
"prediction": {"prediction": {"color": "blue"}},
"target_roi": {
"target_roi": {"color": "brown"},
},
"do_predict": {
"do_predict": {"color": "brown"},
},
},
}
process_only_new_candles = True process_only_new_candles = True
stoploss = -0.05 startup_candle_count: int = 30
use_exit_signal = True
startup_candle_count: int = 300
can_short = False
linear_roi_offset = DecimalParameter(
0.00, 0.02, default=0.005, space="sell", optimize=False, load=True
)
max_roi_time_long = IntParameter(0, 800, default=400, space="sell", optimize=False, load=True)
def informative_pairs(self):
whitelist_pairs = self.dp.current_whitelist()
corr_pairs = self.config["freqai"]["feature_parameters"]["include_corr_pairlist"]
informative_pairs = []
for tf in self.config["freqai"]["feature_parameters"]["include_timeframes"]:
for pair in whitelist_pairs:
informative_pairs.append((pair, tf))
for pair in corr_pairs:
if pair in whitelist_pairs:
continue # avoid duplication
informative_pairs.append((pair, tf))
return informative_pairs
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
@ -77,7 +41,7 @@ class freqai_test_spice_rack(IStrategy):
df.loc[ df.loc[
( (
(df['tema'] > df['tema'].shift(1)) & # Guard: tema is raising (df['rsi'] > df['rsi'].shift(1)) & # Guard: tema is raising
(df['dissimilarity_index'] < 1) & (df['dissimilarity_index'] < 1) &
(df['maxima'] > 0.1) (df['maxima'] > 0.1)
), ),
@ -85,7 +49,7 @@ class freqai_test_spice_rack(IStrategy):
df.loc[ df.loc[
( (
(df['tema'] < df['tema'].shift(1)) & # Guard: tema is falling (df['rsi'] < df['rsi'].shift(1)) & # Guard: tema is falling
(df['dissimilarity_index'] < 1) & (df['dissimilarity_index'] < 1) &
(df['minima'] > 0.1) (df['minima'] > 0.1)
), ),
@ -97,7 +61,7 @@ class freqai_test_spice_rack(IStrategy):
df.loc[ df.loc[
( (
(df['tema'] < df['tema'].shift(1)) & # Guard: tema is falling (df['rsi'] < df['rsi'].shift(1)) & # Guard: tema is falling
(df['dissimilarity_index'] < 1) & (df['dissimilarity_index'] < 1) &
(df['maxima'] > 0.1) (df['maxima'] > 0.1)
), ),
@ -106,7 +70,7 @@ class freqai_test_spice_rack(IStrategy):
df.loc[ df.loc[
( (
(df['tema'] > df['tema'].shift(1)) & # Guard: tema is raising (df['rsi'] > df['rsi'].shift(1)) & # Guard: tema is raising
(df['dissimilarity_index'] < 1) & (df['dissimilarity_index'] < 1) &
(df['minima'] > 0.1) (df['minima'] > 0.1)
), ),