|
4 | 4 | import ccxt |
5 | 5 | import pytest |
6 | 6 |
|
7 | | -from freqtrade.enums import CandleType, MarginMode, TradingMode |
| 7 | +from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode |
8 | 8 | from freqtrade.exceptions import RetryableOrderError, TemporaryError |
9 | 9 | from freqtrade.exchange.common import API_RETRY_COUNT |
10 | 10 | from freqtrade.exchange.exchange import timeframe_to_minutes |
@@ -681,6 +681,26 @@ def test__get_stop_params_okx(mocker, default_conf): |
681 | 681 | assert params["posSide"] == "net" |
682 | 682 |
|
683 | 683 |
|
| 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 | + |
684 | 704 | def test_fetch_orders_okx(default_conf, mocker, limit_order): |
685 | 705 | api_mock = MagicMock() |
686 | 706 | api_mock.fetch_orders = MagicMock( |
|
0 commit comments