Remove Singleton from Strategy()

This commit is contained in:
Gerald Lonlas
2018-02-06 20:22:17 -08:00
parent 4da033c7a2
commit db67b10605
5 changed files with 30 additions and 40 deletions

View File

@@ -21,7 +21,6 @@ def test_search_strategy():
def test_strategy_structure():
assert hasattr(Strategy, 'init')
assert hasattr(Strategy, 'populate_indicators')
assert hasattr(Strategy, 'populate_buy_trend')
assert hasattr(Strategy, 'populate_sell_trend')
@@ -53,8 +52,7 @@ def test_load_not_found_strategy(caplog):
def test_strategy(result):
strategy = Strategy()
strategy.init({'strategy': 'default_strategy'})
strategy = Strategy({'strategy': 'default_strategy'})
assert hasattr(strategy.custom_strategy, 'minimal_roi')
assert strategy.minimal_roi['0'] == 0.04
@@ -82,8 +80,7 @@ def test_strategy_override_minimal_roi(caplog):
"0": 0.5
}
}
strategy = Strategy()
strategy.init(config)
strategy = Strategy(config)
assert hasattr(strategy.custom_strategy, 'minimal_roi')
assert strategy.minimal_roi['0'] == 0.5
@@ -99,8 +96,7 @@ def test_strategy_override_stoploss(caplog):
'strategy': 'default_strategy',
'stoploss': -0.5
}
strategy = Strategy()
strategy.init(config)
strategy = Strategy(config)
assert hasattr(strategy.custom_strategy, 'stoploss')
assert strategy.stoploss == -0.5
@@ -117,8 +113,7 @@ def test_strategy_override_ticker_interval(caplog):
'strategy': 'default_strategy',
'ticker_interval': 60
}
strategy = Strategy()
strategy.init(config)
strategy = Strategy(config)
assert hasattr(strategy.custom_strategy, 'ticker_interval')
assert strategy.ticker_interval == 60
@@ -138,8 +133,7 @@ def test_strategy_fallback_default_strategy():
def test_strategy_singleton():
strategy1 = Strategy()
strategy1.init({'strategy': 'default_strategy'})
strategy1 = Strategy({'strategy': 'default_strategy'})
assert hasattr(strategy1.custom_strategy, 'minimal_roi')
assert strategy1.minimal_roi['0'] == 0.04

View File

@@ -10,13 +10,14 @@ def test_constant_object() -> None:
Test the Constants object has the mandatory Constants
:return: None
"""
constant = Constants()
assert hasattr(constant, 'CONF_SCHEMA')
assert hasattr(constant, 'DYNAMIC_WHITELIST')
assert hasattr(constant, 'PROCESS_THROTTLE_SECS')
assert hasattr(constant, 'TICKER_INTERVAL')
assert hasattr(constant, 'HYPEROPT_EPOCH')
assert hasattr(constant, 'RETRY_TIMEOUT')
assert hasattr(Constants, 'CONF_SCHEMA')
assert hasattr(Constants, 'DYNAMIC_WHITELIST')
assert hasattr(Constants, 'PROCESS_THROTTLE_SECS')
assert hasattr(Constants, 'TICKER_INTERVAL')
assert hasattr(Constants, 'HYPEROPT_EPOCH')
assert hasattr(Constants, 'RETRY_TIMEOUT')
assert hasattr(Constants, 'DEFAULT_STRATEGY')
def test_conf_schema() -> None: