Fix crash when no min-stake-amount could be determined

This commit is contained in:
Matthias 2022-02-02 12:20:05 +01:00
parent 5aa683006c
commit 0058abcc2d
2 changed files with 5 additions and 3 deletions

View File

@ -3,7 +3,7 @@
import logging
from copy import deepcopy
from typing import Any, Dict, NamedTuple
from typing import Any, Dict, NamedTuple, Optional
import arrow
@ -238,14 +238,15 @@ class Wallets:
return self._check_available_stake_amount(stake_amount, available_amount)
def validate_stake_amount(self, pair, stake_amount, min_stake_amount):
def validate_stake_amount(
self, pair: str, stake_amount: Optional[float], min_stake_amount: Optional[float]):
if not stake_amount:
logger.debug(f"Stake amount is {stake_amount}, ignoring possible trade for {pair}.")
return 0
max_stake_amount = self.get_available_stake_amount()
if min_stake_amount > max_stake_amount:
if min_stake_amount is not None and min_stake_amount > max_stake_amount:
if self._log:
logger.warning("Minimum stake amount > available balance.")
return 0

View File

@ -188,6 +188,7 @@ def test_get_trade_stake_amount_unlimited_amount(default_conf, ticker, balance_r
(9, 11, 100, 11), # Below min stake
(1, 15, 10, 0), # Below min stake and min_stake > max_stake
(20, 50, 100, 0), # Below min stake and stake * 1.3 > min_stake
(1000, None, 1000, 1000), # No min-stake-amount could be determined
])
def test_validate_stake_amount(mocker, default_conf,