Move experimental settings to ask_strategy
This commit is contained in:
@@ -114,7 +114,10 @@ CONF_SCHEMA = {
|
||||
'properties': {
|
||||
'use_order_book': {'type': 'boolean'},
|
||||
'order_book_min': {'type': 'number', 'minimum': 1},
|
||||
'order_book_max': {'type': 'number', 'minimum': 1, 'maximum': 50}
|
||||
'order_book_max': {'type': 'number', 'minimum': 1, 'maximum': 50},
|
||||
'use_sell_signal': {'type': 'boolean'},
|
||||
'sell_profit_only': {'type': 'boolean'},
|
||||
'ignore_roi_if_buy_signal': {'type': 'boolean'}
|
||||
}
|
||||
},
|
||||
'order_types': {
|
||||
@@ -144,7 +147,8 @@ CONF_SCHEMA = {
|
||||
'properties': {
|
||||
'use_sell_signal': {'type': 'boolean'},
|
||||
'sell_profit_only': {'type': 'boolean'},
|
||||
'ignore_roi_if_buy_signal_true': {'type': 'boolean'}
|
||||
'ignore_roi_if_buy_signal': {'type': 'boolean'},
|
||||
'block_bad_exchanges': {'type': 'boolean'}
|
||||
}
|
||||
},
|
||||
'pairlist': {
|
||||
|
@@ -580,13 +580,15 @@ class FreqtradeBot:
|
||||
logger.debug('Handling %s ...', trade)
|
||||
|
||||
(buy, sell) = (False, False)
|
||||
experimental = self.config.get('experimental', {})
|
||||
if experimental.get('use_sell_signal') or experimental.get('ignore_roi_if_buy_signal'):
|
||||
|
||||
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')):
|
||||
(buy, sell) = self.strategy.get_signal(
|
||||
trade.pair, self.strategy.ticker_interval,
|
||||
self.dataprovider.ohlcv(trade.pair, self.strategy.ticker_interval))
|
||||
|
||||
config_ask_strategy = self.config.get('ask_strategy', {})
|
||||
if config_ask_strategy.get('use_order_book', False):
|
||||
logger.info('Using order book for selling...')
|
||||
# logger.debug('Order book %s',orderBook)
|
||||
|
@@ -98,10 +98,10 @@ class Hyperopt:
|
||||
self.position_stacking = self.config.get('position_stacking', False)
|
||||
|
||||
if self.has_space('sell'):
|
||||
# Make sure experimental is enabled
|
||||
if 'experimental' not in self.config:
|
||||
self.config['experimental'] = {}
|
||||
self.config['experimental']['use_sell_signal'] = True
|
||||
# Make sure use_sell_signal is enabled
|
||||
if 'ask_strategy' not in self.config:
|
||||
self.config['ask_strategy'] = {}
|
||||
self.config['ask_strategy']['use_sell_signal'] = True
|
||||
|
||||
@staticmethod
|
||||
def get_lock_filename(config) -> str:
|
||||
|
@@ -38,13 +38,13 @@ class StrategyResolver(IResolver):
|
||||
config=config,
|
||||
extra_dir=config.get('strategy_path'))
|
||||
|
||||
# make sure experimental dict is available
|
||||
if 'experimental' not in config:
|
||||
config['experimental'] = {}
|
||||
# make sure ask_strategy dict is available
|
||||
if 'ask_strategy' not in config:
|
||||
config['ask_strategy'] = {}
|
||||
|
||||
# Set attributes
|
||||
# Check if we need to override configuration
|
||||
# (Attribute name, default, experimental)
|
||||
# (Attribute name, default, ask_strategy)
|
||||
attributes = [("minimal_roi", {"0": 10.0}, False),
|
||||
("ticker_interval", None, False),
|
||||
("stoploss", None, False),
|
||||
@@ -57,20 +57,20 @@ class StrategyResolver(IResolver):
|
||||
("order_time_in_force", None, False),
|
||||
("stake_currency", None, False),
|
||||
("stake_amount", None, False),
|
||||
("use_sell_signal", False, True),
|
||||
("use_sell_signal", True, True),
|
||||
("sell_profit_only", False, True),
|
||||
("ignore_roi_if_buy_signal", False, True),
|
||||
]
|
||||
for attribute, default, experimental in attributes:
|
||||
if experimental:
|
||||
self._override_attribute_helper(config['experimental'], attribute, default)
|
||||
for attribute, default, ask_strategy in attributes:
|
||||
if ask_strategy:
|
||||
self._override_attribute_helper(config['ask_strategy'], attribute, default)
|
||||
else:
|
||||
self._override_attribute_helper(config, attribute, default)
|
||||
|
||||
# Loop this list again to have output combined
|
||||
for attribute, _, exp in attributes:
|
||||
if exp and attribute in config['experimental']:
|
||||
logger.info("Strategy using %s: %s", attribute, config['experimental'][attribute])
|
||||
if exp and attribute in config['ask_strategy']:
|
||||
logger.info("Strategy using %s: %s", attribute, config['ask_strategy'][attribute])
|
||||
elif attribute in config:
|
||||
logger.info("Strategy using %s: %s", attribute, config[attribute])
|
||||
|
||||
|
@@ -309,9 +309,9 @@ class IStrategy(ABC):
|
||||
# Set current rate to high for backtesting sell
|
||||
current_rate = high or rate
|
||||
current_profit = trade.calc_profit_percent(current_rate)
|
||||
experimental = self.config.get('experimental', {})
|
||||
config_ask_strategy = self.config.get('ask_strategy', {})
|
||||
|
||||
if buy and experimental.get('ignore_roi_if_buy_signal', False):
|
||||
if buy and config_ask_strategy.get('ignore_roi_if_buy_signal', False):
|
||||
# This one is noisy, commented out
|
||||
# logger.debug(f"{trade.pair} - Buy signal still active. sell_flag=False")
|
||||
return SellCheckTuple(sell_flag=False, sell_type=SellType.NONE)
|
||||
@@ -322,7 +322,7 @@ class IStrategy(ABC):
|
||||
f"sell_type=SellType.ROI")
|
||||
return SellCheckTuple(sell_flag=True, sell_type=SellType.ROI)
|
||||
|
||||
if experimental.get('sell_profit_only', False):
|
||||
if config_ask_strategy.get('sell_profit_only', False):
|
||||
# This one is noisy, commented out
|
||||
# logger.debug(f"{trade.pair} - Checking if trade is profitable...")
|
||||
if trade.calc_profit(rate=rate) <= 0:
|
||||
@@ -330,7 +330,7 @@ class IStrategy(ABC):
|
||||
# logger.debug(f"{trade.pair} - Trade is not profitable. sell_flag=False")
|
||||
return SellCheckTuple(sell_flag=False, sell_type=SellType.NONE)
|
||||
|
||||
if sell and not buy and experimental.get('use_sell_signal', False):
|
||||
if sell and not buy and config_ask_strategy.get('use_sell_signal', True):
|
||||
logger.debug(f"{trade.pair} - Sell signal received. sell_flag=True, "
|
||||
f"sell_type=SellType.SELL_SIGNAL")
|
||||
return SellCheckTuple(sell_flag=True, sell_type=SellType.SELL_SIGNAL)
|
||||
|
Reference in New Issue
Block a user