From cf89766b43b7e5601220e5144edab8ee9307a8ad Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 26 三月 2025 17:29:03 +0800 Subject: [PATCH] 新题材拉黑机制修改 --- trade/l2_trade_util.py | 2 api/outside_api_command_callback.py | 22 ++++++- code_attribute/code_nature_analyse.py | 2 code_attribute/first_target_code_data_processor.py | 65 +++++++++------------ trade/buy_radical/new_block_processor.py | 30 ++++++++++ servers/data_server.py | 17 ++--- 6 files changed, 85 insertions(+), 53 deletions(-) diff --git a/api/outside_api_command_callback.py b/api/outside_api_command_callback.py index 33e1218..9c233dd 100644 --- a/api/outside_api_command_callback.py +++ b/api/outside_api_command_callback.py @@ -1063,7 +1063,19 @@ except: pass # L鎾ゆ瘮渚� - l_down_cancel_rate, must_buy = LCancelRateManager.get_cancel_rate(code, buy_mode = OrderBeginPosInfo.MODE_RADICAL) + l_down_cancel_rate, must_buy = LCancelRateManager.get_cancel_rate(code, + buy_mode=OrderBeginPosInfo.MODE_RADICAL) + + # 鍦ㄦ寕鐨勮窛绂绘垚浜よ繘搴︿綅閲戦/锛堣繙杩戞湡鍙傝�冮噺-鍗曞綋鏃ュ疄鏃舵垚浜ら噺锛�*100% + expire_rate = "鏈煡" + try: + referer_volume = code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume( + code, limit_up_price) + today_volumn = code_volumn_manager.CodeVolumeManager().get_today_volumn(code) + expire_rate = f"{round(100 * total_left_num * 100 / (referer_volume - today_volumn), 2)}%" + except: + pass + fdata = {"id": orderSysID, "code_info": (code, code_name), "total_num": total_nums, "finish_num": deal_or_cancel_num, "buy1_money": output_util.money_desc(buy1_money), @@ -1087,7 +1099,8 @@ "is_near_big_order": is_near_big_order, "block": '', "trade_queue": [], - "l_down_cancel_rate":l_down_cancel_rate + "l_down_cancel_rate": l_down_cancel_rate, + "expire_rate": expire_rate } limit_up_data = kpl_data_manager.KPLLimitUpDataRecordManager.record_code_dict.get(code) # 鑾峰彇褰撳墠鏉垮潡 @@ -1354,7 +1367,7 @@ "zyltgb": constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES, "top_block_count_by_market_strong": constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG, "special_codes_max_block_in_rank": constant.RADICAL_BUY_TOP_IN_INDEX_WITH_SPECIAL, - "ignore_block_in_money_market_strong":constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG + "ignore_block_in_money_market_strong": constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG }} self.send_response({"code": 0, "data": data, "msg": f""}, client_id, @@ -1373,7 +1386,8 @@ constant.RADICAL_BUY_TOP_IN_INDEX_WITH_SPECIAL = radical_buy.get( "special_codes_max_block_in_rank") if radical_buy.get('ignore_block_in_money_market_strong') is not None: - constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG = radical_buy.get('ignore_block_in_money_market_strong') + constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG = radical_buy.get( + 'ignore_block_in_money_market_strong') self.send_response({"code": 0, "data": {}, "msg": f""}, client_id, request_id) diff --git a/code_attribute/code_nature_analyse.py b/code_attribute/code_nature_analyse.py index 8a440e8..e259959 100644 --- a/code_attribute/code_nature_analyse.py +++ b/code_attribute/code_nature_analyse.py @@ -472,7 +472,7 @@ def __is_new_top(code, limit_up_price, datas): datas = copy.deepcopy(datas) datas.sort(key=lambda x: x["bob"]) - datas = datas[-80:] + datas = datas[-60:] max_price = 0 for data in datas: if max_price < data["high"]: diff --git a/code_attribute/first_target_code_data_processor.py b/code_attribute/first_target_code_data_processor.py index f19fc47..35a6c9a 100644 --- a/code_attribute/first_target_code_data_processor.py +++ b/code_attribute/first_target_code_data_processor.py @@ -18,6 +18,7 @@ from third_data.history_k_data_util import HistoryKDatasUtils, JueJinApi from trade import l2_trade_util from settings.trade_setting import MarketSituationManager +from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager from utils import global_util, tool, init_data_util, buy_condition_util __CodesPlateKeysManager = CodesHisReasonAndBlocksManager() @@ -121,46 +122,36 @@ k_format = code_nature_analyse.get_k_format(code, limit_up_price, volumes_data) code_nature_analyse.CodeNatureRecordManager().save_k_format(code, k_format) - # 鏄惁鍏锋湁杈ㄨ瘑搴� - is_special = True if k_format and k_format[8][0] else False if not WantBuyCodesManager().is_in_cache( code) and not gpcode_manager.BuyOpenLimitUpCodeManager().is_in_cache(code): - # 涓嶆槸鎯充拱鍗曪紝涔熶笉鏄帓涓�鐨勪唬鐮� - # if not is_special: - # situation = MarketSituationManager().get_situation_cache() - # zylt_threshold_as_yi = buy_condition_util.get_zyltgb_threshold(situation) - # if global_util.zyltgb_map.get(code) and global_util.zyltgb_map.get(code) > zylt_threshold_as_yi[ - # 1] * 100000000: - # l2_trade_util.forbidden_trade(code, - # f"鏃犺鲸璇嗗害锛岃嚜鐢辨祦閫氬競鍊�({global_util.zyltgb_map.get(code) // 100000000})>{zylt_threshold_as_yi[1]}浜�") - # continue - # elif limit_up_price and float(limit_up_price) >= constant.MAX_CODE_PRICE: - # l2_trade_util.forbidden_trade(code, - # f"鏃犺鲸璇嗗害锛屾定鍋滀环({limit_up_price})>{constant.MAX_CODE_PRICE}") - # continue - if code_nature_analyse.is_price_too_high_in_days(code, volumes_data, limit_up_price)[0]: - # 鍒ゆ柇鏄惁澶珮 - l2_trade_util.forbidden_trade(code, "6澶╁唴鑲′环闀垮緱澶珮") - continue - - if tool.is_ge_code(code) and float(limit_up_price) < 10: - l2_trade_util.forbidden_trade(code, "鍒涗笟鏉胯偂浠�10鍧楀唴") - - if len(k_format) > 14 and k_format[14]: - l2_trade_util.forbidden_trade(code, "鏄ㄦ棩鐐告澘") - continue - - # if code_nature_analyse.is_continue_limit_up_not_enough_fall_dwon(code, volumes_data): - # # 鍒ゆ柇鏄惁澶珮 - # l2_trade_util.forbidden_trade(code, "鍥炶俯涓嶅") - # continue - try: - if not __is_normal_in_5d(code): - l2_trade_util.forbidden_trade(code, "鏈�杩�5澶╂湁ST/闈炴甯哥姸鎬�") + need_forbidden = True + # 鏂伴鏉愮牬鍓嶉珮灏变笉闇�瑕佸姞榛� + if BlockSpecialCodesManager().get_code_blocks(code) and k_format and k_format[1]: + need_forbidden = False + if need_forbidden: + if code_nature_analyse.is_price_too_high_in_days(code, volumes_data, limit_up_price)[0]: + # 鍒ゆ柇鏄惁澶珮 + l2_trade_util.forbidden_trade(code, "6澶╁唴鑲′环闀垮緱澶珮") continue - except Exception as e: - logger_debug.error(f"{code}鍑洪敊__is_normal_in_5d") - logger_debug.exception(e) + + if tool.is_ge_code(code) and float(limit_up_price) < 10: + l2_trade_util.forbidden_trade(code, "鍒涗笟鏉胯偂浠�10鍧楀唴") + + if len(k_format) > 14 and k_format[14]: + l2_trade_util.forbidden_trade(code, "鏄ㄦ棩鐐告澘") + continue + + # if code_nature_analyse.is_continue_limit_up_not_enough_fall_dwon(code, volumes_data): + # # 鍒ゆ柇鏄惁澶珮 + # l2_trade_util.forbidden_trade(code, "鍥炶俯涓嶅") + # continue + try: + if not __is_normal_in_5d(code): + l2_trade_util.forbidden_trade(code, "鏈�杩�5澶╂湁ST/闈炴甯哥姸鎬�") + continue + except Exception as e: + logger_debug.error(f"{code}鍑洪敊__is_normal_in_5d") + logger_debug.exception(e) if code_nature_analyse.is_up_too_high_in_10d_with_limit_up(code, volumes_data): # 鍒ゆ柇鏄惁澶珮 diff --git a/servers/data_server.py b/servers/data_server.py index 818b8e0..55d1ba8 100644 --- a/servers/data_server.py +++ b/servers/data_server.py @@ -9,7 +9,7 @@ import requests import constant -from code_attribute.gpcode_manager import BlackListCodeManager +from code_attribute.gpcode_manager import BlackListCodeManager, HumanRemoveForbiddenManager from l2.huaxin import huaxin_target_codes_manager from l2.l2_transaction_data_manager import HuaXinBuyOrderManager from log_module.log import logger_system, logger_debug, logger_kpl_limit_up, logger_request_api @@ -18,12 +18,12 @@ ContainsLimitupCodesBlocksManager from third_data.kpl_limit_up_data_manager import LatestLimitUpBlockManager, CodeLimitUpSequenceManager from third_data.third_blocks_manager import BlockMapManager -from trade.buy_radical import radical_buy_data_manager +from trade.buy_radical import radical_buy_data_manager, new_block_processor 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, BeforeSubDealBigOrderManager from utils import global_util, tool, data_export_util -from code_attribute import gpcode_manager +from code_attribute import gpcode_manager, code_nature_analyse from log_module import log_analyse, log_export, async_log_util from l2 import code_price_manager, l2_data_util, transaction_progress from cancel_strategy.s_l_h_cancel_strategy import HourCancelBigNumComputer, LCancelRateManager @@ -1045,10 +1045,8 @@ if code_info_list: # 灏嗕唬鐮佸姞鍏ユ柊棰樻潗 for x in code_info_list: - add_result = LimitUpCodesBlockRecordManager().add_new_blocks(x[0], bi[0]) - if add_result: - # 澧炲姞鏂伴鏉愭槸鍚︽垚鍔燂紝 涓存椂灏嗙エ鍔犲叆杈ㄨ瘑搴� - BlockSpecialCodesManager().add_code_block_for_temp(x[0], bi[0]) + new_block_processor.process_new_block(x[0], bi[0]) + try: if result_list_: @@ -1145,10 +1143,7 @@ update_new_block_plates = [] for r in reasons: for c in block_codes[r]: - add_result = LimitUpCodesBlockRecordManager().add_new_blocks(c, r) - if add_result: - # 澧炲姞鏂伴鏉愭槸鍚︽垚鍔燂紝 涓存椂灏嗙エ鍔犲叆杈ㄨ瘑搴� - BlockSpecialCodesManager().add_code_block_for_temp(c, r) + new_block_processor.process_new_block(c, r) for r in reasons: if r in block_plate_code_dict: diff --git a/trade/buy_radical/new_block_processor.py b/trade/buy_radical/new_block_processor.py new file mode 100644 index 0000000..1daaf11 --- /dev/null +++ b/trade/buy_radical/new_block_processor.py @@ -0,0 +1,30 @@ +""" +鏂伴鏉愬鐞嗗櫒 +""" +from code_attribute import code_nature_analyse +from code_attribute.gpcode_manager import HumanRemoveForbiddenManager +from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager +from trade import l2_trade_util, trade_record_log_util +from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager + + +def process_new_block(code, block): + """ + 澶勭悊鏂伴鏉� + @param code: + @param block: + @return: + """ + add_result = LimitUpCodesBlockRecordManager().add_new_blocks(code, block) + if add_result: + # 澧炲姞鏂伴鏉愭槸鍚︽垚鍔燂紝 涓存椂灏嗙エ鍔犲叆杈ㄨ瘑搴� + BlockSpecialCodesManager().add_code_block_for_temp(code, block) + # 鏂伴鏉愮牬鍓嶉珮灏辩Щ榛� + k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) + if k_format and k_format[1]: + if l2_trade_util.is_in_forbidden_trade_codes(code): + l2_trade_util.remove_from_forbidden_trade_codes(code) + # 鍔犳兂涔板崟瑕佷粠榛戝悕鍗曠Щ闄� + trade_record_log_util.add_common_msg(code, "鏂伴鏉愮Щ榛�", block) + + # diff --git a/trade/l2_trade_util.py b/trade/l2_trade_util.py index f37a9e0..acc73a8 100644 --- a/trade/l2_trade_util.py +++ b/trade/l2_trade_util.py @@ -4,6 +4,7 @@ from log_module import async_log_util from log_module.log import logger_trade from trade import trade_record_log_util +from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager __redis_manager = redis_manager.RedisManager(2) @@ -37,6 +38,7 @@ need_add = False else: need_add = True + if need_add: if not is_in_forbidden_trade_codes(code): trade_record_log_util.add_forbidden_buy_log(code, msg) -- Gitblit v1.8.0