From 02c91a4afceca47e22ffaef219ecaff1004f179c Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 13 三月 2024 11:05:54 +0800 Subject: [PATCH] 更改序列化传输方式 --- third_data/kpl_api.py | 4 +++- l2/huaxin/huaxin_delegate_postion_manager.py | 4 ++-- l2/l2_data_listen_manager.py | 13 ++++++++----- huaxin_client/l2_data_manager.py | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/huaxin_client/l2_data_manager.py b/huaxin_client/l2_data_manager.py index d23c3d8..9a34109 100644 --- a/huaxin_client/l2_data_manager.py +++ b/huaxin_client/l2_data_manager.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import json import logging +import marshal import multiprocessing import queue import threading @@ -160,7 +161,7 @@ self.upload_l2_data_task_dict.pop(code) def __upload_l2_data(self, code, _queue, datas): - _queue.put_nowait((code, datas, time.time())) + _queue.put_nowait(marshal.dumps([code, datas, time.time()])) # 澶勭悊璁㈠崟鏁版嵁骞朵笂浼� def __run_upload_order_task(self, code): diff --git a/l2/huaxin/huaxin_delegate_postion_manager.py b/l2/huaxin/huaxin_delegate_postion_manager.py index eb2774f..ba806ef 100644 --- a/l2/huaxin/huaxin_delegate_postion_manager.py +++ b/l2/huaxin/huaxin_delegate_postion_manager.py @@ -221,7 +221,7 @@ # 涓嬪崟鏃堕棿涓嶄竴鑷� need_update = True - if not need_update and real_place_index_data["val"]["num"] != volume: + if not need_update and real_place_index_data["val"]["num"] != volume//100: # 涓嬪崟閲忎笉涓�鑷� need_update = True @@ -267,7 +267,7 @@ continue if not L2DataUtil.is_limit_up_price_buy(val): continue - if volume != val["num"]: + if volume//100 != val["num"]: continue left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( code, diff --git a/l2/l2_data_listen_manager.py b/l2/l2_data_listen_manager.py index 1f0a19f..e3be39a 100644 --- a/l2/l2_data_listen_manager.py +++ b/l2/l2_data_listen_manager.py @@ -1,6 +1,7 @@ """ L2鏁版嵁鐩戝惉 """ +import marshal import multiprocessing import threading import time @@ -33,11 +34,12 @@ while True: # datas_dict = {} try: - if not q.empty(): - item = q.get() - self.my_l2_data_callback.OnL2Order(item[0], item[1], item[2]) - else: - time.sleep(0.001) + # if not q.empty(): + item = q.get() + item = marshal.loads(item) + self.my_l2_data_callback.OnL2Order(item[0], item[1], item[2]) + # else: + # time.sleep(0.001) # while not q.empty(): # item = q.get() @@ -78,6 +80,7 @@ # time.sleep(0.01) if not q.empty(): item = q.get() + item = marshal.loads(item) self.my_l2_data_callback.OnL2Transaction(item[0], item[1]) else: time.sleep(0.005) diff --git a/third_data/kpl_api.py b/third_data/kpl_api.py index a616eb9..405db99 100644 --- a/third_data/kpl_api.py +++ b/third_data/kpl_api.py @@ -213,6 +213,7 @@ blocks = [] try: _bks = __getConceptJXBK(code) + print(_bks) if _bks: blocks.extend(_bks) except: @@ -220,6 +221,7 @@ try: _bks = __getConceptBK(code) + print(_bks) if _bks: blocks.extend(_bks) except: @@ -259,4 +261,4 @@ if __name__ == "__main__": - print(getCodeBlocks("600822")) + print(getCodeBlocks("002350")) -- Gitblit v1.8.0