Make _calculate_unlimited_stake_amount() a separate method

This commit is contained in:
hroff-1902 2019-12-28 02:36:32 +03:00
parent 243bcb2368
commit abaeab89aa

View File

@ -220,6 +220,15 @@ 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:
return self._calculate_unlimited_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()) open_trades = len(Trade.get_open_trades())
if open_trades >= self.config['max_open_trades']: if open_trades >= self.config['max_open_trades']:
logger.warning("Can't open a new trade: max number of trades is reached") logger.warning("Can't open a new trade: max number of trades is reached")
@ -227,8 +236,6 @@ class FreqtradeBot:
available_amount = self.wallets.get_free(self.config['stake_currency']) available_amount = self.wallets.get_free(self.config['stake_currency'])
return available_amount / (self.config['max_open_trades'] - open_trades) return available_amount / (self.config['max_open_trades'] - open_trades)
return self._check_available_stake_amount(stake_amount)
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