From 0a07dfc5cf7bad17af06c1e873e363fe72dd2d46 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 13 Aug 2019 10:20:32 +0200 Subject: [PATCH] Add test verifying that multiple trades are opened in one iteration --- freqtrade/tests/test_freqtradebot.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 43982fa5c..e8245d60b 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -697,6 +697,28 @@ def test_create_trade_no_signal(default_conf, fee, mocker) -> None: assert not freqtrade.create_trade() +@pytest.mark.parametrize("max_open", range(1, 5)) +def test_create_trade_multiple_trades(default_conf, ticker, + fee, markets, mocker, max_open) -> None: + patch_RPCManager(mocker) + patch_exchange(mocker) + default_conf['max_open_trades'] = max_open + mocker.patch.multiple( + 'freqtrade.exchange.Exchange', + get_ticker=ticker, + buy=MagicMock(return_value={'id': "12355555"}), + get_fee=fee, + markets=PropertyMock(return_value=markets) + ) + freqtrade = FreqtradeBot(default_conf) + patch_get_signal(freqtrade) + + freqtrade.create_trade() + + trades = Trade.get_open_trades() + assert len(trades) == max_open + + def test_process_trade_creation(default_conf, ticker, limit_buy_order, markets, fee, mocker, caplog) -> None: patch_RPCManager(mocker)