From e59b4e4ae8e4861d850b208ffac75c0b967c6500 Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: 星期一, 26 五月 2025 14:33:27 +0800
Subject: [PATCH] 1.修改有概念的强拉参数 2.修改充分交易量函数基础条件 3.GUI新增及修改 行情板块强度模块,服务端解析日志数据及应答 4.

---
 strategy/basic_methods.py           |    9 ++--
 strategy/plate_strength_analysis.py |    5 +-
 log_module/log_export.py            |   25 ++++++++++++
 data_server.py                      |   32 +++++++++++++--
 strategy/buying_strategy.py         |    6 +-
 strategy/kpl_data_manager.py        |   36 +++++++++++++++++
 6 files changed, 98 insertions(+), 15 deletions(-)

diff --git a/data_server.py b/data_server.py
index ab07f6f..b4c09ff 100644
--- a/data_server.py
+++ b/data_server.py
@@ -17,7 +17,7 @@
 from log_module import log_export, async_log_util
 from log_module.log import hx_logger_l2_transaction, logger_debug, logger_request_api
 from strategy import data_cache
-from strategy.kpl_data_manager import KPLStockOfMarketsPlateLogManager
+from strategy.kpl_data_manager import KPLStockOfMarketsPlateLogManager, KPLMarketStockHeatLogManager
 from strategy.trade_setting import TradeSetting
 from trade import huaxin_trade_api, huaxin_trade_data_update
 from trade.huaxin_trade_record_manager import DelegateRecordManager, DealRecordManager, MoneyManager, PositionManager
@@ -192,19 +192,41 @@
             finally:
                 if use_time_list and use_time_list[-1][1] > 10:
                     logger_debug.warning(f"鐜鑾峰彇鏃堕棿澶т簬10s({request_id}):{use_time_list}")
-
-        elif url.path == "/load_kpl_stock_of_markets_plate":
+        # 鑾峰彇鏉垮潡寮哄害鏁版嵁
+        elif url.path == "/load_get_kpl_market_sift_plate":
             # 鍔犺浇鏁版嵁
             KPLStockOfMarketsPlateLogManager().load_data()
             response_data = json.dumps({"code": 0, "msg": "鏆傛棤鍐呭"})
-        elif url.path == "/get_kpl_stock_of_markets_plate":
+        elif url.path == "/get_kpl_market_sift_plate":
+            # 鑾峰彇寮�鐩樺暒娴佸叆鏉垮潡璇︾粏淇℃伅
+            print("==========get_kpl_market_sift_plate==========")
+            try:
+                time_str = params_dict.get("time")
+                if not time_str:
+                    time_str = tool.get_now_time_str()
+                fdatas = KPLStockOfMarketsPlateLogManager().get_filter_log_datas()
+                response_data = json.dumps({"code": 1, "msg": "鏆傛棤鍐呭"})
+                for i in range(len(fdatas) - 1, -1, -1):
+                    if fdatas[i][0] <= time_str:
+                        response_data = json.dumps({"code": 0, "data": fdatas[i]})
+                        break
+            except Exception as e:
+                logging.exception(e)
+                response_data = json.dumps({"code": 1, "msg": str(e)})
+
+        # 鑾峰彇涓偂寮哄害鏁版嵁
+        elif url.path == "/load_get_kpl_market_stock_heat":
+            # 鍔犺浇鏁版嵁
+            KPLMarketStockHeatLogManager().load_data()
+            response_data = json.dumps({"code": 0, "msg": "鏆傛棤鍐呭"})
+        elif url.path == "/get_get_kpl_market_stock_heat":
             # 鑾峰彇寮�鐩樺暒娴佸叆鏉垮潡璇︾粏淇℃伅
             print("==========get_kpl_stock_of_markets_plate==========")
             try:
                 time_str = params_dict.get("time")
                 if not time_str:
                     time_str = tool.get_now_time_str()
-                fdatas = KPLStockOfMarketsPlateLogManager().get_filter_log_datas()
+                fdatas = KPLMarketStockHeatLogManager().get_filter_log_datas()
                 response_data = json.dumps({"code": 1, "msg": "鏆傛棤鍐呭"})
                 for i in range(len(fdatas) - 1, -1, -1):
                     if fdatas[i][0] <= time_str:
