Use new TestStrategy (V3) by default in tests

This commit is contained in:
Matthias
2021-09-21 20:18:14 +02:00
parent 7a5c7e7020
commit c791b95405
21 changed files with 127 additions and 132 deletions

View File

@@ -10,7 +10,7 @@ from pandas import DataFrame
from freqtrade.exceptions import OperationalException
from freqtrade.resolvers import StrategyResolver
from freqtrade.strategy.interface import IStrategy
from tests.conftest import log_has, log_has_re
from tests.conftest import CURRENT_TEST_STRATEGY, log_has, log_has_re
def test_search_strategy():
@@ -18,7 +18,7 @@ def test_search_strategy():
s, _ = StrategyResolver._search_object(
directory=default_location,
object_name='StrategyTestV2',
object_name=CURRENT_TEST_STRATEGY,
add_source=True,
)
assert issubclass(s, IStrategy)
@@ -77,7 +77,7 @@ def test_load_strategy_invalid_directory(result, caplog, default_conf):
default_conf['strategy'] = 'StrategyTestV3'
extra_dir = Path.cwd() / 'some/path'
with pytest.raises(OperationalException):
StrategyResolver._load_strategy('StrategyTestV2', config=default_conf,
StrategyResolver._load_strategy(CURRENT_TEST_STRATEGY, config=default_conf,
extra_dir=extra_dir)
assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog)
@@ -129,7 +129,7 @@ def test_strategy_v2(result, default_conf):
def test_strategy_override_minimal_roi(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'minimal_roi': {
"20": 0.1,
"0": 0.5
@@ -146,7 +146,7 @@ def test_strategy_override_minimal_roi(caplog, default_conf):
def test_strategy_override_stoploss(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'stoploss': -0.5
})
strategy = StrategyResolver.load_strategy(default_conf)
@@ -158,7 +158,7 @@ def test_strategy_override_stoploss(caplog, default_conf):
def test_strategy_override_trailing_stop(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'trailing_stop': True
})
strategy = StrategyResolver.load_strategy(default_conf)
@@ -171,7 +171,7 @@ def test_strategy_override_trailing_stop(caplog, default_conf):
def test_strategy_override_trailing_stop_positive(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'trailing_stop_positive': -0.1,
'trailing_stop_positive_offset': -0.2
@@ -191,7 +191,7 @@ def test_strategy_override_timeframe(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'timeframe': 60,
'stake_currency': 'ETH'
})
@@ -207,7 +207,7 @@ def test_strategy_override_process_only_new_candles(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'process_only_new_candles': True
})
strategy = StrategyResolver.load_strategy(default_conf)
@@ -227,7 +227,7 @@ def test_strategy_override_order_types(caplog, default_conf):
'stoploss_on_exchange': True,
}
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'order_types': order_types
})
strategy = StrategyResolver.load_strategy(default_conf)
@@ -241,12 +241,12 @@ def test_strategy_override_order_types(caplog, default_conf):
" 'stoploss_on_exchange': True}.", caplog)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'order_types': {'buy': 'market'}
})
# Raise error for invalid configuration
with pytest.raises(ImportError,
match=r"Impossible to load Strategy 'StrategyTestV3'. "
match=r"Impossible to load Strategy '" + CURRENT_TEST_STRATEGY + "'. "
r"Order-types mapping is incomplete."):
StrategyResolver.load_strategy(default_conf)
@@ -260,7 +260,7 @@ def test_strategy_override_order_tif(caplog, default_conf):
}
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'order_time_in_force': order_time_in_force
})
strategy = StrategyResolver.load_strategy(default_conf)
@@ -273,20 +273,20 @@ def test_strategy_override_order_tif(caplog, default_conf):
" {'buy': 'fok', 'sell': 'gtc'}.", caplog)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'order_time_in_force': {'buy': 'fok'}
})
# Raise error for invalid configuration
with pytest.raises(ImportError,
match=r"Impossible to load Strategy 'StrategyTestV3'. "
r"Order-time-in-force mapping is incomplete."):
match=f"Impossible to load Strategy '{CURRENT_TEST_STRATEGY}'. "
"Order-time-in-force mapping is incomplete."):
StrategyResolver.load_strategy(default_conf)
def test_strategy_override_use_sell_signal(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
})
strategy = StrategyResolver.load_strategy(default_conf)
assert strategy.use_sell_signal
@@ -296,7 +296,7 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
assert default_conf['use_sell_signal']
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'use_sell_signal': False,
})
strategy = StrategyResolver.load_strategy(default_conf)
@@ -309,7 +309,7 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
def test_strategy_override_use_sell_profit_only(caplog, default_conf):
caplog.set_level(logging.INFO)
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
})
strategy = StrategyResolver.load_strategy(default_conf)
assert not strategy.sell_profit_only
@@ -319,7 +319,7 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
assert not default_conf['sell_profit_only']
default_conf.update({
'strategy': 'StrategyTestV3',
'strategy': CURRENT_TEST_STRATEGY,
'sell_profit_only': True,
})
strategy = StrategyResolver.load_strategy(default_conf)