From c8638ce82fae82e9558a292e6c9dc2a9dcbb7d70 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 5 Nov 2019 21:03:06 +0100 Subject: [PATCH] Fix bug where bids_to_ask_delta causes doublebuys The continue must happen irrespective of the outcome of this - otherwise the below BUY will happen anyway. --- freqtrade/freqtradebot.py | 3 +-- tests/test_freqtradebot.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 7206e555f..7e9706803 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -319,8 +319,7 @@ class FreqtradeBot: (bidstrat_check_depth_of_market.get('bids_to_ask_delta', 0) > 0): if self._check_depth_of_market_buy(_pair, bidstrat_check_depth_of_market): buycount += self.execute_buy(_pair, stake_amount) - else: - continue + continue buycount += self.execute_buy(_pair, stake_amount) diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 0ed8e8a77..f3baff7ce 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -3213,6 +3213,8 @@ def test_order_book_depth_of_market(default_conf, ticker, limit_buy_order, fee, assert trade.open_date is not None assert trade.exchange == 'bittrex' + assert len(Trade.query.all()) == 1 + # Simulate fulfilled LIMIT_BUY order for trade trade.update(limit_buy_order)