diff --git a/log_module/log_export.py b/log_module/log_export.py
index d9b077e..b916c31 100644
--- a/log_module/log_export.py
+++ b/log_module/log_export.py
@@ -53,6 +53,31 @@
     return contents
 
 
+def load_market_stock_heat(date=tool.get_now_date_str()):
+    """
+     鑾峰彇绮鹃�夋祦鍏ョ殑鎴愬垎鑲�
+    :param date:
+    :return:
+    """
+    path = f"{constant.get_path_prefix()}/low_suction_log/gp/kpl/market_sift_plate.{date}.log"
+    fdatas = []
+    if os.path.exists(path):
+        with open(path, 'r', encoding="utf-8") as f:
+            lines = f.readlines()
+            for line in lines:
+                if line:
+                    time_str = __get_async_log_time(line)
+                    try:
+                        data = line.split(" - ")[1].strip()
+                        if data.startswith("["):
+                            data = data[data.find("]") + 1:].strip()
+                        data_dict = eval(data)
+                        fdatas.append((time_str, data_dict))
+                    except:
+                        pass
+    return fdatas
+
+
 def load_stock_of_markets_plate(date=tool.get_now_date_str()):
     """
      鑾峰彇绮鹃�夋祦鍏ョ殑鎴愬垎鑲�
diff --git a/strategy/basic_methods.py b/strategy/basic_methods.py
index 3cdf59e..b9defd5 100644
--- a/strategy/basic_methods.py
+++ b/strategy/basic_methods.py
@@ -210,10 +210,11 @@
 
 # 鍏呭垎浜ゆ槗閲忓叕寮� 鐢ㄤ簬璁$畻鏃ュ唴娑ㄥ箙娈电悊璁虹殑瀹夊叏浜ゆ槗閲忓��
 def sufficient_volume(current_volume, yesterday_volume, today_growth):
-    if current_volume < yesterday_volume * today_growth:
-        return False
-    else:
-        return True
+    if today_growth > 0:
+        if current_volume < yesterday_volume * today_growth:
+            return False
+        else:
+            return True
 
 
 # 璁$畻 濮斾拱鍜屽鍗栫殑姣斾緥鍑芥暟(鑾峰彇涔扮洏寮哄害鏁版嵁)銆愭帢閲戞暟鎹粨鏋勩��
diff --git a/strategy/buying_strategy.py b/strategy/buying_strategy.py
index f306aa4..d9b66dd 100644
--- a/strategy/buying_strategy.py
+++ b/strategy/buying_strategy.py
@@ -315,13 +315,13 @@
                                         logger_info(f"閲嶅鐩镐氦姒傚康==={intersection_plate}")
                                     # 璋冪敤鍏呭垎浜ゆ槗閲忓嚱鏁�
                                     sufficient_volume = basic_methods.sufficient_volume(current_volume, k_line_data[0]['volume'], today_growth)
-                                    logger_info(f"銆恵k_line_data[0]['sec_name']}銆戝綋鏃ュ綋鏃堕噺鏄惁鐩稿娑ㄥ箙鍏呰冻锛�===銆恵sufficient_volume}銆� 锛佸綋鏃ュ綋鏃舵�绘垚浜ら噺锛歿round(current_volume / 10000, 2)}涓囷紝鏄ㄦ棩鐨勬�绘垚浜ら噺{round(k_line_data[0]['volume'] / 10000, 2)}涓囷紝褰撴棩褰撴椂娑ㄥ箙锛歿today_growth}%銆�")
+                                    logger_info(f"銆恵k_line_data[0]['sec_name']}銆戝綋鏃ュ綋鏃堕噺鏄惁鐩稿娑ㄥ箙鍏呰冻锛�===銆恵sufficient_volume}銆� 锛佸綋鏃朵笌鏄ㄦ棩鎴愪氦鐜囧崰姣�:{round(current_volume/k_line_data[0]['volume'], 2)}%锛屽綋鏃ュ綋鏃舵�绘垚浜ら噺锛歿round(current_volume / 10000, 2)}涓囷紝鏄ㄦ棩鐨勬�绘垚浜ら噺{round(k_line_data[0]['volume'] / 10000, 2)}涓囷紝褰撴棩褰撴椂娑ㄥ箙锛歿today_growth}%銆�")
                                     logger_info(f"銆愭湁姒傚康銆�(娑ㄥ仠鍒楄〃涓寘鍚嚜韬蹇� 涓� 涓嶆槸鍞竴鍖呭惈姒傚康涓嶅彲鐢�) 锛佹渶鏂颁环: {current_price}锛岋紝褰撴棩褰撴椂娑ㄥ箙锛歿today_growth}%銆�")
                                     # 鏈夋蹇垫湁寮哄害瑙嗙晫
                                     if strength_list_have_it is True:
                                         logger_info(f"銆愭湁姒傚康 鏈夊己搴︺�戝嚭鐜板湪鏉垮潡寮哄害澶т簬2鐨勫垪琛ㄤ腑 鐬椂閲忓箙姣旓細{round(last_volume_to_growth_ratio, 2)}%锛屽綋鏃ュ綋鏃舵定骞咃細{today_growth}%銆�")
-                                        if tick_growth < 0.8 and (free_market_value <= 100 and current_price <= 10):
-                                            logger_info(f"銆愭湁姒傚康 鏈夊己搴� 鏈夊己鎷夈�戠灛鏃舵定骞� > 0.8% 锛佺灛鏃舵定骞咃細{round(tick_growth, 2)}%")
+                                        if tick_growth < 0.5 and (free_market_value <= 100 and current_price <= 10):
+                                            logger_info(f"銆愭湁姒傚康 鏈夊己搴� 鏃犲己鎷夈�戠灛鏃舵定骞� < 0.5% 锛佺灛鏃舵定骞咃細{round(tick_growth, 2)}%")
                                             return
                                         if last_volume_to_growth_ratio > 0.8 and (free_market_value <= 100 and current_price <= 10):
                                             logger_info(f"銆愪笉鍒┿�戠灛鏃堕噺骞呮瘮> 0.8 涓� (灏忚嚜鐢卞競鍊�<40浜� 鎴� 鏈�鏂颁环灏忎簬20鍏� )锛侊紝鐬椂閲忓箙姣旓細{round(last_volume_to_growth_ratio, 2)}%锛岃嚜鐢卞競鍊硷細{free_market_value} 浜裤��")
diff --git a/strategy/kpl_data_manager.py b/strategy/kpl_data_manager.py
index f2112c8..60b8184 100644
--- a/strategy/kpl_data_manager.py
+++ b/strategy/kpl_data_manager.py
@@ -1,8 +1,42 @@
 from log_module import log_export, async_log_util
-from log_module.log import logger_stock_of_markets_plate, logger_debug
+from log_module.log import logger_stock_of_markets_plate, logger_debug, logger_kpl_market_sift_plate
 from utils import tool
 
+# 寮�鐩樺暒涓偂寮哄害鏃ュ織绠$悊
+@tool.singleton
+class KPLMarketStockHeatLogManager:
+    """
+    绮鹃�夋祦鍏ユ澘鍧椾笌鏉垮潡浠g爜鏃ュ織绠$悊
+    """
 
+    def __init__(self):
+        # 杩囨护鍚庣殑鏃ュ織鏁版嵁
+        self.__filter_log_datas = []
+
+    def __load_data(self):
+        if tool.get_now_time_str() > '13:10:00':
+            logger_debug.info("KPLMarketStockHeatLogManager 寮�濮嬪姞杞芥暟鎹�")
+            datas = log_export.load_market_stock_heat()
+            for data in datas:
+                # (鍙戠敓鏃堕棿,[鍑�娴佸叆鏉垮潡], {"鏉垮潡":(浠g爜, 鍚嶇О, 娑ㄥ箙)})
+                self.__filter_log_datas.append(self.__filter_origin_data(data))
+            logger_debug.info("KPLMarketStockHeatLogManager 鏁版嵁鍔犺浇瀹屾垚锛歿}", len(self.__filter_log_datas))
+
+    def load_data(self):
+        self.__load_data()
+
+    def __filter_origin_data(self, data):
+        return (data[0], [x[1] for x in data[1][0]],
+                {p: [xx for xx in data[1][1][p]] for p in data[1][1]})
+
+    def add_log(self, in_plates_info, plate_codes_info):
+        oringin_data = (tool.get_now_time_str(), in_plates_info, plate_codes_info)
+        async_log_util.info(logger_kpl_market_sift_plate, f"{(oringin_data[1], oringin_data[2])}")
+
+    def get_filter_log_datas(self):
+        return self.__filter_log_datas
+
+# 寮�鐩樺暒涓偂寮哄害鏃ュ織绠$悊
 @tool.singleton
 class KPLStockOfMarketsPlateLogManager:
     """
