vnpy_okx 2025.11.8__py3-none-any.whl → 2025.12.22__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 +1 -1
- vnpy_okx/okx_gateway.py +14 -2
- vnpy_okx/py.typed +0 -0
- {vnpy_okx-2025.11.8.dist-info → vnpy_okx-2025.12.22.dist-info}/METADATA +2 -2
- vnpy_okx-2025.12.22.dist-info/RECORD +7 -0
- {vnpy_okx-2025.11.8.dist-info → vnpy_okx-2025.12.22.dist-info}/WHEEL +1 -1
- vnpy_okx-2025.11.8.dist-info/RECORD +0 -6
- {vnpy_okx-2025.11.8.dist-info → vnpy_okx-2025.12.22.dist-info}/licenses/LICENSE +0 -0
vnpy_okx/__init__.py
CHANGED
vnpy_okx/okx_gateway.py
CHANGED
|
@@ -9,6 +9,7 @@ from urllib.parse import urlencode
|
|
|
9
9
|
from types import TracebackType
|
|
10
10
|
from collections.abc import Callable
|
|
11
11
|
from time import sleep
|
|
12
|
+
from decimal import Decimal
|
|
12
13
|
|
|
13
14
|
from vnpy.event import EventEngine, Event, EVENT_TIMER
|
|
14
15
|
from vnpy.trader.constant import (
|
|
@@ -112,6 +113,7 @@ class OkxGateway(BaseGateway):
|
|
|
112
113
|
"Proxy Host": "",
|
|
113
114
|
"Proxy Port": 0,
|
|
114
115
|
"Spread Trading": ["False", "True"],
|
|
116
|
+
"Margin Currency": ""
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
exchanges: Exchange = [Exchange.GLOBAL]
|
|
@@ -132,6 +134,7 @@ class OkxGateway(BaseGateway):
|
|
|
132
134
|
self.proxy_host: str = ""
|
|
133
135
|
self.proxy_port: int = 0
|
|
134
136
|
self.spread_trading: bool = False
|
|
137
|
+
self.margin_currency: str = ""
|
|
135
138
|
|
|
136
139
|
self.orders: dict[str, OrderData] = {}
|
|
137
140
|
self.local_orderids: set[str] = set()
|
|
@@ -167,6 +170,7 @@ class OkxGateway(BaseGateway):
|
|
|
167
170
|
self.proxy_host = setting["Proxy Host"]
|
|
168
171
|
self.proxy_port = setting["Proxy Port"]
|
|
169
172
|
self.spread_trading = setting["Spread Trading"] == "True"
|
|
173
|
+
self.margin_currency = setting["Margin Currency"]
|
|
170
174
|
|
|
171
175
|
self.rest_api.connect(
|
|
172
176
|
self.key,
|
|
@@ -194,6 +198,7 @@ class OkxGateway(BaseGateway):
|
|
|
194
198
|
self.server,
|
|
195
199
|
self.proxy_host,
|
|
196
200
|
self.proxy_port,
|
|
201
|
+
self.margin_currency,
|
|
197
202
|
)
|
|
198
203
|
|
|
199
204
|
if self.spread_trading:
|
|
@@ -1266,6 +1271,7 @@ class PrivateApi(WebsocketApi):
|
|
|
1266
1271
|
self.key: str = ""
|
|
1267
1272
|
self.secret: bytes = b""
|
|
1268
1273
|
self.passphrase: str = ""
|
|
1274
|
+
self.margin_currency: str = ""
|
|
1269
1275
|
|
|
1270
1276
|
self.reqid: int = 0
|
|
1271
1277
|
self.order_count: int = 0
|
|
@@ -1296,6 +1302,7 @@ class PrivateApi(WebsocketApi):
|
|
|
1296
1302
|
server: str,
|
|
1297
1303
|
proxy_host: str,
|
|
1298
1304
|
proxy_port: int,
|
|
1305
|
+
margin_currency: str,
|
|
1299
1306
|
) -> None:
|
|
1300
1307
|
"""
|
|
1301
1308
|
Start server connection.
|
|
@@ -1309,10 +1316,12 @@ class PrivateApi(WebsocketApi):
|
|
|
1309
1316
|
server: Server type ("REAL" or "DEMO")
|
|
1310
1317
|
proxy_host: Proxy server hostname or IP
|
|
1311
1318
|
proxy_port: Proxy server port
|
|
1319
|
+
margin_currency: Margin currency
|
|
1312
1320
|
"""
|
|
1313
1321
|
self.key = key
|
|
1314
1322
|
self.secret = secret.encode()
|
|
1315
1323
|
self.passphrase = passphrase
|
|
1324
|
+
self.margin_currency = margin_currency
|
|
1316
1325
|
|
|
1317
1326
|
self.connect_time = int(datetime.now().strftime("%y%m%d%H%M%S"))
|
|
1318
1327
|
|
|
@@ -1425,8 +1434,8 @@ class PrivateApi(WebsocketApi):
|
|
|
1425
1434
|
balance=float(detail["eq"]),
|
|
1426
1435
|
gateway_name=self.gateway_name,
|
|
1427
1436
|
)
|
|
1428
|
-
account.available = float(detail["
|
|
1429
|
-
account.frozen =
|
|
1437
|
+
account.available = float(detail["availBal"])
|
|
1438
|
+
account.frozen = float(Decimal(detail["eq"]) - Decimal(detail["availBal"]))
|
|
1430
1439
|
self.gateway.on_account(account)
|
|
1431
1440
|
|
|
1432
1441
|
def on_position(self, packet: dict) -> None:
|
|
@@ -1615,6 +1624,9 @@ class PrivateApi(WebsocketApi):
|
|
|
1615
1624
|
"tdMode": "cross" # Only support cross margin mode
|
|
1616
1625
|
}
|
|
1617
1626
|
|
|
1627
|
+
if self.margin_currency:
|
|
1628
|
+
arg["ccy"] = self.margin_currency
|
|
1629
|
+
|
|
1618
1630
|
# Create websocket request with unique request ID
|
|
1619
1631
|
self.reqid += 1
|
|
1620
1632
|
packet: dict = {
|
vnpy_okx/py.typed
ADDED
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vnpy_okx
|
|
3
|
-
Version: 2025.
|
|
3
|
+
Version: 2025.12.22
|
|
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.
|
|
36
|
+
<img src ="https://img.shields.io/badge/version-2025.12.22-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=qqImNd6avopPM_BepNBtC1-eU86tJHil0jS8CX-JmAA,1248
|
|
2
|
+
vnpy_okx/okx_gateway.py,sha256=JaULeN4L-1p8oXd_cpaDMVy_Tu9-1nHDUA7wN8RBtC8,72263
|
|
3
|
+
vnpy_okx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
vnpy_okx-2025.12.22.dist-info/METADATA,sha256=aiyUjnkp2haPgxe0ZSNZ8LsiSYTdTZJCp9AJeExcdpc,2841
|
|
5
|
+
vnpy_okx-2025.12.22.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
vnpy_okx-2025.12.22.dist-info/licenses/LICENSE,sha256=vKkW-EmD7w-5lDDjg15L8feZ1nkQeNpEHfyO2v9tprs,1099
|
|
7
|
+
vnpy_okx-2025.12.22.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
vnpy_okx/__init__.py,sha256=EvwIgr_MBKK_appvqekSiZOEiXW-B93A3SWeJTXW8wc,1248
|
|
2
|
-
vnpy_okx/okx_gateway.py,sha256=r_pQkuVPpE7eHSjeAoyq6jt28cBaPtb5wVn1nUHT6g4,71837
|
|
3
|
-
vnpy_okx-2025.11.8.dist-info/METADATA,sha256=HV-oiZKXmbMlvvNARBbBjdM8c0WXoTk0UC3FBQjY6m8,2840
|
|
4
|
-
vnpy_okx-2025.11.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
-
vnpy_okx-2025.11.8.dist-info/licenses/LICENSE,sha256=vKkW-EmD7w-5lDDjg15L8feZ1nkQeNpEHfyO2v9tprs,1099
|
|
6
|
-
vnpy_okx-2025.11.8.dist-info/RECORD,,
|
|
File without changes
|