Rename DefaultStrategy
This commit is contained in:
@@ -7,9 +7,9 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
|
||||
class DefaultStrategy(IStrategy):
|
||||
class StrategyTestV2(IStrategy):
|
||||
"""
|
||||
Default Strategy provided by freqtrade bot.
|
||||
Strategy used by tests freqtrade bot.
|
||||
Please do not modify this strategy, it's intended for internal use only.
|
||||
Please look at the SampleStrategy in the user_data/strategy directory
|
||||
or strategy repository https://github.com/freqtrade/freqtrade-strategies
|
||||
|
@@ -4,20 +4,20 @@ from pandas import DataFrame
|
||||
|
||||
from freqtrade.persistence.models import Trade
|
||||
|
||||
from .strats.default_strategy import DefaultStrategy
|
||||
from .strats.default_strategy import StrategyTestV2
|
||||
|
||||
|
||||
def test_default_strategy_structure():
|
||||
assert hasattr(DefaultStrategy, 'minimal_roi')
|
||||
assert hasattr(DefaultStrategy, 'stoploss')
|
||||
assert hasattr(DefaultStrategy, 'timeframe')
|
||||
assert hasattr(DefaultStrategy, 'populate_indicators')
|
||||
assert hasattr(DefaultStrategy, 'populate_buy_trend')
|
||||
assert hasattr(DefaultStrategy, 'populate_sell_trend')
|
||||
assert hasattr(StrategyTestV2, 'minimal_roi')
|
||||
assert hasattr(StrategyTestV2, 'stoploss')
|
||||
assert hasattr(StrategyTestV2, 'timeframe')
|
||||
assert hasattr(StrategyTestV2, 'populate_indicators')
|
||||
assert hasattr(StrategyTestV2, 'populate_buy_trend')
|
||||
assert hasattr(StrategyTestV2, 'populate_sell_trend')
|
||||
|
||||
|
||||
def test_default_strategy(result, fee):
|
||||
strategy = DefaultStrategy({})
|
||||
strategy = StrategyTestV2({})
|
||||
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
assert type(strategy.minimal_roi) is dict
|
||||
|
@@ -22,11 +22,11 @@ from freqtrade.strategy.interface import SellCheckTuple
|
||||
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
|
||||
from tests.conftest import log_has, log_has_re
|
||||
|
||||
from .strats.default_strategy import DefaultStrategy
|
||||
from .strats.default_strategy import StrategyTestV2
|
||||
|
||||
|
||||
# Avoid to reinit the same object again and again
|
||||
_STRATEGY = DefaultStrategy(config={})
|
||||
_STRATEGY = StrategyTestV2(config={})
|
||||
_STRATEGY.dp = DataProvider({}, None, None)
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ def test_get_signal_no_sell_column(default_conf, mocker, caplog, ohlcv_history):
|
||||
|
||||
|
||||
def test_ignore_expired_candle(default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
strategy.ignore_buying_expired_candle_after = 60
|
||||
|
||||
@@ -229,7 +229,7 @@ def test_assert_df(ohlcv_history, caplog):
|
||||
|
||||
|
||||
def test_advise_all_indicators(default_conf, testdatadir) -> None:
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
timerange = TimeRange.parse_timerange('1510694220-1510700340')
|
||||
@@ -240,7 +240,7 @@ def test_advise_all_indicators(default_conf, testdatadir) -> None:
|
||||
|
||||
|
||||
def test_advise_all_indicators_copy(mocker, default_conf, testdatadir) -> None:
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
aimock = mocker.patch('freqtrade.strategy.interface.IStrategy.advise_indicators')
|
||||
timerange = TimeRange.parse_timerange('1510694220-1510700340')
|
||||
@@ -258,7 +258,7 @@ def test_min_roi_reached(default_conf, fee) -> None:
|
||||
min_roi_list = [{20: 0.05, 55: 0.01, 0: 0.1},
|
||||
{0: 0.1, 20: 0.05, 55: 0.01}]
|
||||
for roi in min_roi_list:
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
strategy.minimal_roi = roi
|
||||
trade = Trade(
|
||||
@@ -297,7 +297,7 @@ def test_min_roi_reached2(default_conf, fee) -> None:
|
||||
},
|
||||
]
|
||||
for roi in min_roi_list:
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
strategy.minimal_roi = roi
|
||||
trade = Trade(
|
||||
@@ -332,7 +332,7 @@ def test_min_roi_reached3(default_conf, fee) -> None:
|
||||
30: 0.05,
|
||||
55: 0.30,
|
||||
}
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
strategy.minimal_roi = min_roi
|
||||
trade = Trade(
|
||||
@@ -385,7 +385,7 @@ def test_min_roi_reached3(default_conf, fee) -> None:
|
||||
def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, trailing, custom,
|
||||
profit2, adjusted2, expected2, custom_stop) -> None:
|
||||
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
trade = Trade(
|
||||
@@ -433,7 +433,7 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili
|
||||
|
||||
def test_custom_sell(default_conf, fee, caplog) -> None:
|
||||
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
trade = Trade(
|
||||
@@ -487,7 +487,7 @@ def test_analyze_ticker_default(ohlcv_history, mocker, caplog) -> None:
|
||||
advise_sell=sell_mock,
|
||||
|
||||
)
|
||||
strategy = DefaultStrategy({})
|
||||
strategy = StrategyTestV2({})
|
||||
strategy.analyze_ticker(ohlcv_history, {'pair': 'ETH/BTC'})
|
||||
assert ind_mock.call_count == 1
|
||||
assert buy_mock.call_count == 1
|
||||
@@ -518,7 +518,7 @@ def test__analyze_ticker_internal_skip_analyze(ohlcv_history, mocker, caplog) ->
|
||||
advise_sell=sell_mock,
|
||||
|
||||
)
|
||||
strategy = DefaultStrategy({})
|
||||
strategy = StrategyTestV2({})
|
||||
strategy.dp = DataProvider({}, None, None)
|
||||
strategy.process_only_new_candles = True
|
||||
|
||||
@@ -550,7 +550,7 @@ def test__analyze_ticker_internal_skip_analyze(ohlcv_history, mocker, caplog) ->
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_is_pair_locked(default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
PairLocks.timeframe = default_conf['timeframe']
|
||||
PairLocks.use_db = True
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
@@ -18,7 +18,7 @@ def test_search_strategy():
|
||||
|
||||
s, _ = StrategyResolver._search_object(
|
||||
directory=default_location,
|
||||
object_name='DefaultStrategy',
|
||||
object_name='StrategyTestV2',
|
||||
add_source=True,
|
||||
)
|
||||
assert issubclass(s, IStrategy)
|
||||
@@ -74,10 +74,10 @@ def test_load_strategy_base64(result, caplog, default_conf):
|
||||
|
||||
|
||||
def test_load_strategy_invalid_directory(result, caplog, default_conf):
|
||||
default_conf['strategy'] = 'DefaultStrategy'
|
||||
default_conf['strategy'] = 'StrategyTestV2'
|
||||
extra_dir = Path.cwd() / 'some/path'
|
||||
with pytest.raises(OperationalException):
|
||||
StrategyResolver._load_strategy('DefaultStrategy', config=default_conf,
|
||||
StrategyResolver._load_strategy('StrategyTestV2', config=default_conf,
|
||||
extra_dir=extra_dir)
|
||||
|
||||
assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog)
|
||||
@@ -100,7 +100,7 @@ def test_load_strategy_noname(default_conf):
|
||||
|
||||
|
||||
def test_strategy(result, default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
@@ -127,7 +127,7 @@ def test_strategy(result, default_conf):
|
||||
def test_strategy_override_minimal_roi(caplog, default_conf):
|
||||
caplog.set_level(logging.INFO)
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'minimal_roi': {
|
||||
"20": 0.1,
|
||||
"0": 0.5
|
||||
@@ -144,7 +144,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': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'stoploss': -0.5
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -156,7 +156,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': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'trailing_stop': True
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -169,7 +169,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': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'trailing_stop_positive': -0.1,
|
||||
'trailing_stop_positive_offset': -0.2
|
||||
|
||||
@@ -189,7 +189,7 @@ def test_strategy_override_timeframe(caplog, default_conf):
|
||||
caplog.set_level(logging.INFO)
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'timeframe': 60,
|
||||
'stake_currency': 'ETH'
|
||||
})
|
||||
@@ -205,7 +205,7 @@ def test_strategy_override_process_only_new_candles(caplog, default_conf):
|
||||
caplog.set_level(logging.INFO)
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'process_only_new_candles': True
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -225,7 +225,7 @@ def test_strategy_override_order_types(caplog, default_conf):
|
||||
'stoploss_on_exchange': True,
|
||||
}
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'order_types': order_types
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -239,12 +239,12 @@ def test_strategy_override_order_types(caplog, default_conf):
|
||||
" 'stoploss_on_exchange': True}.", caplog)
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'order_types': {'buy': 'market'}
|
||||
})
|
||||
# Raise error for invalid configuration
|
||||
with pytest.raises(ImportError,
|
||||
match=r"Impossible to load Strategy 'DefaultStrategy'. "
|
||||
match=r"Impossible to load Strategy 'StrategyTestV2'. "
|
||||
r"Order-types mapping is incomplete."):
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
@@ -258,7 +258,7 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
}
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'order_time_in_force': order_time_in_force
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -271,12 +271,12 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
" {'buy': 'fok', 'sell': 'gtc'}.", caplog)
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'order_time_in_force': {'buy': 'fok'}
|
||||
})
|
||||
# Raise error for invalid configuration
|
||||
with pytest.raises(ImportError,
|
||||
match=r"Impossible to load Strategy 'DefaultStrategy'. "
|
||||
match=r"Impossible to load Strategy 'StrategyTestV2'. "
|
||||
r"Order-time-in-force mapping is incomplete."):
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
@@ -284,7 +284,7 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
caplog.set_level(logging.INFO)
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert strategy.use_sell_signal
|
||||
@@ -294,7 +294,7 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
assert default_conf['use_sell_signal']
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'use_sell_signal': False,
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -307,7 +307,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': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert not strategy.sell_profit_only
|
||||
@@ -317,7 +317,7 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
assert not default_conf['sell_profit_only']
|
||||
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
'strategy': 'StrategyTestV2',
|
||||
'sell_profit_only': True,
|
||||
})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
@@ -395,7 +395,7 @@ def test_call_deprecated_function(result, monkeypatch, default_conf, caplog):
|
||||
|
||||
|
||||
def test_strategy_interface_versioning(result, monkeypatch, default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
default_conf.update({'strategy': 'StrategyTestV2'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
|
||||
|
Reference in New Issue
Block a user