diff --git a/freqtrade/arguments.py b/freqtrade/arguments.py index 97c3d8cb2..1ae805ca5 100644 --- a/freqtrade/arguments.py +++ b/freqtrade/arguments.py @@ -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 diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index b1928a4d5..49c179907 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -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 diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index d91dd4720..581e76406 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -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: """