Convert amount to contracts before comparing for close

closes #7279
This commit is contained in:
Matthias
2022-08-22 20:48:02 +02:00
parent 78b161e14c
commit fe7108ae75
5 changed files with 22 additions and 11 deletions

View File

@@ -15,6 +15,7 @@ from freqtrade.constants import (DATETIME_PRINT_FORMAT, MATH_CLOSE_PREC, NON_OPE
from freqtrade.enums import ExitType, TradingMode
from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.exchange import amount_to_precision, price_to_precision
from freqtrade.exchange.exchange import amount_to_contracts, contracts_to_amount
from freqtrade.leverage import interest
from freqtrade.persistence.base import _DECL_BASE
from freqtrade.util import FtPrecise
@@ -624,7 +625,11 @@ class LocalTrade():
else:
logger.warning(
f'Got different open_order_id {self.open_order_id} != {order.order_id}')
amount_tr = amount_to_precision(self.amount, self.amount_precision, self.precision_mode)
amount_tr = contracts_to_amount(
amount_to_precision(
amount_to_contracts(self.amount, self.contract_size),
self.amount_precision, self.precision_mode),
self.contract_size)
if isclose(order.safe_amount_after_fee, amount_tr, abs_tol=MATH_CLOSE_PREC):
self.close(order.safe_price)
else: