Merge pull request #2 from SmartManoj/patch-2

used decimal
This commit is contained in:
Kavinkumar 2022-03-19 17:23:01 +05:30 committed by GitHub
commit cff002f21c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import traceback
from datetime import datetime, timezone from datetime import datetime, timezone
from math import isclose from math import isclose
from threading import Lock from threading import Lock
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional, Tuple
from freqtrade import __version__, constants from freqtrade import __version__, constants
@ -481,7 +482,8 @@ class FreqtradeBot(LoggingMixin):
if stake_amount is not None and stake_amount < 0.0: if stake_amount is not None and stake_amount < 0.0:
# We should decrease our position # 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: if trade.amount - amount < min_stake_amount:
logger.info('Remaining amount would be too small') logger.info('Remaining amount would be too small')
return return

View File

@ -2055,8 +2055,9 @@ def test_get_sell_rate_orderbook_exception(default_conf, mocker, caplog):
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
with pytest.raises(PricingError): with pytest.raises(PricingError):
exchange.get_rate(pair, refresh=True, side="sell") 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\..*", assert log_has_re(
caplog) 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): def test_get_sell_rate_exception(default_conf, mocker, caplog):