Merge pull request #3281 from freqtrade/sell_order_cancel_exception
Sell order cancel exception
This commit is contained in:
commit
f64209e426
@ -949,8 +949,12 @@ class FreqtradeBot:
|
|||||||
if order['remaining'] == order['amount'] or order.get('filled') == 0.0:
|
if order['remaining'] == order['amount'] or order.get('filled') == 0.0:
|
||||||
if not self.exchange.check_order_canceled_empty(order):
|
if not self.exchange.check_order_canceled_empty(order):
|
||||||
reason = "cancelled due to timeout"
|
reason = "cancelled due to timeout"
|
||||||
# if trade is not partially completed, just delete the trade
|
try:
|
||||||
self.exchange.cancel_order(trade.open_order_id, trade.pair)
|
# if trade is not partially completed, just delete the trade
|
||||||
|
self.exchange.cancel_order(trade.open_order_id, trade.pair)
|
||||||
|
except InvalidOrderException:
|
||||||
|
logger.exception(f"Could not cancel sell order {trade.open_order_id}")
|
||||||
|
return 'error cancelling order'
|
||||||
logger.info('Sell order %s for %s.', reason, trade)
|
logger.info('Sell order %s for %s.', reason, trade)
|
||||||
else:
|
else:
|
||||||
reason = "cancelled on exchange"
|
reason = "cancelled on exchange"
|
||||||
|
@ -2405,6 +2405,21 @@ def test_handle_timedout_limit_sell(mocker, default_conf) -> None:
|
|||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_handle_timedout_limit_sell_cancel_exception(mocker, default_conf) -> None:
|
||||||
|
patch_RPCManager(mocker)
|
||||||
|
patch_exchange(mocker)
|
||||||
|
mocker.patch(
|
||||||
|
'freqtrade.exchange.Exchange.cancel_order', side_effect=InvalidOrderException())
|
||||||
|
|
||||||
|
freqtrade = FreqtradeBot(default_conf)
|
||||||
|
|
||||||
|
trade = MagicMock()
|
||||||
|
order = {'remaining': 1,
|
||||||
|
'amount': 1,
|
||||||
|
'status': "open"}
|
||||||
|
assert freqtrade.handle_timedout_limit_sell(trade, order) == 'error cancelling order'
|
||||||
|
|
||||||
|
|
||||||
def test_execute_sell_up(default_conf, ticker, fee, ticker_sell_up, mocker) -> None:
|
def test_execute_sell_up(default_conf, ticker, fee, ticker_sell_up, mocker) -> None:
|
||||||
rpc_mock = patch_RPCManager(mocker)
|
rpc_mock = patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
|
Loading…
Reference in New Issue
Block a user