Fix review comments

This commit is contained in:
Anton 2018-06-06 00:14:28 +03:00
parent 3030bf9778
commit 12d8a8b1a3
3 changed files with 14 additions and 8 deletions

View File

@ -239,17 +239,15 @@ class Arguments(object):
stop: Optional[int] = None stop: Optional[int] = None
if stype[0]: if stype[0]:
starts = rvals[index] starts = rvals[index]
if stype[0] == 'date': if stype[0] == 'date' and len(starts) == 8:
start = int(starts) if len(starts) == 10 \ start = arrow.get(starts, 'YYYYMMDD').timestamp
else arrow.get(starts, 'YYYYMMDD').timestamp
else: else:
start = int(starts) start = int(starts)
index += 1 index += 1
if stype[1]: if stype[1]:
stops = rvals[index] stops = rvals[index]
if stype[1] == 'date': if stype[1] == 'date' and len(stops) == 8:
stop = int(stops) if len(stops) == 10 \ stop = arrow.get(stops, 'YYYYMMDD').timestamp
else arrow.get(stops, 'YYYYMMDD').timestamp
else: else:
stop = int(stops) stop = int(stops)
return stype, start, stop return stype, start, stop

View File

@ -258,14 +258,16 @@ class FreqtradeBot(object):
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT: if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
open_trades = len(Trade.query.filter(Trade.is_open.is_(True)).all()) 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 0
return avaliable_amount / (self.config['max_open_trades'] - open_trades) return avaliable_amount / (self.config['max_open_trades'] - open_trades)
# Check if stake_amount is fulfilled # Check if stake_amount is fulfilled
if avaliable_amount < stake_amount: if avaliable_amount < stake_amount:
raise DependencyException( 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 return stake_amount

View File

@ -301,6 +301,12 @@ def test_get_trade_stake_amount_unlimited_amount(default_conf,
result = freqtrade._get_trade_stake_amount() result = freqtrade._get_trade_stake_amount()
assert(result == 0) 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: def test_create_trade_no_stake_amount(default_conf, ticker, limit_buy_order, fee, mocker) -> None:
""" """