From fb47d36048e94b9a506d5c153e3dd19a01e37df1 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 30 十月 2023 16:30:27 +0800 Subject: [PATCH] bug修复 --- third_data/code_plate_key_manager.py | 39 ++++++++++++++++++++++++++------------- 1 files changed, 26 insertions(+), 13 deletions(-) diff --git a/third_data/code_plate_key_manager.py b/third_data/code_plate_key_manager.py index e68df3b..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): @@ -441,7 +458,7 @@ @classmethod def __is_block_can_buy(cls, code, block, current_limit_up_datas, code_limit_up_reason_dict, yesterday_current_limit_up_codes, limit_up_record_datas): - log.logger_kpl_debug.info(f"鍒ゆ柇鏉垮潡鏄惁鍙拱锛歿block}") + # log.logger_kpl_debug.info(f"鍒ゆ柇鏉垮潡鏄惁鍙拱锛歿block}") # is_top_8_record, top_8_record = kpl_block_util.is_record_top_block(code, block, limit_up_record_datas, # yesterday_current_limit_up_codes, 50) # is_top_4_current, top_4_current = kpl_block_util.is_current_top_block(code, block, current_limit_up_datas, @@ -506,7 +523,7 @@ # 鑾峰彇鐩爣浠g爜鏉垮潡 keys, k1, k11, k2, k3, k4 = cls.__TargetCodePlateKeyManager.get_plate_keys(code) - log.logger_kpl_debug.info("{}鍏抽敭璇嶏細浠婃棩-{},浠婃棩鍘嗗彶-{},鍘嗗彶-{},浜岀骇琛屼笟-{},浠g爜鏉垮潡-{}", code, k1, k11, k2, k3, k4) + # log.logger_kpl_debug.info("{}鍏抽敭璇嶏細浠婃棩-{},浠婃棩鍘嗗彶-{},鍘嗗彶-{},浜岀骇琛屼笟-{},浠g爜鏉垮潡-{}", code, k1, k11, k2, k3, k4) keys = set() if k1: for k in k1: @@ -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: @@ -564,7 +581,6 @@ before_blocks_dict) if not blocks: return False, block_msg - log.logger_kpl_debug.info(f"{code}:鑾峰彇濮旀墭/涔板叆浠g爜") codes_delegate = set(cls.__CodesTradeStateManager.get_codes_by_trade_states_cache( {trade_manager.TRADE_STATE_BUY_DELEGATED, trade_manager.TRADE_STATE_BUY_PLACE_ORDER})) codes_success = set(cls.__CodesTradeStateManager.get_codes_by_trade_states_cache( @@ -576,13 +592,11 @@ trade_codes_blocks_dict = {} # 宸茬粡鎴愪氦鐨勬澘鍧� trade_success_blocks_count = {} - log.logger_kpl_debug.info(f"{code}:鑾峰彇浠g爜鏉垮潡") for c in codes: keys_, k1_, k11_, k2_, k3_, k4_ = cls.__TargetCodePlateKeyManager.get_plate_keys(c) # 瀹炴椂娑ㄥ仠鍘熷洜 trade_codes_blocks_dict[c] = k1_ | k4_ # 缁熻鏉垮潡涓殑浠g爜 - log.logger_kpl_debug.info(f"{code}:缁熻鏉垮潡涓殑浠g爜") trade_block_codes_dict = {} for c in trade_codes_blocks_dict: for b in trade_codes_blocks_dict[c]: @@ -595,7 +609,6 @@ trade_block_codes_dict[b].add(c) # ---------------------------------鍔犺浇宸茬粡涓嬪崟/鎴愪氦鐨勪唬鐮佷俊鎭�------------end------------- - log.logger_kpl_debug.info(f"{code}:寮�濮嬭绠楁槸鍚﹀彲浠ヤ拱") msg_list = [] for key in blocks: # 鏉垮潡涓凡缁忔湁鎴愪氦鐨勫氨涓嶄笅鍗曚簡 -- Gitblit v1.8.0