From acd3f8f4d658f8261f3a592d7943c065e0b6fc71 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 04 九月 2023 14:56:20 +0800 Subject: [PATCH] 订阅代码增加跟踪日志 --- code_attribute/first_target_code_data_processor.py | 134 +++++++++++++++++++++++--------------------- 1 files changed, 71 insertions(+), 63 deletions(-) diff --git a/code_attribute/first_target_code_data_processor.py b/code_attribute/first_target_code_data_processor.py index ec08354..072cacd 100644 --- a/code_attribute/first_target_code_data_processor.py +++ b/code_attribute/first_target_code_data_processor.py @@ -10,7 +10,7 @@ from code_attribute import gpcode_manager, gpcode_first_screen_manager, global_data_loader, code_nature_analyse, \ code_volumn_manager from code_attribute.code_data_util import ZYLTGBUtil -from log_module.log import logger_first_code_record +from log_module.log import logger_first_code_record, logger_l2_codes_subscript from third_data import kpl_api, block_info from third_data.code_plate_key_manager import CodesHisReasonAndBlocksManager from third_data.history_k_data_util import HistoryKDatasUtils @@ -22,7 +22,8 @@ __CodesPlateKeysManager = CodesHisReasonAndBlocksManager() -def process_first_codes_datas(dataList): +def process_first_codes_datas(dataList, request_id=None): + logger_l2_codes_subscript.info(f"{request_id}鍔犺浇l2浠g爜鐩稿叧鏁版嵁") print("棣栨澘浠g爜鏁伴噺锛�", len(dataList)) limit_up_price_dict = {} temp_codes = [] @@ -34,7 +35,7 @@ codes.append(code) # ---鏌ヨ鎯充拱鍗曪紝濡傛灉娌℃湁鍦ㄥ垪琛ㄤ腑灏遍渶瑕佸己琛屽姞鍏ュ垪琛� - want_codes = gpcode_manager.WantBuyCodesManager.list_code() + want_codes = gpcode_manager.WantBuyCodesManager().list_code_cache() if want_codes: # 娌℃湁鍦ㄧ幇浠烽噰闆嗕腑鐨勬兂涔颁唬鐮� diff_codes = set(want_codes) - set(codes) @@ -65,18 +66,18 @@ # ---淇濆瓨鏈瓫閫夌殑棣栨澘浠g爜 new_add_codes = gpcode_first_screen_manager.set_target_no_screen_codes(codes) - # 淇濆瓨鑷敱娴侀�氳偂鏈� - if dataList: - zyltgb_list = [] - for data in dataList: - code = data["code"] - if code in global_util.zyltgb_map: - continue - zyltgb_list.append( - {"code": code, "zyltgb": data["zyltgb"], "zyltgb_unit": data["zyltgbUnit"]}) - if zyltgb_list: - ZYLTGBUtil.save_list(zyltgb_list) - global_data_loader.load_zyltgb() + # 淇濆瓨鑷敱娴侀�氳偂鏈紝鏆傛椂涓嶄繚瀛� + # if dataList: + # zyltgb_list = [] + # for data in dataList: + # code = data["code"] + # if code in global_util.zyltgb_map: + # continue + # zyltgb_list.append( + # {"code": code, "zyltgb": data["zyltgb"], "zyltgb_unit": data["zyltgbUnit"]}) + # if zyltgb_list: + # ZYLTGBUtil.save_list(zyltgb_list) + # global_data_loader.load_zyltgb() # 鑾峰彇鏄ㄦ棩鏀剁洏浠� for code in codes: @@ -84,58 +85,65 @@ if gpcode_manager.get_limit_up_price(code) is None: inited_data.re_set_price_pres([code], True) - # 鏉垮潡鍏抽敭瀛楀噯澶� - for code in codes: - if __CodesPlateKeysManager.get_history_limit_up_reason(code) is None: - # 浠庢暟鎹簱鍔犺浇鍘嗗彶娑ㄥ仠鍘熷洜 - __CodesPlateKeysManager.set_history_limit_up_reason(code, - KPLLimitUpDataRecordManager.get_latest_blocks_set( - code)) - if __CodesPlateKeysManager.get_blocks(code) is None: - try: - results = kpl_api.getStockIDPlate(code) - bs = [r[1] for r in results] - __CodesPlateKeysManager.set_blocks(code, bs) - except Exception as e: - logging.exception(e) - pass + # 鏉垮潡鍏抽敭瀛楀噯澶� 鏆傛椂鍒犻櫎 + # for code in codes: + # if __CodesPlateKeysManager.get_history_limit_up_reason(code) is None: + # # 浠庢暟鎹簱鍔犺浇鍘嗗彶娑ㄥ仠鍘熷洜 + # __CodesPlateKeysManager.set_history_limit_up_reason(code, + # KPLLimitUpDataRecordManager.get_latest_blocks_set( + # code)) + # if __CodesPlateKeysManager.get_blocks(code) is None: + # try: + # results = kpl_api.getStockIDPlate(code) + # bs = [r[1] for r in results] + # __CodesPlateKeysManager.set_blocks(code, bs) + # except Exception as e: + # logging.exception(e) + # pass # 鑾峰彇60澶╂渶澶ц褰� for code in codes: need_get_volumn = False if code not in global_util.max60_volumn or global_util.max60_volumn.get(code) is None: need_get_volumn = True - if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature( - code) is None: - need_get_volumn = True + # if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature_cache( + # code) is None: + # need_get_volumn = True if need_get_volumn: - volumes_data = inited_data.get_volumns_by_code(code, 150) - volumes = inited_data.parse_max_volume(volumes_data[:90], - code_nature_analyse.is_new_top( - gpcode_manager.get_limit_up_price(code), - volumes_data[:90])) - logger_first_code_record.info("{} 鑾峰彇鍒伴鏉�60澶╂渶澶ч噺锛歿}", code, volumes) - code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) - # 鍒ゆ柇K绾垮舰鎬� - # is_has_k_format, msg = code_nature_analyse.is_has_k_format( - # gpcode_manager.get_limit_up_price(code), volumes_data) - # if not is_has_k_format: - # logger_first_code_record.info("{}棣栨澘K绾垮舰鎬佷笉濂�,{}", code, msg) - # # 鑲℃�т笉濂斤紝灏变笉瑕佸姞鍏� - # bad_codes.add(code) - # # 鍔犲叆绂佹浜ゆ槗浠g爜 - # l2_trade_util.forbidden_trade(code) - code_nature_analyse.set_record_datas(code, - gpcode_manager.get_limit_up_price(code), - volumes_data) - gpcode_manager.FirstCodeManager.add_record(codes) - # 鍒濆鍖栨澘鍧椾俊鎭� - for code in codes: - block_info.init_code(code) + limit_up_price = gpcode_manager.get_limit_up_price(code) + if limit_up_price is None: + continue + try: + volumes_data = inited_data.get_volumns_by_code(code, 150) + volumes = inited_data.parse_max_volume(volumes_data[:90], + code_nature_analyse.is_new_top( + limit_up_price, + volumes_data[:90])) + logger_first_code_record.info("{} 鑾峰彇鍒伴鏉�60澶╂渶澶ч噺锛歿}", code, volumes) + code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) + # 鍒ゆ柇K绾垮舰鎬� + # is_has_k_format, msg = code_nature_analyse.is_has_k_format( + # gpcode_manager.get_limit_up_price(code), volumes_data) + # if not is_has_k_format: + # logger_first_code_record.info("{}棣栨澘K绾垮舰鎬佷笉濂�,{}", code, msg) + # # 鑲℃�т笉濂斤紝灏变笉瑕佸姞鍏� + # bad_codes.add(code) + # # 鍔犲叆绂佹浜ゆ槗浠g爜 + # l2_trade_util.forbidden_trade(code) + # 鏆傛椂涓嶄繚瀛楰绾垮舰鎬� + # code_nature_analyse.set_record_datas(code, + # gpcode_manager.get_limit_up_price(code), + # volumes_data) + except Exception as e: + logger_first_code_record.error(f"{code}:{str(e)}") + gpcode_manager.FirstCodeManager().add_record(codes) + # 鍒濆鍖栨澘鍧椾俊鎭紝鏆傛椂鍒犻櫎 + # for code in codes: + # block_info.init_code(code) if new_add_codes: - gpcode_manager.set_first_gp_codes_with_data(HistoryKDatasUtils.get_gp_latest_info(codes, - fields="symbol,sec_name,sec_type,sec_level")) + gpcode_manager.FirstGPCodesManager().set_first_gp_codes_with_data(HistoryKDatasUtils.get_gp_latest_info(codes, + fields="symbol,sec_name,sec_type,sec_level")) # 鍔犲叆棣栨澘鍘嗗彶璁板綍 logger_first_code_record.info("鏂板棣栨澘锛歿}", new_add_codes) @@ -184,8 +192,8 @@ limit_up_time = tool.get_now_time_str() if is_limit_up: # 鍔犲叆棣栨澘娑ㄥ仠 - gpcode_manager.FirstCodeManager.add_limited_up_record([code]) - pricePre = gpcode_manager.get_price_pre(code) + gpcode_manager.FirstCodeManager().add_limited_up_record([code]) + pricePre = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code) if pricePre is None: inited_data.re_set_price_pres([code]) @@ -195,11 +203,11 @@ "limit_up": is_limit_up}) if code in new_add_codes: if is_limit_up: - place_order_count = trade_data_manager.placeordercountmanager.get_place_order_count( + place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count( code) if place_order_count == 0: - trade_data_manager.placeordercountmanager.place_order(code) + trade_data_manager.PlaceOrderCountManager().place_order(code) gpcode_first_screen_manager.process_ticks(prices) - + logger_l2_codes_subscript.info(f"{request_id}l2浠g爜鐩稿叧鏁版嵁鍔犺浇瀹屾垚") return tick_datas -- Gitblit v1.8.0