Check minimal amount
This commit is contained in:
parent
90025d0ac4
commit
708320318c
@ -234,7 +234,7 @@ class FreqtradeBot(object):
|
|||||||
|
|
||||||
return final_list
|
return final_list
|
||||||
|
|
||||||
def get_target_bid(self, ticker: Dict[str, float]) -> Optional[float]:
|
def get_target_bid(self, ticker: Dict[str, float]) -> float:
|
||||||
"""
|
"""
|
||||||
Calculates bid target between current ask price and last price
|
Calculates bid target between current ask price and last price
|
||||||
:param ticker: Ticker to use for getting Ask and Last Price
|
:param ticker: Ticker to use for getting Ask and Last Price
|
||||||
@ -245,7 +245,7 @@ class FreqtradeBot(object):
|
|||||||
balance = self.config['bid_strategy']['ask_last_balance']
|
balance = self.config['bid_strategy']['ask_last_balance']
|
||||||
return ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
return ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
||||||
|
|
||||||
def _get_trade_stake_amount(self) -> float:
|
def _get_trade_stake_amount(self) -> Optional[float]:
|
||||||
stake_amount = self.config['stake_amount']
|
stake_amount = self.config['stake_amount']
|
||||||
avaliable_amount = exchange.get_balance(self.config['stake_currency'])
|
avaliable_amount = exchange.get_balance(self.config['stake_currency'])
|
||||||
|
|
||||||
@ -254,7 +254,13 @@ class FreqtradeBot(object):
|
|||||||
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')
|
||||||
return None
|
return None
|
||||||
return avaliable_amount / (self.config['max_open_trades'] - open_trades)
|
trade_stake_amount = avaliable_amount / (self.config['max_open_trades'] - open_trades)
|
||||||
|
if trade_stake_amount < 0.0005:
|
||||||
|
raise DependencyException(
|
||||||
|
'Available balance(%f %s) is lower than minimal' % (
|
||||||
|
avaliable_amount, self.config['stake_currency'])
|
||||||
|
)
|
||||||
|
return trade_stake_amount
|
||||||
|
|
||||||
# Check if stake_amount is fulfilled
|
# Check if stake_amount is fulfilled
|
||||||
if avaliable_amount < stake_amount:
|
if avaliable_amount < stake_amount:
|
||||||
|
@ -249,11 +249,21 @@ def test_get_trade_stake_amount_no_stake_amount(default_conf,
|
|||||||
get_balance=MagicMock(return_value=default_conf['stake_amount'] * 0.5)
|
get_balance=MagicMock(return_value=default_conf['stake_amount'] * 0.5)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# test defined stake amount
|
||||||
freqtrade = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(default_conf)
|
||||||
|
|
||||||
with pytest.raises(DependencyException, match=r'.*stake amount.*'):
|
with pytest.raises(DependencyException, match=r'.*stake amount.*'):
|
||||||
freqtrade._get_trade_stake_amount()
|
freqtrade._get_trade_stake_amount()
|
||||||
|
|
||||||
|
# test UNLIMITED_STAKE_AMOUNT
|
||||||
|
conf = deepcopy(default_conf)
|
||||||
|
conf['stake_amount'] = constants.UNLIMITED_STAKE_AMOUNT
|
||||||
|
conf['max_open_trades'] = 2
|
||||||
|
freqtrade = FreqtradeBot(conf)
|
||||||
|
|
||||||
|
with pytest.raises(DependencyException, match=r'.*is lower than minimal.*'):
|
||||||
|
freqtrade._get_trade_stake_amount()
|
||||||
|
|
||||||
|
|
||||||
def test_get_trade_stake_amount_unlimited_amount(default_conf,
|
def test_get_trade_stake_amount_unlimited_amount(default_conf,
|
||||||
ticker,
|
ticker,
|
||||||
|
Loading…
Reference in New Issue
Block a user