From fb47d36048e94b9a506d5c153e3dd19a01e37df1 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 30 十月 2023 16:30:27 +0800
Subject: [PATCH] bug修复

---
 huaxin_client/l2_client.py       |    6 ++++--
 trade/trade_manager.py           |    5 ++---
 huaxin_client/l2_data_manager.py |   15 +++++++--------
 l2/l2_data_manager_new.py        |    1 +
 trade/trade_record_log_util.py   |    3 ++-
 output/code_info_output.py       |   15 +++++++++++----
 6 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/huaxin_client/l2_client.py b/huaxin_client/l2_client.py
index 59f0e17..4da4698 100644
--- a/huaxin_client/l2_client.py
+++ b/huaxin_client/l2_client.py
@@ -321,7 +321,7 @@
             # 娣辫瘉鎾ゅ崟
             print("閫愮瑪濮旀墭", item)
 
-            l2_data_manager.add_l2_order_detail(item, True)
+            l2_data_manager.add_l2_order_detail(item, 0, True)
         else:
             if abs(pTransaction['TradePrice'] - limit_up_price) < 0.201:
                 # 娑ㄥ仠浠�
@@ -343,7 +343,9 @@
     def OnRtnOrderDetail(self, pOrderDetail):
         can_listen = False
         code = str(pOrderDetail['SecurityID'])
+        start_time = 0
         if code in self.special_code_volume_for_order_dict:
+            start_time = time.time()
             if self.special_code_volume_for_order_dict[code][0] == pOrderDetail['Volume'] or constant.SHADOW_ORDER_VOLUME == pOrderDetail['Volume']:
                 # 鐩戞帶鐩爣璁㈠崟涓庡奖瀛愯鍗�
                 if self.special_code_volume_for_order_dict[code][1] > time.time():
@@ -374,7 +376,7 @@
                 "OrderTime": pOrderDetail['OrderTime'], "MainSeq": pOrderDetail['MainSeq'],
                 "SubSeq": pOrderDetail['SubSeq'], "OrderNO": pOrderDetail['OrderNO'],
                 "OrderStatus": pOrderDetail['OrderStatus'].decode()}
-        l2_data_manager.add_l2_order_detail(item)
+        l2_data_manager.add_l2_order_detail(item, start_time)
 
     def OnRtnBondMarketData(self, pDepthMarketData, FirstLevelBuyNum, FirstLevelBuyOrderVolumes, FirstLevelSellNum,
                             FirstLevelSellOrderVolumes):
diff --git a/huaxin_client/l2_data_manager.py b/huaxin_client/l2_data_manager.py
index f854c2c..9a4ae30 100644
--- a/huaxin_client/l2_data_manager.py
+++ b/huaxin_client/l2_data_manager.py
@@ -55,7 +55,7 @@
 
 
 # 娣诲姞濮旀墭璇︽儏
-def add_l2_order_detail(data, istransaction=False):
+def add_l2_order_detail(data, start_time, istransaction=False):
     code = data["SecurityID"]
     # 寮傛鏃ュ織璁板綍
     if code not in tmep_order_detail_queue_dict:
@@ -79,7 +79,7 @@
 
     tmep_order_detail_queue_dict[code].put(
         (data['SecurityID'], data['Price'], data['Volume'], data['Side'], data['OrderType'], data['OrderTime'],
-         data['MainSeq'], data['SubSeq'], data['OrderNO'], data['OrderStatus'], int(time.time() * 1000)))
+         data['MainSeq'], data['SubSeq'], data['OrderNO'], data['OrderStatus'], time.time(), start_time))
 
 
 # 娣诲姞閫愮瑪鎴愪氦
@@ -196,23 +196,22 @@
             try:
                 if code not in target_codes:
                     break
-                # 鎵撳紑鍏变韩鍐呭瓨
                 order_detail_upload_active_time_dict[code] = time.time()
                 udatas = []
                 while not tmep_order_detail_queue_dict[code].empty():
                     temp = tmep_order_detail_queue_dict[code].get()
                     udatas.append(temp)
                 if udatas:
-                    start_time = time.time()
+                    # start_time = time.time()
                     # upload_data(code, "l2_order", udatas)
                     l2_data_callback.OnL2Order(code, udatas, int(time.time() * 1000))
                     # l2_data_transaction_protocol.send_l2_order_detail(pipe, _mmap, code, udatas)
-                    use_time = int((time.time() - start_time) * 1000)
-                    if use_time > 10:
-                        async_log_util.info(logger_local_huaxin_l2_upload, f"{code}-涓婁紶浠g爜鑰楁椂锛歿use_time}ms")
+                    # use_time = int((time.time() - start_time) * 1000)
+                    # if use_time > 10:
+                    #     async_log_util.info(logger_local_huaxin_l2_upload, f"{code}-涓婁紶浠g爜鑰楁椂锛歿use_time}ms")
                 else:
                     # 娌℃湁鏁版嵁鐨勬椂鍊欓渶绛夊緟锛屾湁鏁版嵁鏃朵笉闇�绛夊緟
