Make _calculate_unlimited_stake_amount() a separate method
This commit is contained in:
parent
243bcb2368
commit
abaeab89aa
@ -220,15 +220,22 @@ class FreqtradeBot:
|
|||||||
stake_amount = self.config['stake_amount']
|
stake_amount = self.config['stake_amount']
|
||||||
|
|
||||||
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
|
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
|
||||||
open_trades = len(Trade.get_open_trades())
|
return self._calculate_unlimited_stake_amount()
|
||||||
if open_trades >= self.config['max_open_trades']:
|
|
||||||
logger.warning("Can't open a new trade: max number of trades is reached")
|
|
||||||
return None
|
|
||||||
available_amount = self.wallets.get_free(self.config['stake_currency'])
|
|
||||||
return available_amount / (self.config['max_open_trades'] - open_trades)
|
|
||||||
|
|
||||||
return self._check_available_stake_amount(stake_amount)
|
return self._check_available_stake_amount(stake_amount)
|
||||||
|
|
||||||
|
def _calculate_unlimited_stake_amount(self) -> Optional[float]:
|
||||||
|
"""
|
||||||
|
Calculate stake amount for "unlimited" stake amount
|
||||||
|
:return: None if max number of trades reached
|
||||||
|
"""
|
||||||
|
open_trades = len(Trade.get_open_trades())
|
||||||
|
if open_trades >= self.config['max_open_trades']:
|
||||||
|
logger.warning("Can't open a new trade: max number of trades is reached")
|
||||||
|
return None
|
||||||
|
available_amount = self.wallets.get_free(self.config['stake_currency'])
|
||||||
|
return available_amount / (self.config['max_open_trades'] - open_trades)
|
||||||
|
|
||||||
def _check_available_stake_amount(self, stake_amount) -> float:
|
def _check_available_stake_amount(self, stake_amount) -> float:
|
||||||
"""
|
"""
|
||||||
Check if stake amount can be fulfilled with the available balance
|
Check if stake amount can be fulfilled with the available balance
|
||||||
|
Loading…
Reference in New Issue
Block a user