From fb755880fad8cc2e0b0145544117b7243eac26dd Mon Sep 17 00:00:00 2001 From: misagh Date: Wed, 28 Nov 2018 14:16:50 +0100 Subject: [PATCH] logs added in case stop loss on exchange is hit --- freqtrade/persistence.py | 1 + freqtrade/tests/test_freqtradebot.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index 26b0d9d93..64663a2fd 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -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}') diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 995a3e8ff..81ade608a 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -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