restore interface test file
This commit is contained in:
parent
3d8c3ffd38
commit
d9c9b7d7fc
@ -38,15 +38,20 @@ def test_returns_latest_signal(mocker, default_conf, ohlcv_history):
|
|||||||
mocked_history['buy'] = 0
|
mocked_history['buy'] = 0
|
||||||
mocked_history.loc[1, 'sell'] = 1
|
mocked_history.loc[1, 'sell'] = 1
|
||||||
|
|
||||||
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (False, True)
|
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (False, True, None)
|
||||||
mocked_history.loc[1, 'sell'] = 0
|
mocked_history.loc[1, 'sell'] = 0
|
||||||
mocked_history.loc[1, 'buy'] = 1
|
mocked_history.loc[1, 'buy'] = 1
|
||||||
|
|
||||||
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (True, False)
|
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (True, False, None)
|
||||||
mocked_history.loc[1, 'sell'] = 0
|
mocked_history.loc[1, 'sell'] = 0
|
||||||
mocked_history.loc[1, 'buy'] = 0
|
mocked_history.loc[1, 'buy'] = 0
|
||||||
|
|
||||||
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (False, False)
|
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (False, False, None)
|
||||||
|
mocked_history.loc[1, 'sell'] = 0
|
||||||
|
mocked_history.loc[1, 'buy'] = 1
|
||||||
|
mocked_history.loc[1, 'buy_tag'] = 'buy_signal_01'
|
||||||
|
|
||||||
|
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (True, False, 'buy_signal_01')
|
||||||
|
|
||||||
|
|
||||||
def test_analyze_pair_empty(default_conf, mocker, caplog, ohlcv_history):
|
def test_analyze_pair_empty(default_conf, mocker, caplog, ohlcv_history):
|
||||||
@ -63,15 +68,21 @@ def test_analyze_pair_empty(default_conf, mocker, caplog, ohlcv_history):
|
|||||||
|
|
||||||
|
|
||||||
def test_get_signal_empty(default_conf, mocker, caplog):
|
def test_get_signal_empty(default_conf, mocker, caplog):
|
||||||
assert (False, False) == _STRATEGY.get_signal('foo', default_conf['timeframe'], DataFrame())
|
assert (False, False, None) == _STRATEGY.get_signal(
|
||||||
|
'foo', default_conf['timeframe'], DataFrame()
|
||||||
|
)
|
||||||
assert log_has('Empty candle (OHLCV) data for pair foo', caplog)
|
assert log_has('Empty candle (OHLCV) data for pair foo', caplog)
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
|
|
||||||
assert (False, False) == _STRATEGY.get_signal('bar', default_conf['timeframe'], None)
|
assert (False, False, None) == _STRATEGY.get_signal('bar', default_conf['timeframe'], None)
|
||||||
assert log_has('Empty candle (OHLCV) data for pair bar', caplog)
|
assert log_has('Empty candle (OHLCV) data for pair bar', caplog)
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
|
|
||||||
assert (False, False) == _STRATEGY.get_signal('baz', default_conf['timeframe'], DataFrame([]))
|
assert (False, False, None) == _STRATEGY.get_signal(
|
||||||
|
'baz',
|
||||||
|
default_conf['timeframe'],
|
||||||
|
DataFrame([])
|
||||||
|
)
|
||||||
assert log_has('Empty candle (OHLCV) data for pair baz', caplog)
|
assert log_has('Empty candle (OHLCV) data for pair baz', caplog)
|
||||||
|
|
||||||
|
|
||||||
@ -107,7 +118,11 @@ def test_get_signal_old_dataframe(default_conf, mocker, caplog, ohlcv_history):
|
|||||||
caplog.set_level(logging.INFO)
|
caplog.set_level(logging.INFO)
|
||||||
mocker.patch.object(_STRATEGY, 'assert_df')
|
mocker.patch.object(_STRATEGY, 'assert_df')
|
||||||
|
|
||||||
assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['timeframe'], mocked_history)
|
assert (False, False, None) == _STRATEGY.get_signal(
|
||||||
|
'xyz',
|
||||||
|
default_conf['timeframe'],
|
||||||
|
mocked_history
|
||||||
|
)
|
||||||
assert log_has('Outdated history for pair xyz. Last tick is 16 minutes old', caplog)
|
assert log_has('Outdated history for pair xyz. Last tick is 16 minutes old', caplog)
|
||||||
|
|
||||||
|
|
||||||
@ -416,34 +431,6 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, traili
|
|||||||
strategy.custom_stoploss = original_stopvalue
|
strategy.custom_stoploss = original_stopvalue
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
'current_rate, expected_result, use_custom_entry_price, custom_entry', [
|
|
||||||
# current rate, expected result value, profit for 2nd call, enable trailing,
|
|
||||||
# enable custom stoploss, expected after 1st call, expected after 2nd call
|
|
||||||
(99, False, True, lambda current_rate, **kwargs: current_rate - (current_rate * 0.01)), # custom_entry_price pice - (price * 0.01)
|
|
||||||
(97.8, True, True, lambda current_rate, **kwargs: current_rate - (current_rate * 0.01)), # price stayed under entry price
|
|
||||||
(97.8, True, True, lambda current_rate, **kwargs: current_rate + (current_rate * 0.01)), # entry price over current price
|
|
||||||
(99.9, True, False, None), # feature not activated
|
|
||||||
])
|
|
||||||
def test_entry_price_reached(default_conf, current_rate, exp_custom_entry, candle_ohlc,
|
|
||||||
expected_result, use_custom_entry_price, custom_entry) -> None:
|
|
||||||
|
|
||||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
|
||||||
|
|
||||||
|
|
||||||
strategy = StrategyResolver.load_strategy(default_conf)
|
|
||||||
|
|
||||||
strategy.use_custom_entry_price = use_custom_entry_price
|
|
||||||
custom_entry_price = custom_entry
|
|
||||||
if use_custom_entry_price:
|
|
||||||
strategy.custom_entry_price = custom_entry(current_rate)
|
|
||||||
|
|
||||||
now = arrow.utcnow().datetime
|
|
||||||
entry_flag = strategy.entry_price_reached(current_rate=current_rate, low= None, high=None)
|
|
||||||
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_custom_sell(default_conf, fee, caplog) -> None:
|
def test_custom_sell(default_conf, fee, caplog) -> None:
|
||||||
|
|
||||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||||
|
Loading…
Reference in New Issue
Block a user