diff --git a/strategy/plate_strength_analysis.py b/strategy/plate_strength_analysis.py
index 5bdec91..9948648 100644
--- a/strategy/plate_strength_analysis.py
+++ b/strategy/plate_strength_analysis.py
@@ -75,13 +75,14 @@
     # print(f"market_sift_plate 鏁� ======{len(market_sift_plate['list'])}")
 
     # 绮鹃�夋澘鍧椼�愬墠20銆� market_sift_plate['list'] ======
-    if data_cache.OPENING_TIME < now_time < data_cache.CLOSING_TIME:
+    if data_cache.OPENING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
         logger_kpl_market_sift_plate.info(f"{market_sift_plate['list']}")
     # 鎬绘帶鍒舵椂闂存
     if not (data_cache.OPENING_TIME < now_time < data_cache.NOON_MARKET_TIME):
         return
+    # ['801235', '鍖栧伐', 6996, 0.027, 2.43, 117836347690, -122548038, 8105997595, -8228545633, 0.92, 8595377775454, 0.09, 332297449, 9954902621130, -192457252, 24.0487, 17.1809, 6996, 0.027]
     # market_sift_plate['list'][0] = ['801062', '鍐涘伐', 3520, -0.49, 0.666, 139133934669, 383864272, 9077352839, -8693488567, 1.183, 6129448037490,-0.12, 168245858, 7088854452019, -290614763, 50.2408, 30.3672, 3520, 0]