-                    time.sleep(0.004)
+                    time.sleep(0.001)
             except Exception as e:
                 hx_logger_contact_debug.exception(e)
                 logger_local_huaxin_l2_error.error(f"涓婁紶璁㈠崟鏁版嵁鍑洪敊锛歿str(e)}")
diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index dab435c..943967d 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -600,6 +600,7 @@
                     jx_blocks, jx_blocks_by = KPLCodeJXBlockManager().get_jx_blocks_cache(
                         code), KPLCodeJXBlockManager().get_jx_blocks_cache(code, by=True)
                     info = cls.__trade_log_placr_order_info_dict[code]
+                    info.mode = order_begin_pos.mode
                     info.set_buy_index(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
                     if jx_blocks:
                         info.set_kpl_blocks(list(jx_blocks))
diff --git a/output/code_info_output.py b/output/code_info_output.py
index f6e8cf5..8fbeff9 100644
--- a/output/code_info_output.py
+++ b/output/code_info_output.py
@@ -12,6 +12,7 @@
 import code_attribute
 from code_attribute import code_volumn_manager, limit_up_time_manager, global_data_loader, gpcode_manager
 import constant
+from l2.l2_data_manager import OrderBeginPosInfo
 from l2.l2_data_util import L2DataUtil
 from utils import global_util, tool
 from log_module import log, log_export
@@ -385,9 +386,15 @@
                     extra_datas.append(f"瀹夊叏绗旀暟锛歿data['safe_count']}")
 
                     records_new_data.append((time_, "", "-------------------------", []))
-                    records_new_data.append((time_, "涓嬪崟",
-                                             f"銆恵format_l2_data(total_datas[data['buy_single_index']])}銆�-銆恵format_l2_data(total_datas[data['buy_exec_index']])}銆�",
-                                             extra_datas))
+                    mode = data.get('mode')
+                    if mode == OrderBeginPosInfo.MODE_FAST:
+                        records_new_data.append((time_, "闂數涓嬪崟",
+                                                 f"銆恵format_l2_data(total_datas[data['buy_single_index']])}銆�-銆恵format_l2_data(total_datas[data['buy_exec_index']])}銆�",
+                                                 extra_datas))
+                    else:
+                        records_new_data.append((time_, "涓嬪崟",
+                                                 f"銆恵format_l2_data(total_datas[data['buy_single_index']])}銆�-銆恵format_l2_data(total_datas[data['buy_exec_index']])}銆�",
+                                                 extra_datas))
                 elif type == trade_record_log_util.TYPE_REAL_PLACE_ORDER_POSITION:
                     _datas = []
                     MIN_MONEYS = [30000, 20000, 10000]
@@ -449,4 +456,4 @@
 if __name__ == '__main__':
     code = '002786'
     l2_data_util.load_l2_data(code)
-    print( __load_trade_record(code, l2_data_util.local_today_datas.get(code)))
+    print(__load_trade_record(code, l2_data_util.local_today_datas.get(code)))
diff --git a/trade/trade_manager.py b/trade/trade_manager.py
index 160b6c7..6d5260f 100644
--- a/trade/trade_manager.py
+++ b/trade/trade_manager.py
@@ -447,11 +447,10 @@
 def __buy(code, price, trade_state, capture_timestamp, last_data, last_data_index, mode=0):
     async_log_util.info(logger_trade, "{} trade_manager.__buy 寮�濮�".format(code))
     try:
-
         if constant.API_TRADE_ENABLE:
             count = (constant.BUY_MONEY_PER_CODE // int(round(float(price) * 100))) * 100
-            if mode != 0:
-                count = 100
+            # if mode != 0:
+            #     count = 100
             # 鏈�浣庝笅鍗�1鎵�
             if count < 100:
                 count = 100
diff --git a/trade/trade_record_log_util.py b/trade/trade_record_log_util.py
index de35df7..ea76347 100644
--- a/trade/trade_record_log_util.py
+++ b/trade/trade_record_log_util.py
@@ -18,13 +18,14 @@
 
 class PlaceOrderInfo(object):
     def __init__(self, buy_single_index=None, buy_exec_index=None, m_val=None, safe_count=None, big_num_indexes=None,
-                 kpl_blocks=None):
+                 kpl_blocks=None, mode=None):
         self.buy_single_index = buy_single_index
         self.buy_exec_index = buy_exec_index
         self.m_val = m_val
         self.safe_count = safe_count
         self.big_num_indexes = big_num_indexes
         self.kpl_blocks = kpl_blocks
+        self.mode = mode
 
     def set_buy_index(self, buy_single_index, buy_exec_index):
         self.buy_single_index = buy_single_index

--
Gitblit v1.8.0