-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Feature Request
Problem Statement
OKX has announced a breaking API change that affects WebSocket order operations. Starting from January 29, 2026 (demo environment) and February 3, 2026 (production environment), the instId request parameter will be deprecated in favor of instIdCode.
Currently, NautilusTrader v1.222.0 uses the instId parameter for WebSocket order operations, which now causes order rejections in the OKX demo environment with the error:
Parameter instIdCode can not be empty
Affected WebSocket channels:
- WS / Place order
- WS / Place multiple orders
- WS / Amend order
- WS / Amend multiple orders
- WS / Cancel order
- WS / Cancel multiple orders
Reference: OKX API Changelog - Delist instId request parameter
Proposed Solution
Update the OKX adapter to:
- Fetch
instIdCodewhen loading instruments via theGET /api/v5/public/instrumentsendpoint - Store the
instIdCodemapping in theOKXInstrumentProvider - Use
instIdCodeinstead of (or alongside)instIdin all WebSocket order operations
The instIdCode is available in the instruments endpoint response and can be mapped to instId during instrument loading.
Example Usage
# No changes needed in user code - the adapter should handle this internally
# The OKXInstrumentProvider should cache instIdCode from instruments response:
# GET /api/v5/public/instruments returns:
# {
# "instId": "BTC-USDT-SWAP",
# "instIdCode": 12345, # Numeric instrument ID code
# ...
# }
# When submitting orders via WebSocket, the adapter should use:
# {
# "instIdCode": 12345, # Instead of "instId": "BTC-USDT-SWAP"
# "tdMode": "isolated",
# "side": "buy",
# ...
# }Alternatives Considered
Send both instId and instIdCode: According to OKX docs, if both are provided, instIdCode takes precedence. This could be a transitional approach.
Additional Context
Test Environment:
- NautilusTrader version: 1.222.0
- Python: 3.12.11
- OKX Demo Mode:
is_demo=True - Test Date: 2026-01-29 (first day of deprecation in demo environment)
Error Log:
[WARN] TEST-TRADER-001.TESTTRADE: <--[EVT] OrderRejected(
instrument_id=BTC-USDT-SWAP.OKX,
client_order_id=O20260129081611001T1,
account_id=OKX-master,
reason='Parameter instIdCode can not be empty'
)
Timeline:
- Demo environment deprecation: January 29, 2026
- Production environment deprecation: February 3, 2026