Merge pull request #1352 from freqtrade/combine_resolvers
Combine resolvers
This commit is contained in:
@@ -7,7 +7,7 @@ import pytest
|
||||
|
||||
from freqtrade.optimize.__init__ import load_tickerdata_file
|
||||
from freqtrade.optimize.hyperopt import Hyperopt, start
|
||||
from freqtrade.strategy.resolver import StrategyResolver
|
||||
from freqtrade.resolvers import StrategyResolver
|
||||
from freqtrade.tests.conftest import log_has, patch_exchange
|
||||
from freqtrade.tests.optimize.test_backtesting import get_args
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
import logging
|
||||
from base64 import urlsafe_b64encode
|
||||
from os import path
|
||||
from pathlib import Path
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
@@ -10,7 +11,7 @@ from pandas import DataFrame
|
||||
from freqtrade.strategy import import_strategy
|
||||
from freqtrade.strategy.default_strategy import DefaultStrategy
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
from freqtrade.strategy.resolver import StrategyResolver
|
||||
from freqtrade.resolvers import StrategyResolver
|
||||
|
||||
|
||||
def test_import_strategy(caplog):
|
||||
@@ -40,21 +41,21 @@ def test_import_strategy(caplog):
|
||||
|
||||
def test_search_strategy():
|
||||
default_config = {}
|
||||
default_location = path.join(path.dirname(
|
||||
path.realpath(__file__)), '..', '..', 'strategy'
|
||||
)
|
||||
default_location = Path(__file__).parent.parent.joinpath('strategy').resolve()
|
||||
assert isinstance(
|
||||
StrategyResolver._search_strategy(
|
||||
default_location,
|
||||
config=default_config,
|
||||
strategy_name='DefaultStrategy'
|
||||
StrategyResolver._search_object(
|
||||
directory=default_location,
|
||||
object_type=IStrategy,
|
||||
kwargs={'config': default_config},
|
||||
object_name='DefaultStrategy'
|
||||
),
|
||||
IStrategy
|
||||
)
|
||||
assert StrategyResolver._search_strategy(
|
||||
default_location,
|
||||
config=default_config,
|
||||
strategy_name='NotFoundStrategy'
|
||||
assert StrategyResolver._search_object(
|
||||
directory=default_location,
|
||||
object_type=IStrategy,
|
||||
kwargs={'config': default_config},
|
||||
object_name='NotFoundStrategy'
|
||||
) is None
|
||||
|
||||
|
||||
@@ -77,7 +78,7 @@ def test_load_strategy_invalid_directory(result, caplog):
|
||||
resolver._load_strategy('TestStrategy', config={}, extra_dir=extra_dir)
|
||||
|
||||
assert (
|
||||
'freqtrade.strategy.resolver',
|
||||
'freqtrade.resolvers.strategy_resolver',
|
||||
logging.WARNING,
|
||||
'Path "{}" does not exist'.format(extra_dir),
|
||||
) in caplog.record_tuples
|
||||
@@ -128,7 +129,7 @@ def test_strategy_override_minimal_roi(caplog):
|
||||
resolver = StrategyResolver(config)
|
||||
|
||||
assert resolver.strategy.minimal_roi[0] == 0.5
|
||||
assert ('freqtrade.strategy.resolver',
|
||||
assert ('freqtrade.resolvers.strategy_resolver',
|
||||
logging.INFO,
|
||||
"Override strategy 'minimal_roi' with value in config file: {'0': 0.5}."
|
||||
) in caplog.record_tuples
|
||||
@@ -143,7 +144,7 @@ def test_strategy_override_stoploss(caplog):
|
||||
resolver = StrategyResolver(config)
|
||||
|
||||
assert resolver.strategy.stoploss == -0.5
|
||||
assert ('freqtrade.strategy.resolver',
|
||||
assert ('freqtrade.resolvers.strategy_resolver',
|
||||
logging.INFO,
|
||||
"Override strategy 'stoploss' with value in config file: -0.5."
|
||||
) in caplog.record_tuples
|
||||
@@ -159,7 +160,7 @@ def test_strategy_override_ticker_interval(caplog):
|
||||
resolver = StrategyResolver(config)
|
||||
|
||||
assert resolver.strategy.ticker_interval == 60
|
||||
assert ('freqtrade.strategy.resolver',
|
||||
assert ('freqtrade.resolvers.strategy_resolver',
|
||||
logging.INFO,
|
||||
"Override strategy 'ticker_interval' with value in config file: 60."
|
||||
) in caplog.record_tuples
|
||||
@@ -175,7 +176,7 @@ def test_strategy_override_process_only_new_candles(caplog):
|
||||
resolver = StrategyResolver(config)
|
||||
|
||||
assert resolver.strategy.process_only_new_candles
|
||||
assert ('freqtrade.strategy.resolver',
|
||||
assert ('freqtrade.resolvers.strategy_resolver',
|
||||
logging.INFO,
|
||||
"Override process_only_new_candles 'process_only_new_candles' "
|
||||
"with value in config file: True."
|
||||
@@ -201,7 +202,7 @@ def test_strategy_override_order_types(caplog):
|
||||
for method in ['buy', 'sell', 'stoploss']:
|
||||
assert resolver.strategy.order_types[method] == order_types[method]
|
||||
|
||||
assert ('freqtrade.strategy.resolver',
|
||||
assert ('freqtrade.resolvers.strategy_resolver',
|
||||
logging.INFO,
|
||||
"Override strategy 'order_types' with value in config file:"
|
||||
" {'buy': 'market', 'sell': 'limit', 'stoploss': 'limit'}."
|
||||
|
@@ -3,7 +3,7 @@
|
||||
import pandas
|
||||
|
||||
from freqtrade.optimize import load_data
|
||||
from freqtrade.strategy.resolver import StrategyResolver
|
||||
from freqtrade.resolvers import StrategyResolver
|
||||
|
||||
_pairs = ['ETH/BTC']
|
||||
|
||||
|
Reference in New Issue
Block a user