test: add test for bybit classic account behavior

related: #10872
This commit is contained in:
Matthias
2024-11-19 18:19:01 +01:00
parent e8c122d5ed
commit f545274a0e

View File

@@ -1,6 +1,8 @@
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest
from freqtrade.enums.marginmode import MarginMode from freqtrade.enums.marginmode import MarginMode
from freqtrade.enums.tradingmode import TradingMode from freqtrade.enums.tradingmode import TradingMode
from tests.conftest import EXMS, get_mock_coro, get_patched_exchange, log_has from tests.conftest import EXMS, get_mock_coro, get_patched_exchange, log_has
@@ -172,3 +174,26 @@ def test_bybit_fetch_order_canceled_empty(default_conf_usdt, mocker):
assert res2["filled"] == 0.0 assert res2["filled"] == 0.0
assert res2["amount"] == 20.0 assert res2["amount"] == 20.0
assert res2["status"] == "open" assert res2["status"] == "open"
@pytest.mark.parametrize(
"side,order_type,uta,tradingmode,expected",
[
("buy", "limit", False, "spot", True),
("buy", "limit", False, "futures", True),
("sell", "limit", False, "spot", True),
("sell", "limit", False, "futures", True),
("buy", "market", False, "spot", True),
("buy", "market", False, "futures", False),
("buy", "market", True, "spot", False),
("buy", "market", True, "futures", False),
],
)
def test_bybit__order_needs_price(
default_conf, mocker, side, order_type, uta, tradingmode, expected
):
exchange = get_patched_exchange(mocker, default_conf, exchange="bybit")
exchange.trading_mode = tradingmode
exchange.unified_account = uta
assert exchange._order_needs_price(side, order_type) == expected