Skip to content

Commit 81e4e0d

Browse files
committed
test(okx): add unit test for stop_price_type_value_mapping
1 parent a3e9752 commit 81e4e0d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/exchange/test_okx.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import ccxt
55
import pytest
66

7-
from freqtrade.enums import CandleType, MarginMode, TradingMode
7+
from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode
88
from freqtrade.exceptions import RetryableOrderError, TemporaryError
99
from freqtrade.exchange.common import API_RETRY_COUNT
1010
from freqtrade.exchange.exchange import timeframe_to_minutes
@@ -681,6 +681,26 @@ def test__get_stop_params_okx(mocker, default_conf):
681681
assert params["posSide"] == "net"
682682

683683

684+
def test_okx_stop_price_type_mapping(mocker, default_conf):
685+
"""
686+
Test that OKX stop_price_type_value_mapping correctly maps PriceType values.
687+
PriceType.MARK should map to "mark", PriceType.INDEX should map to "index".
688+
"""
689+
default_conf["trading_mode"] = "futures"
690+
default_conf["margin_mode"] = "isolated"
691+
exchange = get_patched_exchange(mocker, default_conf, exchange="okx")
692+
693+
# Verify the mapping is correct
694+
mapping = exchange._ft_has.get("stop_price_type_value_mapping", {})
695+
696+
assert mapping.get(PriceType.LAST) == "last"
697+
assert mapping.get(PriceType.MARK) == "mark"
698+
assert mapping.get(PriceType.INDEX) == "index"
699+
700+
# Verify stop_price_type_field is set correctly
701+
assert exchange._ft_has.get("stop_price_type_field") == "slTriggerPxType"
702+
703+
684704
def test_fetch_orders_okx(default_conf, mocker, limit_order):
685705
api_mock = MagicMock()
686706
api_mock.fetch_orders = MagicMock(

0 commit comments

Comments
 (0)