From 92cb2dd75ea37b64b174f42ddd0b5b17d6a4634a Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 16 二月 2023 16:04:11 +0800
Subject: [PATCH] H撤策略优化,新增热门板块爬取,新增windows截图工具

---
 l2/l2_data_manager_new.py |   47 +++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py
index 3d741bc..6ef1ca8 100644
--- a/l2/l2_data_manager_new.py
+++ b/l2/l2_data_manager_new.py
@@ -16,7 +16,7 @@
 import tool
 from trade import trade_data_manager, trade_manager, trade_queue_manager, l2_trade_factor, l2_trade_util, \
     trade_result_manager
-from l2 import safe_count_manager, l2_data_manager, l2_data_log, l2_log
+from l2 import safe_count_manager, l2_data_manager, l2_data_log, l2_log, l2_data_source_util
 from l2.cancel_buy_strategy import SecondCancelBigNumComputer, HourCancelBigNumComputer, L2LimitUpMoneyStatisticUtil, \
     L2LimitUpSellStatisticUtil
 from l2.l2_data_manager import L2DataException, TradePointManager
@@ -121,8 +121,9 @@
             # 濡傛灉鏄定鍋滀拱鎾や俊鍙烽渶瑕佺湅鏁版嵁浣嶇疆鏄惁姣斿紑濮嬪鐞嗘椂闂存棭
             if L2DataUtil.is_limit_up_price_buy_cancel(data["val"]):
                 # 鑾峰彇涔板叆淇″彿
-                buy_index, buy_data = l2_data_util.get_buy_data_with_cancel_data(total_datas[i],
-                                                                                 local_today_num_operate_map.get(code))
+                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data(code, total_datas[i],
+                                                                                                 local_today_num_operate_map.get(
+                                                                                                     code))
                 if buy_index is not None and buy_index < begin_pos:
                     continue
 
@@ -152,7 +153,6 @@
 
 class L2TradeDataProcessor:
     unreal_buy_dict = {}
-    random_key = {}
     l2BigNumForMProcessor = L2BigNumForMProcessor()
     __codeActualPriceProcessor = CodeActualPriceProcessor()
     buy1PriceManager = trade_queue_manager.Buy1PriceManager()
@@ -164,8 +164,7 @@
     # 鏁版嵁澶勭悊鍏ュ彛
     # datas: 鏈鎴浘鏁版嵁
     # capture_timestamp:鎴浘鏃堕棿鎴�
-    def process(cls, code, datas, capture_timestamp, do_id):
-        cls.random_key[code] = do_id
+    def process(cls, code, datas, capture_timestamp):
         __start_time = round(t.time() * 1000)
         try:
             if len(datas) > 0:
@@ -189,7 +188,7 @@
                 finally:
                     # 淇濆瓨鏁版嵁
                     __start_time = round(t.time() * 1000)
-                    l2.l2_data_util.save_l2_data(code, datas, add_datas, cls.random_key[code])
+                    l2.l2_data_util.save_l2_data(code, datas, add_datas)
                     __start_time = l2_data_log.l2_time(code,
                                                        round(t.time() * 1000) - __start_time,
                                                        "淇濆瓨鏁版嵁鏃堕棿锛坽}锛�".format(len(add_datas)))
@@ -204,7 +203,7 @@
             print(id(local_today_datas))
             # 鎷兼帴鏁版嵁
             local_today_datas[code].extend(add_datas)
-            l2.l2_data_util.load_num_operate_map(l2.l2_data_util.local_today_num_operate_map, code, add_datas)
+            l2.l2_data_util.load_num_operate_map(local_today_num_operate_map, code, add_datas)
 
             # 绗�1鏉℃暟鎹槸鍚︿负09:30:00
             if add_datas[0]["val"]["time"] == "09:30:00":
@@ -291,12 +290,14 @@
         def buy_1_cancel():
             _start_time = round(t.time() * 1000)
             # 鎾ゅ崟璁$畻,鍙湅涔�1
-            cancel_data, cancel_msg = L2LimitUpMoneyStatisticUtil.process_data(cls.random_key[code], code, start_index,
+            cancel_data, cancel_msg = L2LimitUpMoneyStatisticUtil.process_data(code, start_index,
                                                                                end_index,
                                                                                buy_single_index, buy_exec_index)
 
             l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time,
                                 "宸蹭笅鍗�-涔�1缁熻鑰楁椂")
+            if constant.TEST:
+                return None, ""
             return cancel_data, cancel_msg
 
         # S鎾�
@@ -307,8 +308,7 @@
             try:
                 b_need_cancel, b_cancel_data = SecondCancelBigNumComputer.need_cancel(code, buy_single_index,
                                                                                       buy_exec_index, start_index,
-                                                                                      end_index, total_data,
-                                                                                      cls.random_key[code])
+                                                                                      end_index, total_data)
                 if b_need_cancel:
                     return b_cancel_data, "S澶у崟鎾ら攢姣斾緥瑙﹀彂闃堝��"
             except Exception as e:
