From 4ffc74d5facac4ee9243bdf355421de34cdbfe6c Mon Sep 17 00:00:00 2001 From: misagh Date: Tue, 27 Nov 2018 19:05:59 +0100 Subject: [PATCH] if buy order is rejected or expired the bot should exit the buy loop --- freqtrade/freqtradebot.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 7258413f1..c5edc71ae 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -474,9 +474,21 @@ class FreqtradeBot(object): amount = stake_amount / buy_limit - order_id = self.exchange.buy(pair=pair, ordertype=self.strategy.order_types['buy'], + order = self.exchange.buy(pair=pair, ordertype=self.strategy.order_types['buy'], amount=amount, rate=buy_limit, - time_in_force=self.strategy.order_time_in_force['buy'])['id'] + time_in_force=self.strategy.order_time_in_force['buy']) + order_id = order['id'] + order_info = order['info'] + + # check if order is expired (in case of FOC or IOC orders) + # or rejected by the exchange. + if order_info['status'] == 'EXPIRED' or order_info['status'] == 'REJECTED': + order_type = self.strategy.order_types['buy'] + status = order_info['status'] + logger.warning('Buy %s order for %s is %s by %s.', + order_type, pair_s, status, self.exchange.name) + return False + self.rpc.send_msg({ 'type': RPCMessageType.BUY_NOTIFICATION,