Move strategy-override signals to top-level of the config

closes #2867
This commit is contained in:
Matthias 2021-06-26 16:06:09 +02:00
parent 60c7308126
commit 1067a9f356
12 changed files with 29 additions and 47 deletions

View File

@ -22,10 +22,7 @@
},
"ask_strategy": {
"use_order_book": true,
"order_book_top": 1,
"use_sell_signal": true,
"sell_profit_only": false,
"ignore_roi_if_buy_signal": false
"order_book_top": 1
},
"exchange": {
"name": "binance",

View File

@ -22,10 +22,7 @@
},
"ask_strategy":{
"use_order_book": true,
"order_book_top": 1,
"use_sell_signal": true,
"sell_profit_only": false,
"ignore_roi_if_buy_signal": false
"order_book_top": 1
},
"exchange": {
"name": "bittrex",

View File

@ -22,10 +22,7 @@
},
"ask_strategy": {
"use_order_book": true,
"order_book_top": 1,
"use_sell_signal": true,
"sell_profit_only": false,
"ignore_roi_if_buy_signal": false
"order_book_top": 1
},
"exchange": {
"name": "ftx",

View File

@ -14,6 +14,10 @@
"trailing_stop_positive": 0.005,
"trailing_stop_positive_offset": 0.0051,
"trailing_only_offset_is_reached": false,
"use_sell_signal": true,
"sell_profit_only": false,
"sell_profit_offset": 0.0,
"ignore_roi_if_buy_signal": false,
"minimal_roi": {
"40": 0.0,
"30": 0.01,
@ -39,11 +43,7 @@
"ask_strategy":{
"price_side": "ask",
"use_order_book": true,
"order_book_top": 1,
"use_sell_signal": true,
"sell_profit_only": false,
"sell_profit_offset": 0.0,
"ignore_roi_if_buy_signal": false
"order_book_top": 1
},
"order_types": {
"buy": "limit",

View File

@ -22,10 +22,7 @@
},
"ask_strategy":{
"use_order_book": true,
"order_book_top": 1,
"use_sell_signal": true,
"sell_profit_only": false,
"ignore_roi_if_buy_signal": false
"order_book_top": 1
},
"exchange": {
"name": "kraken",

View File

@ -150,7 +150,7 @@ def _validate_edge(conf: Dict[str, Any]) -> None:
if not conf.get('edge', {}).get('enabled'):
return
if not conf.get('ask_strategy', {}).get('use_sell_signal', True):
if not conf.get('use_sell_signal', True):
raise OperationalException(
"Edge requires `use_sell_signal` to be True, otherwise no sells will happen."
)

View File

@ -134,6 +134,11 @@ CONF_SCHEMA = {
'trailing_stop_positive': {'type': 'number', 'minimum': 0, 'maximum': 1},
'trailing_stop_positive_offset': {'type': 'number', 'minimum': 0, 'maximum': 1},
'trailing_only_offset_is_reached': {'type': 'boolean'},
'use_sell_signal': {'type': 'boolean'},
'sell_profit_only': {'type': 'boolean'},
'sell_profit_offset': {'type': 'number'},
'ignore_roi_if_buy_signal': {'type': 'boolean'},
'ignore_buying_expired_candle_after': {'type': 'number'},
'bot_name': {'type': 'string'},
'unfilledtimeout': {
'type': 'object',
@ -177,10 +182,6 @@ CONF_SCHEMA = {
},
'use_order_book': {'type': 'boolean'},
'order_book_top': {'type': 'integer', 'minimum': 1, 'maximum': 50, },
'use_sell_signal': {'type': 'boolean'},
'sell_profit_only': {'type': 'boolean'},
'sell_profit_offset': {'type': 'number'},
'ignore_roi_if_buy_signal': {'type': 'boolean'}
},
'required': ['price_side']
},

View File

@ -684,10 +684,8 @@ class FreqtradeBot(LoggingMixin):
(buy, sell) = (False, False)
config_ask_strategy = self.config.get('ask_strategy', {})
if (config_ask_strategy.get('use_sell_signal', True) or
config_ask_strategy.get('ignore_roi_if_buy_signal', False)):
if (self.config.get('use_sell_signal', True) or
self.config.get('ignore_roi_if_buy_signal', False)):
analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(trade.pair,
self.strategy.timeframe)

View File

@ -378,10 +378,10 @@ def generate_strategy_stats(btdata: Dict[str, DataFrame],
'trailing_only_offset_is_reached': config.get('trailing_only_offset_is_reached', False),
'use_custom_stoploss': config.get('use_custom_stoploss', False),
'minimal_roi': config['minimal_roi'],
'use_sell_signal': config['ask_strategy']['use_sell_signal'],
'sell_profit_only': config['ask_strategy']['sell_profit_only'],
'sell_profit_offset': config['ask_strategy']['sell_profit_offset'],
'ignore_roi_if_buy_signal': config['ask_strategy']['ignore_roi_if_buy_signal'],
'use_sell_signal': config['use_sell_signal'],
'sell_profit_only': config['sell_profit_only'],
'sell_profit_offset': config['sell_profit_offset'],
'ignore_roi_if_buy_signal': config['ignore_roi_if_buy_signal'],
**daily_stats,
**trade_stats
}

View File

@ -76,12 +76,12 @@ class StrategyResolver(IResolver):
("protections", None, None),
("startup_candle_count", None, None),
("unfilledtimeout", None, None),
("use_sell_signal", True, 'ask_strategy'),
("sell_profit_only", False, 'ask_strategy'),
("ignore_roi_if_buy_signal", False, 'ask_strategy'),
("sell_profit_offset", 0.0, 'ask_strategy'),
("use_sell_signal", True, None),
("sell_profit_only", False, None),
("ignore_roi_if_buy_signal", False, None),
("sell_profit_offset", 0.0, None),
("disable_dataframe_checks", False, None),
("ignore_buying_expired_candle_after", 0, 'ask_strategy')
("ignore_buying_expired_candle_after", 0, None)
]
for attribute, default, subkey in attributes:
if subkey:

View File

@ -543,10 +543,9 @@ class IStrategy(ABC, HyperStrategyMixin):
# Set current rate to high for backtesting sell
current_rate = high or rate
current_profit = trade.calc_profit_ratio(current_rate)
ask_strategy = self.config.get('ask_strategy', {})
# if buy signal and ignore_roi is set, we don't need to evaluate min_roi.
roi_reached = (not (buy and ask_strategy.get('ignore_roi_if_buy_signal', False))
roi_reached = (not (buy and self.ignore_roi_if_buy_signal)
and self.min_roi_reached(trade=trade, current_profit=current_profit,
current_time=date))
@ -556,11 +555,10 @@ class IStrategy(ABC, HyperStrategyMixin):
current_rate = rate
current_profit = trade.calc_profit_ratio(current_rate)
if (ask_strategy.get('sell_profit_only', False)
and current_profit <= ask_strategy.get('sell_profit_offset', 0)):
if (self.sell_profit_only and current_profit <= self.sell_profit_offset):
# sell_profit_only and profit doesn't reach the offset - ignore sell signal
pass
elif ask_strategy.get('use_sell_signal', True) and not buy:
elif self.use_sell_signal and not buy:
if sell:
sell_signal = SellType.SELL_SIGNAL
else:

View File

@ -26,9 +26,6 @@
"price_side": "ask",
"use_order_book": true,
"order_book_top": 1,
"use_sell_signal": true,
"sell_profit_only": false,
"ignore_roi_if_buy_signal": false
},
{{ exchange | indent(4) }},
"pairlists": [