-    # 琛屾儏绮鹃�夋澘鍧楀垪琛� 鍓�20 涓殑 绗竴涓澘鍧楀垪琛ㄦ暟鎹� = 銆愪唬鐮侊紝鏉垮潡鍚嶇О锛屽己搴︼紝娑ㄥ箙锛燂紝0.666锛燂紝鎴愪氦棰濓紵锛岀幇棰濓紵锛屼富涔帮紝涓诲崠锛�1.183锛燂紝娴侀�氬�硷紵锛�-0.12锛燂紝300W澶у崟鍑�棰濓紵锛屾�诲競鍊硷紵锛屼笂瀛e害鏈烘瀯澧炰粨锛屼粖骞村钩鍧嘝E锛屾骞村钩鍧嘝E锛屽己搴︼紝鏈煡0鍊笺��
+    # 琛屾儏绮鹃�夋澘鍧楀垪琛� 鍓�20 涓殑 绗竴涓澘鍧楀垪琛ㄦ暟鎹� = 銆愪唬鐮侊紝鏉垮潡鍚嶇О锛屽己搴︼紝娑ㄥ箙锛燂紝閲忔瘮锛燂紝鎴愪氦棰濓紵锛岀幇棰濓紵锛屼富涔帮紝涓诲崠锛�1.183锛燂紝娴侀�氬�硷紵锛�-0.12锛燂紝300W澶у崟鍑�棰濓紵锛屾�诲競鍊硷紵锛屼笂瀛e害鏈烘瀯澧炰粨锛屼粖骞村钩鍧嘝E锛屾骞村钩鍧嘝E锛屽己搴︼紝鏈煡0鍊笺��
     # logger.info(f"market_sift_plate['list'][0]  ======{market_sift_plate['list'][0]}")
     # 鍒濆鍖栫簿閫夋澘鍧楀搴斾釜鑲″瓧鍏�
     market_sift_plate_stock_dict = {}

--
Gitblit v1.8.0