Merge pull request #2343 from hroff-1902/move-experimental
Move experimental settings to ask_strategy
This commit is contained in:
@@ -103,11 +103,6 @@
|
||||
"max_trade_duration_minute": 1440,
|
||||
"remove_pumps": false
|
||||
},
|
||||
"experimental": {
|
||||
"use_sell_signal": false,
|
||||
"sell_profit_only": false,
|
||||
"ignore_roi_if_buy_signal": false
|
||||
},
|
||||
"telegram": {
|
||||
// We can now comment out some settings
|
||||
// "enabled": true,
|
||||
|
||||
@@ -301,7 +301,7 @@ def test_backtest_results(default_conf, fee, mocker, caplog, data) -> None:
|
||||
if data.trailing_stop_positive:
|
||||
default_conf["trailing_stop_positive"] = data.trailing_stop_positive
|
||||
default_conf["trailing_stop_positive_offset"] = data.trailing_stop_positive_offset
|
||||
default_conf["experimental"] = {"use_sell_signal": data.use_sell_signal}
|
||||
default_conf["ask_strategy"] = {"use_sell_signal": data.use_sell_signal}
|
||||
|
||||
mocker.patch("freqtrade.exchange.Exchange.get_fee", MagicMock(return_value=0.0))
|
||||
patch_exchange(mocker)
|
||||
|
||||
@@ -517,6 +517,7 @@ def test_backtesting_start_no_data(default_conf, mocker, caplog, testdatadir) ->
|
||||
|
||||
|
||||
def test_backtest(default_conf, fee, mocker, testdatadir) -> None:
|
||||
default_conf['ask_strategy']['use_sell_signal'] = False
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
|
||||
patch_exchange(mocker)
|
||||
backtesting = Backtesting(default_conf)
|
||||
@@ -571,6 +572,7 @@ def test_backtest(default_conf, fee, mocker, testdatadir) -> None:
|
||||
|
||||
|
||||
def test_backtest_1min_ticker_interval(default_conf, fee, mocker, testdatadir) -> None:
|
||||
default_conf['ask_strategy']['use_sell_signal'] = False
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
|
||||
patch_exchange(mocker)
|
||||
backtesting = Backtesting(default_conf)
|
||||
@@ -613,8 +615,6 @@ def test_backtest_pricecontours(default_conf, fee, mocker, testdatadir) -> None:
|
||||
# TODO: Evaluate usefullness of this, the patterns and buy-signls are unrealistic
|
||||
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
|
||||
tests = [['raise', 19], ['lower', 0], ['sine', 35]]
|
||||
# We need to enable sell-signal - otherwise it sells on ROI!!
|
||||
default_conf['experimental'] = {"use_sell_signal": True}
|
||||
|
||||
for [contour, numres] in tests:
|
||||
simple_backtest(default_conf, contour, numres, mocker, testdatadir)
|
||||
@@ -655,8 +655,6 @@ def test_backtest_alternate_buy_sell(default_conf, fee, mocker, testdatadir):
|
||||
mocker.patch('freqtrade.optimize.backtesting.file_dump_json', MagicMock())
|
||||
backtest_conf = _make_backtest_conf(mocker, conf=default_conf,
|
||||
pair='UNITTEST/BTC', datadir=testdatadir)
|
||||
# We need to enable sell-signal - otherwise it sells on ROI!!
|
||||
default_conf['experimental'] = {"use_sell_signal": True}
|
||||
default_conf['ticker_interval'] = '1m'
|
||||
backtesting = Backtesting(default_conf)
|
||||
backtesting.strategy.advise_buy = _trend_alternate # Override
|
||||
@@ -697,8 +695,6 @@ def test_backtest_multi_pair(default_conf, fee, mocker, tres, pair, testdatadir)
|
||||
|
||||
# Remove data for one pair from the beginning of the data
|
||||
data[pair] = data[pair][tres:].reset_index()
|
||||
# We need to enable sell-signal - otherwise it sells on ROI!!
|
||||
default_conf['experimental'] = {"use_sell_signal": True}
|
||||
default_conf['ticker_interval'] = '5m'
|
||||
|
||||
backtesting = Backtesting(default_conf)
|
||||
|
||||
@@ -256,23 +256,23 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert not resolver.strategy.use_sell_signal
|
||||
assert resolver.strategy.use_sell_signal
|
||||
assert isinstance(resolver.strategy.use_sell_signal, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'use_sell_signal' in default_conf['experimental']
|
||||
assert not default_conf['experimental']['use_sell_signal']
|
||||
assert 'use_sell_signal' in default_conf['ask_strategy']
|
||||
assert default_conf['ask_strategy']['use_sell_signal']
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'experimental': {
|
||||
'use_sell_signal': True,
|
||||
'ask_strategy': {
|
||||
'use_sell_signal': False,
|
||||
},
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
|
||||
assert resolver.strategy.use_sell_signal
|
||||
assert not resolver.strategy.use_sell_signal
|
||||
assert isinstance(resolver.strategy.use_sell_signal, bool)
|
||||
assert log_has("Override strategy 'use_sell_signal' with value in config file: True.", caplog)
|
||||
assert log_has("Override strategy 'use_sell_signal' with value in config file: False.", caplog)
|
||||
|
||||
|
||||
def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
@@ -284,12 +284,12 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
assert not resolver.strategy.sell_profit_only
|
||||
assert isinstance(resolver.strategy.sell_profit_only, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'sell_profit_only' in default_conf['experimental']
|
||||
assert not default_conf['experimental']['sell_profit_only']
|
||||
assert 'sell_profit_only' in default_conf['ask_strategy']
|
||||
assert not default_conf['ask_strategy']['sell_profit_only']
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'experimental': {
|
||||
'ask_strategy': {
|
||||
'sell_profit_only': True,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -14,6 +14,9 @@ from freqtrade.configuration import (Arguments, Configuration,
|
||||
validate_config_consistency)
|
||||
from freqtrade.configuration.check_exchange import check_exchange
|
||||
from freqtrade.configuration.config_validation import validate_config_schema
|
||||
from freqtrade.configuration.deprecated_settings import (check_conflicting_settings,
|
||||
process_deprecated_setting,
|
||||
process_temporary_deprecated_settings)
|
||||
from freqtrade.configuration.directory_operations import (create_datadir,
|
||||
create_userdata_dir)
|
||||
from freqtrade.configuration.load_config import load_config_file
|
||||
@@ -897,3 +900,126 @@ def test_pairlist_resolving_fallback(mocker):
|
||||
assert config['pairs'] == ['ETH/BTC', 'XRP/BTC']
|
||||
assert config['exchange']['name'] == 'binance'
|
||||
assert config['datadir'] == str(Path.cwd() / "user_data/data/binance")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("setting", [
|
||||
("ask_strategy", "use_sell_signal", True,
|
||||
"experimental", "use_sell_signal", False),
|
||||
("ask_strategy", "sell_profit_only", False,
|
||||
"experimental", "sell_profit_only", True),
|
||||
("ask_strategy", "ignore_roi_if_buy_signal", False,
|
||||
"experimental", "ignore_roi_if_buy_signal", True),
|
||||
])
|
||||
def test_process_temporary_deprecated_settings(mocker, default_conf, setting, caplog):
|
||||
patched_configuration_load_config_file(mocker, default_conf)
|
||||
|
||||
# Create sections for new and deprecated settings
|
||||
# (they may not exist in the config)
|
||||
default_conf[setting[0]] = {}
|
||||
default_conf[setting[3]] = {}
|
||||
# Assign new setting
|
||||
default_conf[setting[0]][setting[1]] = setting[2]
|
||||
# Assign deprecated setting
|
||||
default_conf[setting[3]][setting[4]] = setting[5]
|
||||
|
||||
# New and deprecated settings are conflicting ones
|
||||
with pytest.raises(OperationalException, match=r'DEPRECATED'):
|
||||
process_temporary_deprecated_settings(default_conf)
|
||||
|
||||
caplog.clear()
|
||||
|
||||
# Delete new setting
|
||||
del default_conf[setting[0]][setting[1]]
|
||||
|
||||
process_temporary_deprecated_settings(default_conf)
|
||||
assert log_has_re('DEPRECATED', caplog)
|
||||
# The value of the new setting shall have been set to the
|
||||
# value of the deprecated one
|
||||
assert default_conf[setting[0]][setting[1]] == setting[5]
|
||||
|
||||
|
||||
def test_check_conflicting_settings(mocker, default_conf, caplog):
|
||||
patched_configuration_load_config_file(mocker, default_conf)
|
||||
|
||||
# Create sections for new and deprecated settings
|
||||
# (they may not exist in the config)
|
||||
default_conf['sectionA'] = {}
|
||||
default_conf['sectionB'] = {}
|
||||
# Assign new setting
|
||||
default_conf['sectionA']['new_setting'] = 'valA'
|
||||
# Assign deprecated setting
|
||||
default_conf['sectionB']['deprecated_setting'] = 'valB'
|
||||
|
||||
# New and deprecated settings are conflicting ones
|
||||
with pytest.raises(OperationalException, match=r'DEPRECATED'):
|
||||
check_conflicting_settings(default_conf,
|
||||
'sectionA', 'new_setting',
|
||||
'sectionB', 'deprecated_setting')
|
||||
|
||||
caplog.clear()
|
||||
|
||||
# Delete new setting (deprecated exists)
|
||||
del default_conf['sectionA']['new_setting']
|
||||
check_conflicting_settings(default_conf,
|
||||
'sectionA', 'new_setting',
|
||||
'sectionB', 'deprecated_setting')
|
||||
assert not log_has_re('DEPRECATED', caplog)
|
||||
assert 'new_setting' not in default_conf['sectionA']
|
||||
|
||||
caplog.clear()
|
||||
|
||||
# Assign new setting
|
||||
default_conf['sectionA']['new_setting'] = 'valA'
|
||||
# Delete deprecated setting
|
||||
del default_conf['sectionB']['deprecated_setting']
|
||||
check_conflicting_settings(default_conf,
|
||||
'sectionA', 'new_setting',
|
||||
'sectionB', 'deprecated_setting')
|
||||
assert not log_has_re('DEPRECATED', caplog)
|
||||
assert default_conf['sectionA']['new_setting'] == 'valA'
|
||||
|
||||
|
||||
def test_process_deprecated_setting(mocker, default_conf, caplog):
|
||||
patched_configuration_load_config_file(mocker, default_conf)
|
||||
|
||||
# Create sections for new and deprecated settings
|
||||
# (they may not exist in the config)
|
||||
default_conf['sectionA'] = {}
|
||||
default_conf['sectionB'] = {}
|
||||
# Assign new setting
|
||||
default_conf['sectionA']['new_setting'] = 'valA'
|
||||
# Assign deprecated setting
|
||||
default_conf['sectionB']['deprecated_setting'] = 'valB'
|
||||
|
||||
# Both new and deprecated settings exists
|
||||
process_deprecated_setting(default_conf,
|
||||
'sectionA', 'new_setting',
|
||||
'sectionB', 'deprecated_setting')
|
||||
assert log_has_re('DEPRECATED', caplog)
|
||||
# The value of the new setting shall have been set to the
|
||||
# value of the deprecated one
|
||||
assert default_conf['sectionA']['new_setting'] == 'valB'
|
||||
|
||||
caplog.clear()
|
||||
|
||||
# Delete new setting (deprecated exists)
|
||||
del default_conf['sectionA']['new_setting']
|
||||
process_deprecated_setting(default_conf,
|
||||
'sectionA', 'new_setting',
|
||||
'sectionB', 'deprecated_setting')
|
||||
assert log_has_re('DEPRECATED', caplog)
|
||||
# The value of the new setting shall have been set to the
|
||||
# value of the deprecated one
|
||||
assert default_conf['sectionA']['new_setting'] == 'valB'
|
||||
|
||||
caplog.clear()
|
||||
|
||||
# Assign new setting
|
||||
default_conf['sectionA']['new_setting'] = 'valA'
|
||||
# Delete deprecated setting
|
||||
del default_conf['sectionB']['deprecated_setting']
|
||||
process_deprecated_setting(default_conf,
|
||||
'sectionA', 'new_setting',
|
||||
'sectionB', 'deprecated_setting')
|
||||
assert not log_has_re('DEPRECATED', caplog)
|
||||
assert default_conf['sectionA']['new_setting'] == 'valA'
|
||||
|
||||
@@ -1772,8 +1772,6 @@ def test_handle_trade(default_conf, limit_buy_order, limit_sell_order,
|
||||
|
||||
def test_handle_overlpapping_signals(default_conf, ticker, limit_buy_order,
|
||||
fee, markets, mocker) -> None:
|
||||
default_conf.update({'experimental': {'use_sell_signal': True}})
|
||||
|
||||
patch_RPCManager(mocker)
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
@@ -1828,7 +1826,6 @@ def test_handle_overlpapping_signals(default_conf, ticker, limit_buy_order,
|
||||
def test_handle_trade_roi(default_conf, ticker, limit_buy_order,
|
||||
fee, mocker, markets, caplog) -> None:
|
||||
caplog.set_level(logging.DEBUG)
|
||||
default_conf.update({'experimental': {'use_sell_signal': True}})
|
||||
|
||||
patch_RPCManager(mocker)
|
||||
patch_exchange(mocker)
|
||||
@@ -1860,10 +1857,10 @@ def test_handle_trade_roi(default_conf, ticker, limit_buy_order,
|
||||
caplog)
|
||||
|
||||
|
||||
def test_handle_trade_experimental(
|
||||
def test_handle_trade_use_sell_signal(
|
||||
default_conf, ticker, limit_buy_order, fee, mocker, markets, caplog) -> None:
|
||||
# use_sell_signal is True buy default
|
||||
caplog.set_level(logging.DEBUG)
|
||||
default_conf.update({'experimental': {'use_sell_signal': True}})
|
||||
patch_RPCManager(mocker)
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
@@ -2713,7 +2710,7 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
default_conf['experimental'] = {
|
||||
default_conf['ask_strategy'] = {
|
||||
'use_sell_signal': True,
|
||||
'sell_profit_only': True,
|
||||
}
|
||||
@@ -2745,7 +2742,7 @@ def test_sell_profit_only_disable_profit(default_conf, limit_buy_order,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
default_conf['experimental'] = {
|
||||
default_conf['ask_strategy'] = {
|
||||
'use_sell_signal': True,
|
||||
'sell_profit_only': False,
|
||||
}
|
||||
@@ -2775,7 +2772,7 @@ def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, fee, market
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
default_conf['experimental'] = {
|
||||
default_conf['ask_strategy'] = {
|
||||
'use_sell_signal': True,
|
||||
'sell_profit_only': True,
|
||||
}
|
||||
@@ -2805,7 +2802,7 @@ def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, fee, marke
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
default_conf['experimental'] = {
|
||||
default_conf['ask_strategy'] = {
|
||||
'use_sell_signal': True,
|
||||
'sell_profit_only': False,
|
||||
}
|
||||
@@ -2874,7 +2871,7 @@ def test_ignore_roi_if_buy_signal(default_conf, limit_buy_order, fee, markets, m
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
default_conf['experimental'] = {
|
||||
default_conf['ask_strategy'] = {
|
||||
'ignore_roi_if_buy_signal': True
|
||||
}
|
||||
freqtrade = FreqtradeBot(default_conf)
|
||||
@@ -3142,7 +3139,7 @@ def test_disable_ignore_roi_if_buy_signal(default_conf, limit_buy_order,
|
||||
get_fee=fee,
|
||||
markets=PropertyMock(return_value=markets)
|
||||
)
|
||||
default_conf['experimental'] = {
|
||||
default_conf['ask_strategy'] = {
|
||||
'ignore_roi_if_buy_signal': False
|
||||
}
|
||||
freqtrade = FreqtradeBot(default_conf)
|
||||
|
||||
Reference in New Issue
Block a user