From 6684bff9631f822ea12ee2c27cdd1619ae06b9c1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Jan 2022 15:23:08 +0100 Subject: [PATCH] Dry-run orders should have filled set correctly --- freqtrade/exchange/exchange.py | 2 ++ tests/exchange/test_exchange.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 36f5ecd39..ef9e395f5 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -612,6 +612,7 @@ class Exchange: 'cost': _amount * rate, 'type': ordertype, 'side': side, + 'filled': 0, 'remaining': _amount, 'datetime': arrow.utcnow().isoformat(), 'timestamp': arrow.utcnow().int_timestamp * 1000, @@ -627,6 +628,7 @@ class Exchange: average = self.get_dry_market_fill_price(pair, side, amount, rate) dry_order.update({ 'average': average, + 'filled': _amount, 'cost': dry_order['amount'] * average, }) dry_order = self.add_dry_order_fee(pair, dry_order) diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 071f4e2b8..33f34ba3c 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -1018,6 +1018,7 @@ def test_create_dry_run_order_limit_fill(default_conf, mocker, side, startprice, assert order_book_l2_usd.call_count == 1 assert order_closed['status'] == 'open' assert not order['fee'] + assert order_closed['filled'] == 0 order_book_l2_usd.reset_mock() order_closed['price'] = endprice @@ -1025,6 +1026,8 @@ def test_create_dry_run_order_limit_fill(default_conf, mocker, side, startprice, order_closed = exchange.fetch_dry_run_order(order['id']) assert order_closed['status'] == 'closed' assert order['fee'] + assert order_closed['filled'] == 1 + assert order_closed['filled'] == order_closed['amount'] # Empty orderbook test mocker.patch('freqtrade.exchange.Exchange.fetch_l2_order_book', @@ -1064,6 +1067,7 @@ def test_create_dry_run_order_market_fill(default_conf, mocker, side, rate, amou assert order["type"] == "market" assert order["symbol"] == "LTC/USDT" assert order['status'] == 'closed' + assert order['filled'] == amount assert round(order["average"], 4) == round(endprice, 4)