strategy: remove unneeded population methods in resolver

This commit is contained in:
gcarq
2018-03-24 23:20:21 +01:00
parent 1cec06f808
commit 280886104c
3 changed files with 37 additions and 79 deletions

View File

@@ -19,15 +19,15 @@ def test_search_strategy():
def test_load_strategy(result):
strategy = StrategyResolver()
resolver = StrategyResolver()
assert not hasattr(StrategyResolver, 'custom_strategy')
strategy._load_strategy('TestStrategy')
resolver._load_strategy('TestStrategy')
assert not hasattr(StrategyResolver, 'custom_strategy')
assert hasattr(strategy.custom_strategy, 'populate_indicators')
assert 'adx' in strategy.populate_indicators(result)
assert hasattr(resolver.strategy, 'populate_indicators')
assert 'adx' in resolver.strategy.populate_indicators(result)
def test_load_not_found_strategy(caplog):
@@ -42,23 +42,23 @@ def test_load_not_found_strategy(caplog):
def test_strategy(result):
strategy = StrategyResolver({'strategy': 'DefaultStrategy'})
resolver = StrategyResolver({'strategy': 'DefaultStrategy'})
assert hasattr(strategy.custom_strategy, 'minimal_roi')
assert strategy.minimal_roi[0] == 0.04
assert hasattr(resolver.strategy, 'minimal_roi')
assert resolver.strategy.minimal_roi[0] == 0.04
assert hasattr(strategy.custom_strategy, 'stoploss')
assert strategy.stoploss == -0.10
assert hasattr(resolver.strategy, 'stoploss')
assert resolver.strategy.stoploss == -0.10
assert hasattr(strategy.custom_strategy, 'populate_indicators')
assert 'adx' in strategy.populate_indicators(result)
assert hasattr(resolver.strategy, 'populate_indicators')
assert 'adx' in resolver.strategy.populate_indicators(result)
assert hasattr(strategy.custom_strategy, 'populate_buy_trend')
dataframe = strategy.populate_buy_trend(strategy.populate_indicators(result))
assert hasattr(resolver.strategy, 'populate_buy_trend')
dataframe = resolver.strategy.populate_buy_trend(resolver.strategy.populate_indicators(result))
assert 'buy' in dataframe.columns
assert hasattr(strategy.custom_strategy, 'populate_sell_trend')
dataframe = strategy.populate_sell_trend(strategy.populate_indicators(result))
assert hasattr(resolver.strategy, 'populate_sell_trend')
dataframe = resolver.strategy.populate_sell_trend(resolver.strategy.populate_indicators(result))
assert 'sell' in dataframe.columns
@@ -70,10 +70,10 @@ def test_strategy_override_minimal_roi(caplog):
"0": 0.5
}
}
strategy = StrategyResolver(config)
resolver = StrategyResolver(config)
assert hasattr(strategy.custom_strategy, 'minimal_roi')
assert strategy.minimal_roi[0] == 0.5
assert hasattr(resolver.strategy, 'minimal_roi')
assert resolver.strategy.minimal_roi[0] == 0.5
assert ('freqtrade.strategy.resolver',
logging.INFO,
'Override strategy \'minimal_roi\' with value in config file.'
@@ -86,10 +86,10 @@ def test_strategy_override_stoploss(caplog):
'strategy': 'DefaultStrategy',
'stoploss': -0.5
}
strategy = StrategyResolver(config)
resolver = StrategyResolver(config)
assert hasattr(strategy.custom_strategy, 'stoploss')
assert strategy.stoploss == -0.5
assert hasattr(resolver.strategy, 'stoploss')
assert resolver.strategy.stoploss == -0.5
assert ('freqtrade.strategy.resolver',
logging.INFO,
'Override strategy \'stoploss\' with value in config file: -0.5.'
@@ -103,10 +103,10 @@ def test_strategy_override_ticker_interval(caplog):
'strategy': 'DefaultStrategy',
'ticker_interval': 60
}
strategy = StrategyResolver(config)
resolver = StrategyResolver(config)
assert hasattr(strategy.custom_strategy, 'ticker_interval')
assert strategy.ticker_interval == 60
assert hasattr(resolver.strategy, 'ticker_interval')
assert resolver.strategy.ticker_interval == 60
assert ('freqtrade.strategy.resolver',
logging.INFO,
'Override strategy \'ticker_interval\' with value in config file: 60.'
@@ -120,14 +120,3 @@ def test_strategy_fallback_default_strategy():
assert not hasattr(StrategyResolver, 'custom_strategy')
strategy._load_strategy('../../super_duper')
assert not hasattr(StrategyResolver, 'custom_strategy')
def test_strategy_singleton():
strategy1 = StrategyResolver({'strategy': 'DefaultStrategy'})
assert hasattr(strategy1.custom_strategy, 'minimal_roi')
assert strategy1.minimal_roi[0] == 0.04
strategy2 = StrategyResolver()
assert hasattr(strategy2.custom_strategy, 'minimal_roi')
assert strategy2.minimal_roi[0] == 0.04