logs added in case stop loss on exchange is hit

This commit is contained in:
misagh 2018-11-28 14:16:50 +01:00
parent da94e97c60
commit fb755880fa
2 changed files with 3 additions and 1 deletions

View File

@ -255,6 +255,7 @@ class Trade(_DECL_BASE):
self.close(order['price'])
elif order_type == 'stop_loss_limit':
self.stoploss_order_id = None
logger.info('STOP_LOSS_LIMIT is hit for %s.', self)
self.close(order['price'])
else:
raise ValueError(f'Unknown order type: {order_type}')

View File

@ -899,7 +899,7 @@ def test_add_stoploss_on_exchange(mocker, default_conf, limit_buy_order) -> None
assert trade.is_open is True
def test_handle_stoploss_on_exchange(mocker, default_conf, fee,
def test_handle_stoploss_on_exchange(mocker, default_conf, fee, caplog,
markets, limit_buy_order, limit_sell_order) -> None:
stoploss_limit = MagicMock(return_value={'id': 13434334})
patch_RPCManager(mocker)
@ -961,6 +961,7 @@ def test_handle_stoploss_on_exchange(mocker, default_conf, fee,
})
mocker.patch('freqtrade.exchange.Exchange.get_order', stoploss_order_hit)
assert freqtrade.handle_stoploss_on_exchange(trade) is True
assert log_has('STOP_LOSS_LIMIT is hit for {}.'.format(trade), caplog.record_tuples)
assert trade.stoploss_order_id is None
assert trade.is_open is False