From 5b0bc5bbc54d7122f677a8ff9b615238e7940622 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 26 Feb 2023 16:11:47 +0100 Subject: [PATCH] Don't "fix" dry-run kucoin orders closes #8229 --- freqtrade/exchange/kucoin.py | 5 +++-- tests/exchange/test_exchange.py | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/freqtrade/exchange/kucoin.py b/freqtrade/exchange/kucoin.py index 797d9fbd2..20e558513 100644 --- a/freqtrade/exchange/kucoin.py +++ b/freqtrade/exchange/kucoin.py @@ -64,6 +64,7 @@ class Kucoin(Exchange): # ccxt returns status = 'closed' at the moment - which is information ccxt invented. # Since we rely on status heavily, we must set it to 'open' here. # ref: https://github.com/ccxt/ccxt/pull/16674, (https://github.com/ccxt/ccxt/pull/16553) - res['type'] = ordertype - res['status'] = 'open' + if not self._config['dry_run']: + res['type'] = ordertype + res['status'] = 'open' return res diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 828bba16f..7ccd32155 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -27,7 +27,7 @@ from tests.conftest import (generate_test_data_raw, get_mock_coro, get_patched_e # Make sure to always keep one exchange here which is NOT subclassed!! -EXCHANGES = ['bittrex', 'binance', 'kraken', 'gate', 'bybit'] +EXCHANGES = ['bittrex', 'binance', 'kraken', 'gate', 'kucoin', 'bybit'] get_entry_rate_data = [ ('other', 20, 19, 10, 0.0, 20), # Full ask side @@ -1269,7 +1269,7 @@ def test_create_dry_run_order_limit_fill(default_conf, mocker, side, price, fill fetch_l2_order_book=order_book_l2_usd, ) - order = exchange.create_dry_run_order( + order = exchange.create_order( pair='LTC/USDT', ordertype='limit', side=side, @@ -1332,7 +1332,7 @@ def test_create_dry_run_order_market_fill(default_conf, mocker, side, rate, amou fetch_l2_order_book=order_book_l2_usd, ) - order = exchange.create_dry_run_order( + order = exchange.create_order( pair='LTC/USDT', ordertype='market', side=side, @@ -1425,9 +1425,10 @@ def test_create_order(default_conf, mocker, side, ordertype, rate, marketprice, assert order['amount'] == 0.01 -def test_buy_dry_run(default_conf, mocker): +@pytest.mark.parametrize("exchange_name", EXCHANGES) +def test_buy_dry_run(default_conf, mocker, exchange_name): default_conf['dry_run'] = True - exchange = get_patched_exchange(mocker, default_conf) + exchange = get_patched_exchange(mocker, default_conf, id=exchange_name) order = exchange.create_order(pair='ETH/BTC', ordertype='limit', side="buy", amount=1, rate=200, leverage=1.0,