mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Fix review comments
This commit is contained in:
parent
3030bf9778
commit
12d8a8b1a3
|
@ -239,17 +239,15 @@ class Arguments(object):
|
|||
stop: Optional[int] = None
|
||||
if stype[0]:
|
||||
starts = rvals[index]
|
||||
if stype[0] == 'date':
|
||||
start = int(starts) if len(starts) == 10 \
|
||||
else arrow.get(starts, 'YYYYMMDD').timestamp
|
||||
if stype[0] == 'date' and len(starts) == 8:
|
||||
start = arrow.get(starts, 'YYYYMMDD').timestamp
|
||||
else:
|
||||
start = int(starts)
|
||||
index += 1
|
||||
if stype[1]:
|
||||
stops = rvals[index]
|
||||
if stype[1] == 'date':
|
||||
stop = int(stops) if len(stops) == 10 \
|
||||
else arrow.get(stops, 'YYYYMMDD').timestamp
|
||||
if stype[1] == 'date' and len(stops) == 8:
|
||||
stop = arrow.get(stops, 'YYYYMMDD').timestamp
|
||||
else:
|
||||
stop = int(stops)
|
||||
return stype, start, stop
|
||||
|
|
|
@ -258,14 +258,16 @@ class FreqtradeBot(object):
|
|||
|
||||
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
|
||||
open_trades = len(Trade.query.filter(Trade.is_open.is_(True)).all())
|
||||
if open_trades == self.config['max_open_trades']:
|
||||
if open_trades >= self.config['max_open_trades']:
|
||||
return 0
|
||||
return avaliable_amount / (self.config['max_open_trades'] - open_trades)
|
||||
|
||||
# Check if stake_amount is fulfilled
|
||||
if avaliable_amount < stake_amount:
|
||||
raise DependencyException(
|
||||
'stake amount is not fulfilled (currency={})'.format(self.config['stake_currency'])
|
||||
'Available balance(%f %s) is lower than stake amount(%f %s)' % (
|
||||
avaliable_amount, self.config['stake_currency'],
|
||||
stake_amount, self.config['stake_currency'])
|
||||
)
|
||||
|
||||
return stake_amount
|
||||
|
|
|
@ -301,6 +301,12 @@ def test_get_trade_stake_amount_unlimited_amount(default_conf,
|
|||
result = freqtrade._get_trade_stake_amount()
|
||||
assert(result == 0)
|
||||
|
||||
# set max_open_trades = 0, so do not trade
|
||||
conf['max_open_trades'] = 0
|
||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||
result = freqtrade._get_trade_stake_amount()
|
||||
assert(result == 0)
|
||||
|
||||
|
||||
def test_create_trade_no_stake_amount(default_conf, ticker, limit_buy_order, fee, mocker) -> None:
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user