From eb33b717023d9871bd74e6dce47a065228cffefc Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 02 十一月 2023 11:23:09 +0800
Subject: [PATCH] L2进程与策略进程分开

---
 huaxin_client/l1_client.py |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/huaxin_client/l1_client.py b/huaxin_client/l1_client.py
index b46abda..530a410 100644
--- a/huaxin_client/l1_client.py
+++ b/huaxin_client/l1_client.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 import json
 import logging
+import multiprocessing
 import os
 import threading
 import time
@@ -122,7 +123,7 @@
 __latest_subscript_codes = set()
 
 
-def __upload_codes_info(pipe_l2, datas):
+def __upload_codes_info(queue_l1_w_strategy_r: multiprocessing.Queue, datas):
     if not tool.is_trade_time():
         return
     # 涓婁紶鏁版嵁
@@ -130,8 +131,8 @@
     request_id = f"sb_{int(time.time() * 1000)}"
     fdata = json.dumps(
         {"type": type_, "data": {"data": datas}, "request_id": request_id, "time": round(time.time() * 1000, 0)})
-    if pipe_l2 is not None:
-        pipe_l2.send(fdata)
+    if queue_l1_w_strategy_r is not None:
+        queue_l1_w_strategy_r.put_nowait(fdata)
     # 璁板綍鏂板鍔犵殑浠g爜
     codes = set([x[0] for x in datas])
     add_codes = codes - __latest_subscript_codes
@@ -160,7 +161,7 @@
         pass
 
 
-def run(pipe_l2):
+def run(queue_l1_w_strategy_r):
     logger_local_huaxin_l1.info("杩愯l1璁㈤槄鏈嶅姟")
     codes_sh = []
     codes_sz = []
@@ -203,8 +204,8 @@
     # 娴嬭瘯閾捐矾
     # level1_data_dict["000969"] = (
     #     "000969", 9.46, 9.11, 771000*100, time.time())
-    # level1_data_dict["000961"] = (
-    #     "000961",1.93, 10.29, 2638000 * 100, time.time())
+    level1_data_dict["002292"] = (
+        "002292", 8.06, 9.96, 969500 * 100, time.time())
 
     # 绛夊緟绋嬪簭缁撴潫
     while True:
@@ -226,7 +227,7 @@
             codes = [x[0] for x in datas]
             print("浠g爜鏁伴噺:", len(datas))
             logger_l2_codes_subscript.info("寮�濮�#鍗庨懌L1涓婁紶浠g爜锛氭暟閲�-{}", len(datas))
-            __upload_codes_info(pipe_l2, datas)
+            __upload_codes_info(queue_l1_w_strategy_r, datas)
         except Exception as e:
             logging.exception(e)
         finally:

--
Gitblit v1.8.0