From d670ee4074c8eddd7a1471fb7e49f5c204b139c2 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 15 十一月 2024 01:11:01 +0800 Subject: [PATCH] 代码辨识度确认 --- servers/data_server.py | 66 +++++++++++++++++++++++++++++--- 1 files changed, 59 insertions(+), 7 deletions(-) diff --git a/servers/data_server.py b/servers/data_server.py index d6e0989..b4deddc 100644 --- a/servers/data_server.py +++ b/servers/data_server.py @@ -12,6 +12,7 @@ from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager, LimitUpDataConstant from third_data.kpl_limit_up_data_manager import LatestLimitUpBlockManager, CodeLimitUpSequenceManager from third_data.third_blocks_manager import BlockMapManager +from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager from trade.buy_strategy import OpenLimitUpGoodBlocksBuyStrategy from trade.buy_radical.radical_buy_data_manager import RadicalBuyBlockManager from utils import global_util, tool, data_export_util @@ -98,7 +99,7 @@ # (鏉垮潡鍚嶇О锛屾定鍋滀唬鐮佹暟閲忥紝鐐告澘鏁伴噺,娑ㄥ仠鏃堕棿) limit_up_reason_statistic_info = [(k, len(record_reason_dict[k]), len(record_reason_dict[k]) - len( current_reason_dict.get(k) if k in current_reason_dict else []), - int(records_map.get([record_reason_dict[k][0]])[5])) for k in record_reason_dict] + 0) for k in record_reason_dict] limit_up_reason_statistic_info.sort(key=lambda x: x[1] - x[2]) limit_up_reason_statistic_info.reverse() @@ -447,6 +448,9 @@ # 鑾峰彇娑ㄥ仠鍘熷洜涓嬮潰鐨勪唬鐮� ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) plate = kpl_util.filter_block(ps_dict["plate"]) + special_codes = BlockSpecialCodesManager().get_block_codes(plate) + if special_codes is None: + special_codes = set() # 鑾峰彇鏉垮潡涓嬬殑浠g爜 # 缁熻鐩墠涓烘鐨勪唬鐮佹定鍋滄暟閲忥紙鍒嗘定鍋滃師鍥狅級 now_limit_up_codes_info = self.__kplDataManager.get_data(KPLDataType.LIMIT_UP) @@ -466,7 +470,8 @@ # 浠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]), 1, 1 if l2_trade_util.is_in_forbidden_trade_codes(d[3]) else 0]) + output_util.money_desc(d[13]), 1, 1 if l2_trade_util.is_in_forbidden_trade_codes(d[3]) else 0, + 1 if d[3] in special_codes else 0]) for d in record_limit_up_datas: if kpl_util.filter_block(d[2]) == plate: @@ -495,6 +500,15 @@ # 鑾峰彇娑ㄥ仠鍘熷洜涓嬮潰鐨勪唬鐮� ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) plate = kpl_util.filter_block(ps_dict["plate"]) + + special_codes = set() + plates = BlockMapManager().filter_blocks({plate}) + for p in plates: + _codes = BlockSpecialCodesManager().get_block_codes(p) + if _codes is None: + _codes = set() + special_codes |= _codes + # 鑾峰彇鏉垮潡涓嬬殑浠g爜 # 缁熻鐩墠涓烘鐨勪唬鐮佹定鍋滄暟閲忥紙鍒嗘定鍋滃師鍥狅級 now_limit_up_codes_info = self.__kplDataManager.get_data(KPLDataType.LIMIT_UP) @@ -521,7 +535,7 @@ # 浠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]), 1, 1 if l2_trade_util.is_in_forbidden_trade_codes(d[3]) else 0]) + output_util.money_desc(d[13]), 1, 1 if l2_trade_util.is_in_forbidden_trade_codes(d[3]) else 0, 1 if d[3] in special_codes else 0]) codes_info.sort(key=lambda x: x[2]) # 鏌ヨ鏄惁涓烘兂涔板崟 green_codes = gpcode_manager.GreenListCodeManager().list_codes_cache() @@ -956,10 +970,48 @@ if __name__ == "__main__": - code = "603359" - records = code_info_output.load_trade_record_cancel_watch_indexes(code, - trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_H) - print(records) + # 缁熻鐩墠涓烘鐨勪唬鐮佹定鍋滄暟閲忥紙鍒嗘定鍋滃師鍥狅級 + currents = LimitUpDataConstant.current_limit_up_datas + records = LimitUpDataConstant.history_limit_up_datas + if not currents: + currents = KPLDataManager.get_data(KPLDataType.LIMIT_UP) + # 鑾峰彇鍘嗗彶娑ㄥ仠 + if not records: + KPLLimitUpDataRecordManager.load_total_datas() + records = KPLLimitUpDataRecordManager.total_datas + + records_map = {x[3]: x for x in records} + current_codes = [d[0] for d in currents] + record_codes = [d[3] for d in records] + # 璁$畻娑ㄥ仠鏃堕棿鎺掑簭 + record_reason_dict = {} + current_reason_dict = {} + for _code in record_codes: + blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(_code) + if not blocks: + blocks = set() + for b in blocks: + if b not in record_reason_dict: + record_reason_dict[b] = [] + record_reason_dict[b].append(_code) + for _code in current_codes: + blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(_code) + if not blocks: + blocks = set() + for b in blocks: + if b not in current_reason_dict: + current_reason_dict[b] = [] + current_reason_dict[b].append(_code) + # (鏉垮潡鍚嶇О锛屾定鍋滀唬鐮佹暟閲忥紝鐐告澘鏁伴噺,娑ㄥ仠鏃堕棿) + limit_up_reason_statistic_info = [(k, len(record_reason_dict[k]), len(record_reason_dict[k]) - len( + current_reason_dict.get(k) if k in current_reason_dict else []), + 0) for k in record_reason_dict] + limit_up_reason_statistic_info.sort(key=lambda x: x[1] - x[2]) + limit_up_reason_statistic_info.reverse() + + response_data = json.dumps({"code": 0, "data": {"limit_up_count": len(current_codes), + "open_limit_up_count": len(record_codes) - len(current_codes), + "limit_up_reason_statistic": limit_up_reason_statistic_info}}) # data = code_info_output.get_output_params(code, self.__jingxuan_cache_dict, self.__industry_cache_dict, # trade_record_date=date) -- Gitblit v1.8.0