From 05a02dbd657804f2e1e392f36a57e1cf5c6c3b2f Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 17 十月 2023 14:04:30 +0800
Subject: [PATCH] 修复09:30:00之前开盘啦精选板块可能没有加载的bug

---
 third_data/code_plate_key_manager.py |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/third_data/code_plate_key_manager.py b/third_data/code_plate_key_manager.py
index a3e8e85..1db7f34 100644
--- a/third_data/code_plate_key_manager.py
+++ b/third_data/code_plate_key_manager.py
@@ -7,12 +7,12 @@
 
 import constant
 from db.redis_manager_delegate import RedisUtils
-from third_data import kpl_block_util
+from third_data import kpl_block_util, kpl_api
 from utils import global_util, tool
-from log_module import log
+from log_module import log, async_log_util
 from db import redis_manager_delegate as redis_manager
 
-from log_module.log import logger_kpl_limit_up, logger_kpl_block_can_buy, logger_kpl_debug
+from log_module.log import logger_kpl_limit_up, logger_kpl_block_can_buy
 from third_data.kpl_util import KPLPlatManager
 from trade import trade_manager, l2_trade_util
 
@@ -77,6 +77,26 @@
             return self.__code_by_blocks.get(code)
         else:
             return self.__code_blocks.get(code)
+
+    # 浠庣綉缁滀笂鍔犺浇绮鹃�夋澘鍧�
+    def load_jx_blocks(self, code, buy_1_price, limit_up_price):
+        if limit_up_price and buy_1_price:
+            # 澶勭悊涔�1,鍗�1淇℃伅
+            pre_close_price = round(float(limit_up_price) / 1.1, 2)
+            # 濡傛灉娑ㄥ箙澶т簬7%灏辫鍙栨澘鍧�
+            price_rate = (buy_1_price - pre_close_price) / pre_close_price
+            if price_rate > 0.07:
+                if not self.get_jx_blocks_cache(code):
+                    blocks = kpl_api.getCodeJingXuanBlocks(code)
+                    self.save_jx_blocks(code, blocks)
+                    async_log_util.info(logger_kpl_block_can_buy,f"{code}:鑾峰彇鍒扮簿閫夋澘鍧�-{blocks}")
+            elif price_rate > 0.03:
+                # 娣诲姞澶囩敤鏉垮潡
+                if not self.get_jx_blocks_cache(code, by=True):
+                    blocks = kpl_api.getCodeJingXuanBlocks(code)
+                    self.save_jx_blocks(code, blocks, by=True)
+                    async_log_util.info(logger_kpl_block_can_buy, f"{code}:鑾峰彇鍒扮簿閫夋澘鍧�(澶囩敤)-{blocks}")
+
 
 
 # 寮�鐩樺暒绂佹浜ゆ槗鏉垮潡绠$悊
@@ -291,11 +311,9 @@
     @classmethod
     def is_in_top(cls, keys):
         reasons = cls.get_can_buy_key_set()
-        log.logger_kpl_debug.debug("甯傚満娴佸叆鍓�5:{}", reasons)
         forbidden_plates = cls.__KPLPlateForbiddenManager.list_all_cache()
         reasons = reasons - forbidden_plates
         temp_set = keys & reasons
-        log.logger_kpl_debug.debug("甯傚満娴佸叆鍓�5鍖归厤缁撴灉:{}", temp_set)
         if temp_set:
             return True, temp_set
         else:
@@ -317,7 +335,6 @@
         self.__history_limit_up_reason_dict[code] = set(reasons)
         RedisUtils.setex(self.__get_redis(), f"kpl_his_limit_up_reason-{code}", tool.get_expire(),
                          json.dumps(list(reasons)))
-        logger_kpl_debug.debug(f"璁剧疆鍘嗗彶娑ㄥ仠鍘熷洜锛歿code}-{reasons}")
 
     # 濡傛灉杩斿洖鍊间笉涓篘one琛ㄧず宸茬粡鍔犺浇杩囧巻鍙插師鍥犱簡
     def get_history_limit_up_reason(self, code):
@@ -519,7 +536,7 @@
                 keys |= k4
                 keys = keys - constant.KPL_INVALID_BLOCKS
 
-        log.logger_kpl_debug.info("{}鏈�缁堝叧閿瘝锛歿}", code, keys)
+        # log.logger_kpl_debug.info("{}鏈�缁堝叧閿瘝锛歿}", code, keys)
 
         # 娑ㄥ仠鍒楄〃涓尮閰嶅叧閿瘝锛岃繑鍥烇紙鏉垮潡:浠g爜闆嗗悎锛夛紝浠g爜闆嗗悎涓凡缁忔帓闄よ嚜韬�
         if not keys:

--
Gitblit v1.8.0