Don't return None from unlimited_stake - 0 handles this just as well
This commit is contained in:
@@ -250,12 +250,13 @@ class FreqtradeBot:
|
||||
|
||||
return used_rate
|
||||
|
||||
def get_trade_stake_amount(self, pair) -> Optional[float]:
|
||||
def get_trade_stake_amount(self, pair) -> float:
|
||||
"""
|
||||
Calculate stake amount for the trade
|
||||
:return: float: Stake amount
|
||||
:raise: DependencyException if the available stake amount is too low
|
||||
"""
|
||||
stake_amount: Optional[float]
|
||||
stake_amount: float
|
||||
if self.edge:
|
||||
stake_amount = self.edge.stake_amount(
|
||||
pair,
|
||||
@@ -286,20 +287,20 @@ class FreqtradeBot:
|
||||
self.config['tradable_balance_ratio']) - val_tied_up
|
||||
return available_amount
|
||||
|
||||
def _calculate_unlimited_stake_amount(self) -> Optional[float]:
|
||||
def _calculate_unlimited_stake_amount(self) -> float:
|
||||
"""
|
||||
Calculate stake amount for "unlimited" stake amount
|
||||
:return: None if max number of trades reached
|
||||
:return: 0 if max number of trades reached, else stake_amount to use.
|
||||
"""
|
||||
free_open_trades = self.get_free_open_trades()
|
||||
if not free_open_trades:
|
||||
return None
|
||||
return 0
|
||||
|
||||
available_amount = self._get_available_stake_amount()
|
||||
|
||||
return available_amount / free_open_trades
|
||||
|
||||
def _check_available_stake_amount(self, stake_amount: Optional[float]) -> Optional[float]:
|
||||
def _check_available_stake_amount(self, stake_amount: float) -> float:
|
||||
"""
|
||||
Check if stake amount can be fulfilled with the available balance
|
||||
for the stake currency
|
||||
@@ -307,7 +308,7 @@ class FreqtradeBot:
|
||||
"""
|
||||
available_amount = self._get_available_stake_amount()
|
||||
|
||||
if stake_amount is not None and available_amount < stake_amount:
|
||||
if available_amount < stake_amount:
|
||||
raise DependencyException(
|
||||
f"Available balance ({available_amount} {self.config['stake_currency']}) is "
|
||||
f"lower than stake amount ({stake_amount} {self.config['stake_currency']})"
|
||||
|
Reference in New Issue
Block a user