Change rel_tol to abs_tol to avoid surprises with high priced pairs
This commit is contained in:
parent
8d92f8b362
commit
43f2ef226c
@ -511,7 +511,7 @@ class FreqtradeBot:
|
|||||||
trade.pair.startswith(exectrade['fee']['currency'])):
|
trade.pair.startswith(exectrade['fee']['currency'])):
|
||||||
fee_abs += exectrade['fee']['cost']
|
fee_abs += exectrade['fee']['cost']
|
||||||
|
|
||||||
if not isclose(amount, order_amount, rel_tol=constants.MATH_CLOSE_PREC):
|
if not isclose(amount, order_amount, abs_tol=constants.MATH_CLOSE_PREC):
|
||||||
logger.warning(f"Amount {amount} does not match amount {trade.amount}")
|
logger.warning(f"Amount {amount} does not match amount {trade.amount}")
|
||||||
raise OperationalException("Half bought? Amounts don't match")
|
raise OperationalException("Half bought? Amounts don't match")
|
||||||
real_amount = amount - fee_abs
|
real_amount = amount - fee_abs
|
||||||
@ -536,7 +536,7 @@ class FreqtradeBot:
|
|||||||
# Try update amount (binance-fix)
|
# Try update amount (binance-fix)
|
||||||
try:
|
try:
|
||||||
new_amount = self.get_real_amount(trade, order)
|
new_amount = self.get_real_amount(trade, order)
|
||||||
if not isclose(order['amount'], new_amount, rel_tol=constants.MATH_CLOSE_PREC):
|
if not isclose(order['amount'], new_amount, abs_tol=constants.MATH_CLOSE_PREC):
|
||||||
order['amount'] = new_amount
|
order['amount'] = new_amount
|
||||||
# Fee was applied, so set to 0
|
# Fee was applied, so set to 0
|
||||||
trade.fee_open = 0
|
trade.fee_open = 0
|
||||||
|
@ -3277,7 +3277,7 @@ def test_get_real_amount_wrong_amount_rounding(default_conf, trades_for_order, b
|
|||||||
|
|
||||||
# Amount changes by fee amount.
|
# Amount changes by fee amount.
|
||||||
assert isclose(freqtrade.get_real_amount(trade, limit_buy_order), amount - (amount * 0.001),
|
assert isclose(freqtrade.get_real_amount(trade, limit_buy_order), amount - (amount * 0.001),
|
||||||
rel_tol=MATH_CLOSE_PREC,)
|
abs_tol=MATH_CLOSE_PREC,)
|
||||||
|
|
||||||
|
|
||||||
def test_get_real_amount_invalid(default_conf, trades_for_order, buy_order_fee, mocker):
|
def test_get_real_amount_invalid(default_conf, trades_for_order, buy_order_fee, mocker):
|
||||||
|
Loading…
Reference in New Issue
Block a user