From b874fdb322d0740838f73e5ed260f800bf43ad1a Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 22 三月 2024 15:51:57 +0800
Subject: [PATCH] 增加外部端口

---
 utils/hosting_api_util.py |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/utils/hosting_api_util.py b/utils/hosting_api_util.py
index 0565187..4d65ac5 100644
--- a/utils/hosting_api_util.py
+++ b/utils/hosting_api_util.py
@@ -131,13 +131,14 @@
 # blocking鏄惁闃诲杩涚▼
 def trade_order(direction, code, volume, price, price_type=2, blocking=True):
     print("瀹㈡埛绔�", ClientSocketManager.socket_client_dict)
-    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
-                                   {"type": API_TYPE_TRADE, "trade_type": 1,
-                                    "direction": direction,
-                                    "code": code,
-                                    "volume": volume,
-                                    "price_type": price_type,
-                                    "price": price, "sinfo": f"order_{code}_{round(time.time() * 1000)}"})
+    request_id, client = __request(
+        ClientSocketManager.CLIENT_TYPE_TRADE if direction == 1 else ClientSocketManager.CLIENT_TYPE_TRADE_SELL,
+        {"type": API_TYPE_TRADE, "trade_type": 1,
+         "direction": direction,
+         "code": code,
+         "volume": volume,
+         "price_type": price_type,
+         "price": price, "sinfo": f"order_{code}_{round(time.time() * 1000)}"})
 
     return __read_response(client, request_id, blocking)
 
@@ -310,7 +311,7 @@
 
 # 淇濆瓨姝e湪杩愯鐨勬暟鎹�
 def sell_rule(operate, data={}, blocking=True):
-    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_COMMON,
+    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE_SELL,
                                    {"type": API_TYPE_SELL_RULE, "operate": operate, "data": data,
                                     "sinfo": f"cb_{API_TYPE_SELL_RULE}_{round(time.time() * 1000)}"})
     return __read_response(client, request_id, blocking, timeout=10)
@@ -318,7 +319,7 @@
 
 # 鑾峰彇浠g爜鎸佷粨淇℃伅
 def get_code_position_info(code, blocking=True):
-    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE,
+    request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE_SELL,
                                    {"type": API_TYPE_GET_CODE_POSITION_INFO, "code": code,
                                     "sinfo": f"cb_{API_TYPE_GET_CODE_POSITION_INFO}_{round(time.time() * 1000)}"})
     return __read_response(client, request_id, blocking)

--
Gitblit v1.8.0