From a00da3062c6c825b585f82275823ac45cdeb6502 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 19 一月 2024 19:16:20 +0800
Subject: [PATCH] L后成交太快撤单

---
 third_data/data_server.py |   69 ++++++++++++++++++++--------------
 1 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/third_data/data_server.py b/third_data/data_server.py
index cd80e3d..b179ff9 100644
--- a/third_data/data_server.py
+++ b/third_data/data_server.py
@@ -448,7 +448,7 @@
         elif url.path == "/kpl/get_plate_codes":
             # 鑾峰彇娑ㄥ仠鍘熷洜涓嬮潰鐨勪唬鐮�
             ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()])
-            plate = ps_dict["plate"]
+            plate = kpl_util.filter_block(ps_dict["plate"])
             # 鑾峰彇鏉垮潡涓嬬殑浠g爜
             # 缁熻鐩墠涓烘鐨勪唬鐮佹定鍋滄暟閲忥紙鍒嗘定鍋滃師鍥狅級
             now_limit_up_codes_info = self.__kplDataManager.get_data(KPLDataType.LIMIT_UP)
@@ -461,12 +461,23 @@
 
             codes_info = []
             for d in record_limit_up_datas:
-                if d[2] != plate:
+                if kpl_util.filter_block(d[2]) != plate:
                     continue
                 # 浠g爜,鍚嶇О,娑ㄥ仠鏃堕棿,鏄惁鐐告澘,鏄惁鎯充拱,鏄惁宸茬粡涓嬭繃鍗�
                 codes_info.append(
                     [d[3], d[4], tool.to_time_str(int(d[5])), 1 if d[3] not in now_limit_up_codes else 0, 0, 0, d[12],
-                     output_util.money_desc(d[13])])
+                     output_util.money_desc(d[13]), 1])
+
+            for d in record_limit_up_datas:
+                if kpl_util.filter_block(d[2]) == plate:
+                    continue
+                if plate not in [kpl_util.filter_block(k) for k in d[6].split("銆�")]:
+                    continue
+                # 浠g爜,鍚嶇О,娑ㄥ仠鏃堕棿,鏄惁鐐告澘,鏄惁鎯充拱,鏄惁宸茬粡涓嬭繃鍗�
+                codes_info.append(
+                    [d[3], d[4], tool.to_time_str(int(d[5])), 1 if d[3] not in now_limit_up_codes else 0, 0, 0, d[12],
+                     output_util.money_desc(d[13]), 0])
+
             codes_info.sort(key=lambda x: x[2])
             # 鏌ヨ鏄惁涓烘兂涔板崟
             want_codes = gpcode_manager.WantBuyCodesManager().list_code_cache()
@@ -517,27 +528,29 @@
                 response_data = json.dumps({"code": 1, "msg": "璇蜂笂浼燾ode"})
 
         elif url.path == "/get_last_trade_day_reasons":
-            try:
-                # 璁$畻骞冲潎娑ㄥ箙
-                def get_limit_rate_list(codes):
-                    if not codes:
-                        return []
-                    need_request_codes = set()
-                    if tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") < 0:
-                        need_request_codes |= set(codes)
-                    else:
-                        now_time = time.time()
-                        for c in codes:
-                            if c not in self.__code_limit_rate_dict:
-                                need_request_codes.add(c)
-                            elif now_time - self.__code_limit_rate_dict[c][1] >  60:
-                                need_request_codes.add(c)
-                    if need_request_codes:
-                        _limit_rate_list = HistoryKDatasUtils.get_codes_limit_rate(list(need_request_codes))
-                        for d in _limit_rate_list:
-                            self.__code_limit_rate_dict[d[0]] = (d[1], time.time())
-                    return [(c_, self.__code_limit_rate_dict[c_][0]) for c_ in codes]
 
+            # 璁$畻骞冲潎娑ㄥ箙
+            def get_limit_rate_list(codes):
+                if not codes:
+                    return []
+                need_request_codes = set()
+                if tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") < 0:
+                    need_request_codes |= set(codes)
+                else:
+                    now_time = time.time()
+                    for c in codes:
+                        if c not in self.__code_limit_rate_dict:
+                            need_request_codes.add(c)
+                        elif now_time - self.__code_limit_rate_dict[c][1] > 60:
+                            need_request_codes.add(c)
+                if need_request_codes:
+                    _limit_rate_list = HistoryKDatasUtils.get_codes_limit_rate(list(need_request_codes))
+                    for d in _limit_rate_list:
+                        self.__code_limit_rate_dict[d[0]] = (d[1], time.time())
+                return [(c_, self.__code_limit_rate_dict[c_][0]) for c_ in codes]
+
+            try:
+                raise Exception("鎺ュ彛鏆傚仠浣跨敤")
                 # 鑾峰彇涓婁釜浜ゆ槗鏃ョ殑鐩稿悓娑ㄥ仠鍘熷洜鐨勪唬鐮佷俊鎭�
                 ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()])
                 code = ps_dict["code"]
@@ -590,11 +603,11 @@
                     response_data = json.dumps({"code": 0, "data": {"reason": reason, "reason_rate": percent_rate,
                                                                     "data": {"yesterday": yesterday_result_list,
                                                                              "current": current_result_list}}})
+                else:
+                    response_data = json.dumps({"code": 1, "msg": "鏄ㄦ棩鏈定鍋�"})
             except Exception as e:
                 logger_debug.exception(e)
                 raise e
-            else:
-                response_data = json.dumps({"code": 1, "msg": "鏄ㄦ棩鏈定鍋�"})
 
         elif url.path == "/pull_kp_client_msg":
             # 鎷夊彇瀹㈡埛绔秷鎭�
@@ -626,7 +639,7 @@
             result_str = self.__process_kpl_data(params)
             self.__send_response(result_str)
 
-    def __process_kpl_data(self, data):
+    def __process_kpl_data(self, data_origin):
         def do_limit_up(result_list_):
             if result_list_:
                 # 淇濆瓨娑ㄥ仠鏃堕棿
@@ -684,7 +697,7 @@
                 self.__kplDataManager.save_data(type_, result_list_)
 
         # 灏�"姒傚康"浜屽瓧鏇挎崲鎺�
-        data = json.loads(json.dumps(data).replace("姒傚康", ""))
+        data = data_origin
         type_ = data["type"]
         print("寮�鐩樺暒type:", type_)
         if type_ == KPLDataType.BIDDING.value:
@@ -701,7 +714,7 @@
 
                 self.__kplDataManager.save_data(type_, result_list)
         elif type_ == KPLDataType.LIMIT_UP.value:
-            result_list = kpl_util.parseDaBanData(data["data"], kpl_util.DABAN_TYPE_LIMIT_UP)
+            result_list = kpl_util.parseLimitUpData(data["data"])
             self.__data_process_thread_pool.submit(lambda: do_limit_up(result_list))
             # 璁板綍娑ㄥ仠鏃ュ織
             logger_kpl_limit_up.info(result_list)

--
Gitblit v1.8.0