Use filled, it's the safer choice when determining the filled amount.
This commit is contained in:
parent
b4aeb93a18
commit
981976681a
@ -898,7 +898,7 @@ class FreqtradeBot:
|
|||||||
Buy timeout - cancel order
|
Buy timeout - cancel order
|
||||||
:return: True if order was fully cancelled
|
:return: True if order was fully cancelled
|
||||||
"""
|
"""
|
||||||
if order['status'] != 'canceled':
|
if order['status'] not in ('canceled', 'closed'):
|
||||||
reason = "cancelled due to timeout"
|
reason = "cancelled due to timeout"
|
||||||
corder = self.exchange.cancel_order_with_result(trade.open_order_id, trade.pair,
|
corder = self.exchange.cancel_order_with_result(trade.open_order_id, trade.pair,
|
||||||
trade.amount)
|
trade.amount)
|
||||||
@ -909,7 +909,7 @@ class FreqtradeBot:
|
|||||||
|
|
||||||
logger.info('Buy order %s for %s.', reason, trade)
|
logger.info('Buy order %s for %s.', reason, trade)
|
||||||
|
|
||||||
if safe_value_fallback(corder, order, 'remaining', 'remaining') == order['amount']:
|
if safe_value_fallback(corder, order, 'filled', 'filled') == 0.0:
|
||||||
logger.info('Buy order fully cancelled. Removing %s from database.', trade)
|
logger.info('Buy order fully cancelled. Removing %s from database.', trade)
|
||||||
# if trade is not partially completed, just delete the trade
|
# if trade is not partially completed, just delete the trade
|
||||||
Trade.session.delete(trade)
|
Trade.session.delete(trade)
|
||||||
@ -921,8 +921,7 @@ class FreqtradeBot:
|
|||||||
# cancel_order may not contain the full order dict, so we need to fallback
|
# cancel_order may not contain the full order dict, so we need to fallback
|
||||||
# to the order dict aquired before cancelling.
|
# to the order dict aquired before cancelling.
|
||||||
# we need to fall back to the values from order if corder does not contain these keys.
|
# we need to fall back to the values from order if corder does not contain these keys.
|
||||||
trade.amount = order['amount'] - safe_value_fallback(corder, order,
|
trade.amount = safe_value_fallback(corder, order, 'filled', 'filled')
|
||||||
'remaining', 'remaining')
|
|
||||||
trade.stake_amount = trade.amount * trade.open_rate
|
trade.stake_amount = trade.amount * trade.open_rate
|
||||||
self.update_trade_state(trade, corder, trade.amount)
|
self.update_trade_state(trade, corder, trade.amount)
|
||||||
|
|
||||||
|
@ -2346,7 +2346,6 @@ def test_handle_timedout_limit_buy_exchanges(mocker, caplog, default_conf,
|
|||||||
assert log_has_re(r'Buy order fully cancelled. Removing .* from database\.', caplog)
|
assert log_has_re(r'Buy order fully cancelled. Removing .* from database\.', caplog)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('cancelorder', [
|
@pytest.mark.parametrize('cancelorder', [
|
||||||
{},
|
{},
|
||||||
{'remaining': None},
|
{'remaining': None},
|
||||||
|
Loading…
Reference in New Issue
Block a user