mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-14 03:41:14 +00:00
test(okx): add unit test for stop_price_type_value_mapping
This commit is contained in:
@@ -4,7 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, PropertyMock
|
|||||||
import ccxt
|
import ccxt
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from freqtrade.enums import CandleType, MarginMode, TradingMode
|
from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode
|
||||||
from freqtrade.exceptions import RetryableOrderError, TemporaryError
|
from freqtrade.exceptions import RetryableOrderError, TemporaryError
|
||||||
from freqtrade.exchange.common import API_RETRY_COUNT
|
from freqtrade.exchange.common import API_RETRY_COUNT
|
||||||
from freqtrade.exchange.exchange import timeframe_to_minutes
|
from freqtrade.exchange.exchange import timeframe_to_minutes
|
||||||
@@ -681,6 +681,26 @@ def test__get_stop_params_okx(mocker, default_conf):
|
|||||||
assert params["posSide"] == "net"
|
assert params["posSide"] == "net"
|
||||||
|
|
||||||
|
|
||||||
|
def test_okx_stop_price_type_mapping(mocker, default_conf):
|
||||||
|
"""
|
||||||
|
Test that OKX stop_price_type_value_mapping correctly maps PriceType values.
|
||||||
|
PriceType.MARK should map to "mark", PriceType.INDEX should map to "index".
|
||||||
|
"""
|
||||||
|
default_conf["trading_mode"] = "futures"
|
||||||
|
default_conf["margin_mode"] = "isolated"
|
||||||
|
exchange = get_patched_exchange(mocker, default_conf, exchange="okx")
|
||||||
|
|
||||||
|
# Verify the mapping is correct
|
||||||
|
mapping = exchange._ft_has.get("stop_price_type_value_mapping", {})
|
||||||
|
|
||||||
|
assert mapping.get(PriceType.LAST) == "last"
|
||||||
|
assert mapping.get(PriceType.MARK) == "mark"
|
||||||
|
assert mapping.get(PriceType.INDEX) == "index"
|
||||||
|
|
||||||
|
# Verify stop_price_type_field is set correctly
|
||||||
|
assert exchange._ft_has.get("stop_price_type_field") == "slTriggerPxType"
|
||||||
|
|
||||||
|
|
||||||
def test_fetch_orders_okx(default_conf, mocker, limit_order):
|
def test_fetch_orders_okx(default_conf, mocker, limit_order):
|
||||||
api_mock = MagicMock()
|
api_mock = MagicMock()
|
||||||
api_mock.fetch_orders = MagicMock(
|
api_mock.fetch_orders = MagicMock(
|
||||||
|
|||||||
Reference in New Issue
Block a user