vnpy_okx 2026.1.11__py3-none-any.whl → 2026.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vnpy_okx/__init__.py CHANGED
@@ -23,7 +23,7 @@
23
23
  from .okx_gateway import OkxGateway
24
24
 
25
25
 
26
- __version__ = "2026.01.11"
26
+ __version__ = "2026.02.05"
27
27
 
28
28
 
29
29
  __all__ = ["OkxGateway"]
vnpy_okx/okx_gateway.py CHANGED
@@ -513,6 +513,13 @@ class RestApi(RestClient):
513
513
  Returns:
514
514
  Request: Modified request with authentication parameters
515
515
  """
516
+ # Add simulated trading header for demo server (applies to all requests)
517
+ if self.simulated:
518
+ if not request.headers:
519
+ request.headers = {"x-simulated-trading": "1"}
520
+ else:
521
+ request.headers["x-simulated-trading"] = "1"
522
+
516
523
  # Public API does not need to sign
517
524
  if "public" in request.path:
518
525
  return request
@@ -740,7 +747,11 @@ class RestApi(RestClient):
740
747
  base, quote, _ = name.split("-")
741
748
  symbol = base + quote + "_SWAP_OKX"
742
749
  case Product.FUTURES:
743
- base, quote, expiry = name.split("-")
750
+ symbol_parts: list[str] = name.split("-")
751
+ if len(symbol_parts) < 3:
752
+ continue
753
+
754
+ base, quote, expiry = symbol_parts
744
755
  symbol = base + quote + "_" + expiry + "_OKX"
745
756
 
746
757
  if d["tickSz"]:
@@ -859,6 +870,8 @@ class RestApi(RestClient):
859
870
  request: Original request object
860
871
  """
861
872
  detail: str = self.exception_detail(exc, value, tb, request)
873
+ # Escape curly braces to prevent loguru from interpreting them as format placeholders
874
+ detail = detail.replace("{", "{{").replace("}", "}}")
862
875
 
863
876
  msg: str = f"Exception catched by REST API: {detail}"
864
877
  self.gateway.write_log(msg)
@@ -1066,12 +1079,12 @@ class WebsocketApi(WebsocketClient):
1066
1079
  self.connected = True
1067
1080
  self.gateway.write_log(f"{self.name} connected")
1068
1081
 
1069
- def on_disconnected(self) -> None:
1082
+ def on_disconnected(self, status_code: int, msg: str) -> None:
1070
1083
  """
1071
1084
  Callback when server is disconnected.
1072
1085
  """
1073
1086
  self.connected = False
1074
- self.gateway.write_log(f"{self.name} disconnected")
1087
+ self.gateway.write_log(f"{self.name} disconnected, code: {status_code}, msg: {msg}")
1075
1088
 
1076
1089
  def on_message(self, message: str) -> None:
1077
1090
  """
@@ -1625,7 +1638,7 @@ class PrivateApi(WebsocketApi):
1625
1638
 
1626
1639
  # Prepare order parameters for OKX API
1627
1640
  arg: dict = {
1628
- "instId": contract.name,
1641
+ "instIdCode": contract.extra["instIdCode"], # type: ignore
1629
1642
  "clOrdId": orderid,
1630
1643
  "side": DIRECTION_VT2OKX[req.direction],
1631
1644
  "ordType": ORDERTYPE_VT2OKX[req.type],
@@ -1676,7 +1689,7 @@ class PrivateApi(WebsocketApi):
1676
1689
  return
1677
1690
 
1678
1691
  # Initialize cancel parameters
1679
- arg: dict = {"instId": contract.name}
1692
+ arg: dict = {"instIdCode": contract.extra["instIdCode"]} # type: ignore
1680
1693
 
1681
1694
  # Determine the type of order ID to use for cancellation
1682
1695
  # OKX supports both client order ID and exchange order ID for cancellation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vnpy_okx
3
- Version: 2026.1.11
3
+ Version: 2026.2.5
4
4
  Summary: OKX trading gateway for VeighNa.
5
5
  Project-URL: Homepage, https://www.github.com/veighna-global
6
6
  Project-URL: Source, https://www.github.com/veighna-global
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
33
33
  </p>
34
34
 
35
35
  <p align="center">
36
- <img src ="https://img.shields.io/badge/version-2025.12.28-blueviolet.svg"/>
36
+ <img src ="https://img.shields.io/badge/version-2026.02.05-blueviolet.svg"/>
37
37
  <img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
38
38
  <img src ="https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg" />
39
39
  <img src ="https://img.shields.io/github/license/veighna-global/vnpy_okx.svg?color=orange"/>
@@ -0,0 +1,7 @@
1
+ vnpy_okx/__init__.py,sha256=pxheVoMBN2-9IX-ybzwv_YK1veUv2SBthG3SDTT2RgE,1248
2
+ vnpy_okx/okx_gateway.py,sha256=U9gD-K52N0yEOgzVxzuyzpoGj48OxaYzAjM-G7g4nsg,73769
3
+ vnpy_okx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ vnpy_okx-2026.2.5.dist-info/METADATA,sha256=l3DiX2IL8GW0kcOm-8xD2inDLaylOd63Fr3tLxr9GzU,2839
5
+ vnpy_okx-2026.2.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ vnpy_okx-2026.2.5.dist-info/licenses/LICENSE,sha256=vKkW-EmD7w-5lDDjg15L8feZ1nkQeNpEHfyO2v9tprs,1099
7
+ vnpy_okx-2026.2.5.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- vnpy_okx/__init__.py,sha256=f6oPlp_8EDCCpyWTT16niwdAtKE3BmP3CkntE6NITGc,1248
2
- vnpy_okx/okx_gateway.py,sha256=9jRt6r5ReRAy15CnuF0cxR3d6f7jrtbHxxmAX5ofwNE,73037
3
- vnpy_okx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- vnpy_okx-2026.1.11.dist-info/METADATA,sha256=i6iIE4Sb-jNBO3t5YmY5dF4RQsZbFgE917kOkHtxY6I,2840
5
- vnpy_okx-2026.1.11.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- vnpy_okx-2026.1.11.dist-info/licenses/LICENSE,sha256=vKkW-EmD7w-5lDDjg15L8feZ1nkQeNpEHfyO2v9tprs,1099
7
- vnpy_okx-2026.1.11.dist-info/RECORD,,