From 8d92f8b3624555bf50f8463ebe961653a1db2435 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 26 Sep 2019 07:04:56 +0200 Subject: [PATCH] Compare floats via isclose instead of == --- freqtrade/freqtradebot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index f56b1f2ea..c6d3d0f44 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -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