|
|
|
|
@ -2,7 +2,6 @@
|
|
|
|
|
import logging
|
|
|
|
|
import warnings
|
|
|
|
|
from base64 import urlsafe_b64encode
|
|
|
|
|
from os import path
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
@ -15,7 +14,7 @@ from tests.conftest import log_has, log_has_re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_search_strategy():
|
|
|
|
|
default_location = Path(__file__).parent.parent.joinpath('strategy').resolve()
|
|
|
|
|
default_location = Path(__file__).parent / 'strats'
|
|
|
|
|
|
|
|
|
|
s, _ = StrategyResolver._search_object(
|
|
|
|
|
directory=default_location,
|
|
|
|
|
@ -31,21 +30,21 @@ def test_search_strategy():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_search_all_strategies_no_failed():
|
|
|
|
|
directory = Path(__file__).parent
|
|
|
|
|
directory = Path(__file__).parent / "strats"
|
|
|
|
|
strategies = StrategyResolver.search_all_objects(directory, enum_failed=False)
|
|
|
|
|
assert isinstance(strategies, list)
|
|
|
|
|
assert len(strategies) == 3
|
|
|
|
|
assert len(strategies) == 2
|
|
|
|
|
assert isinstance(strategies[0], dict)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_search_all_strategies_with_failed():
|
|
|
|
|
directory = Path(__file__).parent
|
|
|
|
|
directory = Path(__file__).parent / "strats"
|
|
|
|
|
strategies = StrategyResolver.search_all_objects(directory, enum_failed=True)
|
|
|
|
|
assert isinstance(strategies, list)
|
|
|
|
|
assert len(strategies) == 4
|
|
|
|
|
# with enum_failed=True search_all_objects() shall find 3 good strategies
|
|
|
|
|
assert len(strategies) == 3
|
|
|
|
|
# with enum_failed=True search_all_objects() shall find 2 good strategies
|
|
|
|
|
# and 1 which fails to load
|
|
|
|
|
assert len([x for x in strategies if x['class'] is not None]) == 3
|
|
|
|
|
assert len([x for x in strategies if x['class'] is not None]) == 2
|
|
|
|
|
assert len([x for x in strategies if x['class'] is None]) == 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,13 +71,12 @@ def test_load_strategy_base64(result, caplog, default_conf):
|
|
|
|
|
def test_load_strategy_invalid_directory(result, caplog, default_conf):
|
|
|
|
|
default_conf['strategy'] = 'DefaultStrategy'
|
|
|
|
|
extra_dir = Path.cwd() / 'some/path'
|
|
|
|
|
strategy = StrategyResolver._load_strategy('DefaultStrategy', config=default_conf,
|
|
|
|
|
extra_dir=extra_dir)
|
|
|
|
|
with pytest.raises(OperationalException):
|
|
|
|
|
StrategyResolver._load_strategy('DefaultStrategy', config=default_conf,
|
|
|
|
|
extra_dir=extra_dir)
|
|
|
|
|
|
|
|
|
|
assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog)
|
|
|
|
|
|
|
|
|
|
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_load_not_found_strategy(default_conf):
|
|
|
|
|
default_conf['strategy'] = 'NotFoundStrategy'
|
|
|
|
|
@ -326,7 +324,7 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
|
|
|
|
|
|
|
|
|
@pytest.mark.filterwarnings("ignore:deprecated")
|
|
|
|
|
def test_deprecate_populate_indicators(result, default_conf):
|
|
|
|
|
default_location = path.join(path.dirname(path.realpath(__file__)))
|
|
|
|
|
default_location = Path(__file__).parent / "strats"
|
|
|
|
|
default_conf.update({'strategy': 'TestStrategyLegacy',
|
|
|
|
|
'strategy_path': default_location})
|
|
|
|
|
strategy = StrategyResolver.load_strategy(default_conf)
|
|
|
|
|
@ -360,7 +358,7 @@ def test_deprecate_populate_indicators(result, default_conf):
|
|
|
|
|
|
|
|
|
|
@pytest.mark.filterwarnings("ignore:deprecated")
|
|
|
|
|
def test_call_deprecated_function(result, monkeypatch, default_conf):
|
|
|
|
|
default_location = path.join(path.dirname(path.realpath(__file__)))
|
|
|
|
|
default_location = Path(__file__).parent / "strats"
|
|
|
|
|
default_conf.update({'strategy': 'TestStrategyLegacy',
|
|
|
|
|
'strategy_path': default_location})
|
|
|
|
|
strategy = StrategyResolver.load_strategy(default_conf)
|
|
|
|
|
|