From 9fc0f8797d5b2e298452a150180de1077bb8c230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Sat, 19 Mar 2022 17:18:03 +0530 Subject: [PATCH 1/2] used decimal --- freqtrade/freqtradebot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index a92bc4a90..0fd1bb120 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -7,6 +7,7 @@ import traceback from datetime import datetime, timezone from math import isclose from threading import Lock +from decimal import Decimal from typing import Any, Dict, List, Optional, Tuple from freqtrade import __version__, constants @@ -481,7 +482,8 @@ class FreqtradeBot(LoggingMixin): if stake_amount is not None and stake_amount < 0.0: # We should decrease our position - amount = abs(stake_amount) / current_exit_rate + # Strategy should return value as Decimal. + amount = abs(float(Decimal(stake_amount) / Decimal(current_exit_rate))) if trade.amount - amount < min_stake_amount: logger.info('Remaining amount would be too small') return From 83d62d84b3c76597732f7fb3e718a240e6bf9c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Sat, 19 Mar 2022 17:22:01 +0530 Subject: [PATCH 2/2] Update test_exchange.py --- tests/exchange/test_exchange.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 61fd55e49..157f4c3a8 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -2055,8 +2055,9 @@ def test_get_sell_rate_orderbook_exception(default_conf, mocker, caplog): exchange = get_patched_exchange(mocker, default_conf) with pytest.raises(PricingError): exchange.get_rate(pair, refresh=True, side="sell") - assert log_has_re(rf"{pair} - Sell Price at location 1 from orderbook could not be determined\..*", - caplog) + assert log_has_re( + rf"{pair} - Sell Price at location 1 from orderbook " + rf"could not be determined\..*", caplog) def test_get_sell_rate_exception(default_conf, mocker, caplog):