Compare floats via isclose instead of ==
This commit is contained in:
parent
49f0a72121
commit
8d92f8b362
@ -6,6 +6,7 @@ import copy
|
||||
import logging
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from math import isclose
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import arrow
|
||||
@ -510,7 +511,7 @@ class FreqtradeBot:
|
||||
trade.pair.startswith(exectrade['fee']['currency'])):
|
||||
fee_abs += exectrade['fee']['cost']
|
||||
|
||||
if amount != order_amount:
|
||||
if not isclose(amount, order_amount, rel_tol=constants.MATH_CLOSE_PREC):
|
||||
logger.warning(f"Amount {amount} does not match amount {trade.amount}")
|
||||
raise OperationalException("Half bought? Amounts don't match")
|
||||
real_amount = amount - fee_abs
|
||||
@ -535,7 +536,7 @@ class FreqtradeBot:
|
||||
# Try update amount (binance-fix)
|
||||
try:
|
||||
new_amount = self.get_real_amount(trade, order)
|
||||
if order['amount'] != new_amount:
|
||||
if not isclose(order['amount'], new_amount, rel_tol=constants.MATH_CLOSE_PREC):
|
||||
order['amount'] = new_amount
|
||||
# Fee was applied, so set to 0
|
||||
trade.fee_open = 0
|
||||
|
Loading…
Reference in New Issue
Block a user