@@ -324,9 +324,8 @@
             _start_time = round(t.time() * 1000)
             try:
                 b_need_cancel, b_cancel_data = HourCancelBigNumComputer.need_cancel(code, buy_exec_index, start_index,
-                                                                                    end_index, total_data,
-                                                                                    cls.random_key[code])
-                if b_need_cancel and not cancel_data:
+                                                                                    end_index, total_data, local_today_num_operate_map.get(code))
+                if b_need_cancel and b_cancel_data:
                     return b_cancel_data, "H鎾ら攢姣斾緥瑙﹀彂闃堝��"
             except Exception as e:
                 logging.exception(e)
@@ -340,7 +339,7 @@
             _start_time = round(t.time() * 1000)
             # 缁熻鏉夸笂鍗�
             try:
-                cancel_data, cancel_msg = L2LimitUpSellStatisticUtil.process(cls.random_key[code], code, start_index,
+                cancel_data, cancel_msg = L2LimitUpSellStatisticUtil.process(code, start_index,
                                                                              end_index,
                                                                              buy_exec_index)
                 return cancel_data, cancel_msg
@@ -714,7 +713,7 @@
             f2 = dask.delayed(limit_up_time_manager.save_limit_up_time)(code, total_datas[compute_index]["val"]["time"])
             f3 = dask.delayed(cls.__virtual_buy)(code, buy_single_index, compute_index, capture_time)
             f4 = dask.delayed(l2_data_manager.TradePointManager.delete_buy_cancel_point)(code)
-            f5 = dask.delayed(L2LimitUpMoneyStatisticUtil.process_data)(cls.random_key[code], code, buy_single_index,
+            f5 = dask.delayed(L2LimitUpMoneyStatisticUtil.process_data)(code, buy_single_index,
                                                                         compute_index,
                                                                         buy_single_index,
                                                                         buy_exec_index, False)
@@ -744,7 +743,7 @@
                 need_cancel, cancel_data = SecondCancelBigNumComputer.need_cancel(code, buy_single_index,
                                                                                   compute_index,
                                                                                   buy_single_index, compute_index,
-                                                                                  total_datas, cls.random_key[code],
+                                                                                  total_datas,
                                                                                   True)
                 _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time,
                                                   "S绾уぇ鍗曞鐞嗚�楁椂", force=True)
@@ -758,7 +757,7 @@
                     cls.__buy(code, capture_time, total_datas[compute_index], compute_index)
             else:
                 SecondCancelBigNumComputer.need_cancel(code, buy_single_index, compute_index, buy_single_index,
-                                                       compute_index, total_datas, cls.random_key[code], False)
+                                                       compute_index, total_datas, False)
 
                 _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time,
                                                   "S绾уぇ鍗曞鐞嗚�楁椂", force=True)
@@ -927,9 +926,9 @@
                     # 鍙粺璁�59涓囦互涓婄殑閲戦
                     # 娑ㄥ仠涔版挙
                     # 鍒ゆ柇涔板叆浣嶇疆鏄惁鍦ㄤ拱鍏ヤ俊鍙蜂箣鍓�
-                    buy_index, buy_data = l2_data_util.get_buy_data_with_cancel_data(total_datas[i],
-                                                                                     local_today_num_operate_map.get(
-                                                                                         code))
+                    buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data(code, total_datas[i],
+                                                                                                     local_today_num_operate_map.get(
+                                                                                                         code))
                     if buy_index is not None:
                         # 鎵惧埌涔版挙鏁版嵁鐨勪拱鍏ョ偣
                         if buy_index >= buy_single_index:
@@ -940,7 +939,7 @@
                             l2_log.buy_debug(code, "{}鏁版嵁鍦ㄤ拱鍏ヤ俊鍙蜂箣鍚� 鎾や拱绾拱鎵嬫暟锛歿} 鐩爣鎵嬫暟锛歿}", i, buy_nums, threshold_num)
                         else:
                             l2_log.buy_debug(code, "{}鏁版嵁鍦ㄤ拱鍏ヤ俊鍙蜂箣鍓嶏紝涔板叆浣嶏細{}", i, buy_index)
-                            if total_datas[buy_single_index]["val"]["time"] == buy_data["val"]["time"]:
+                            if total_datas[buy_single_index]["val"]["time"] == total_datas[buy_index]["val"]["time"]:
                                 # 鍚屼竴绉�,褰撲綔涔板叆淇″彿涔嬪悗澶勭悊
                                 buy_nums -= int(_val["num"]) * int(data["re"])
                                 buy_count -= int(data["re"])
@@ -1102,9 +1101,9 @@
         cls.random_key[code] = random.randint(0, 100000)
         buy_single_begin_index, buy_exec_index = 426, 479
 
-        L2LimitUpMoneyStatisticUtil.process_data(cls.random_key[code], code, 480, 519,
+        L2LimitUpMoneyStatisticUtil.process_data(code, 480, 519,
                                                  buy_single_begin_index, buy_exec_index, False)
-        L2LimitUpMoneyStatisticUtil.process_data(cls.random_key[code], code, 480, 519,
+        L2LimitUpMoneyStatisticUtil.process_data(code, 480, 519,
                                                  buy_single_begin_index, buy_exec_index, False)
 
     @classmethod

--
Gitblit v1.8.0