From 96ede6bdcb28d8d2a8d50146564cbbc67bacf23b Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 13 三月 2024 16:21:46 +0800 Subject: [PATCH] 板上买的条件调整 --- third_data/data_server.py | 20 ++++++++++ log_module/log_export.py | 14 ++++++ third_data/kpl_data_manager.py | 18 ++++++++ log_module/log.py | 11 ++++- l2/cancel_buy_strategy.py | 2 l2/l2_data_manager_new.py | 40 ++++++++++++++++++-- 6 files changed, 95 insertions(+), 10 deletions(-) diff --git a/l2/cancel_buy_strategy.py b/l2/cancel_buy_strategy.py index fafb09e..5700c6c 100644 --- a/l2/cancel_buy_strategy.py +++ b/l2/cancel_buy_strategy.py @@ -1744,7 +1744,7 @@ total_deal_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1] // 100) limit_up_price = gpcode_manager.get_limit_up_price(code) deal_money = int(total_deal_num * float(limit_up_price) * 100) - if deal_money >= order_position.sell_info[1] * 2 and order_position.sell_info[1] > 500*10000: + if deal_money >= order_position.sell_info[1] * 2 and order_position.sell_info[1] > 1000*10000: return True, f"鎴愪氦閲戦锛歿deal_money}/{order_position.sell_info[1] * 2}" return False, "鎴愪氦閲戦涓嶆弧瓒�" except Exception as e: diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py index 7eae4e3..d611564 100644 --- a/l2/l2_data_manager_new.py +++ b/l2/l2_data_manager_new.py @@ -1619,10 +1619,18 @@ limit_up_price = gpcode_manager.get_limit_up_price(code) if limit_up_price is None: raise Exception("娑ㄥ仠浠锋棤娉曡幏鍙�") + limit_up_price = float(limit_up_price) threshold_num = None # 澶х洰鏍囨墜鏁帮紙婊¤冻杩欎釜灏变笉闇�瑕佺湅瀹夊叏绗旀暟锛� threshold_max_num = None + + # 鐩爣璁㈠崟鏁伴噺 + threshold_count = cls.__l2PlaceOrderParamsManagerDict[code].get_safe_count() + + # 鏈�澶ч棿闅旀椂闂磎s + max_space_time_ms = cls.__l2PlaceOrderParamsManagerDict[code].get_time_range() * 1000 + # ----------------璋冩暣鏉夸笂涓嬪崟鐨刴鍊间笌瀹夊叏绗旀暟---------------- if at_limit_up: # 鏉夸笂涔帮紝鑾峰彇鏈�杩戜竴娆¢棯鐢典笅鍗曠殑鎬诲崠棰� @@ -1632,6 +1640,32 @@ # 鎬诲崠鐨勪竴鍗婁綔涓簃鍊� threshold_num = int(sell_data[1] / (limit_up_price * 100)) // 2 threshold_max_num = 1 + # 淇″彿涓轰箣鍓嶆湁寰呮垚浜ょ殑澶у崟锛堜笉鏄鍦ㄦ垚浜わ級 + trade_index,is_default = cls.__TradeBuyQueue.get_traded_index(code) + if not is_default and trade_index is not None: + temp_big_num = int(30000/limit_up_price) + for i in range(trade_index+1, buy_single_index): + data = total_datas[i] + val = data['val'] + if not L2DataUtil.is_limit_up_price_buy(val): + continue + # 鍒ゆ柇鏄惁鏈夊ぇ鍗曟湭鎴愪氦 + if temp_big_num > val["num"]: + continue + + left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, + data[ + "index"], + total_datas, + local_today_canceled_buyno_map.get( + code)) + if left_count > 0: + # 瀹夊叏绗旀暟涓庡泭鎷椂闂磋寖鍥翠慨鏀� + threshold_count = 3 + max_space_time_ms = 9*1000 + break + + if not threshold_num: # 鐩爣鎵嬫暟 @@ -1640,16 +1674,14 @@ threshold_max_num = int(threshold_num * 1.2) # place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) - # 鐩爣璁㈠崟鏁伴噺 - threshold_count = cls.__l2PlaceOrderParamsManagerDict[code].get_safe_count() + # buy_single_time_seconds = L2DataUtil.get_time_as_second(total_datas[buy_single_index]["val"]["time"]) # 鍙互瑙﹀彂涔帮紝褰撴湁娑ㄥ仠涔颁俊鍙锋椂鎵嶄細瑙﹀彂涔� trigger_buy = True - # 鏈�澶ч棿闅旀椂闂磎s - max_space_time_ms = cls.__l2PlaceOrderParamsManagerDict[code].get_time_range() * 1000 + # 濡傛灉澶у崟鍚湁鐜囧ぇ浜�50%锛屽垯鏃堕棿鍥婃嫭鑼冨洿鎻愰珮鍒�3s if max_num_set and origin_count: if len(max_num_set) / origin_count > 0.5: diff --git a/log_module/log.py b/log_module/log.py index af0b7ae..c4ab4a3 100644 --- a/log_module/log.py +++ b/log_module/log.py @@ -197,6 +197,10 @@ filter=lambda record: record["extra"].get("name") == "kpl_block_can_buy", rotation="00:00", compression="zip", enqueue=True) + logger.add(self.get_path("kpl", "kpl_open_limit_up"), + filter=lambda record: record["extra"].get("name") == "kpl_open_limit_up", + rotation="00:00", compression="zip", enqueue=True) + # 鐪嬬洏鏃ュ織 logger.add(self.get_path("kp", "kp_msg"), filter=lambda record: record["extra"].get("name") == "kp_msg", @@ -380,6 +384,8 @@ logger_kpl_block_can_buy = __mylogger.get_logger("kpl_block_can_buy") +logger_kpl_open_limit_up = __mylogger.get_logger("kpl_open_limit_up") + logger_kp_msg = __mylogger.get_logger("kp_msg") logger_redis_debug = __mylogger.get_logger("redis_debug") @@ -424,6 +430,5 @@ if __name__ == "__main__": - close_print() - logger_local_huaxin_l1.info("娴嬭瘯") - input() + open_limit_up_codes = set({"000333","000222"}) + logger_kpl_open_limit_up.info(f"鐐告澘浠g爜锛歿open_limit_up_codes}") diff --git a/log_module/log_export.py b/log_module/log_export.py index 8dfa4da..b42ce5b 100644 --- a/log_module/log_export.py +++ b/log_module/log_export.py @@ -402,6 +402,18 @@ return fdatas +def load_kpl_open_limit_up(): + path = f"{constant.get_path_prefix()}/logs/gp/kpl/kpl_open_limit_up.{tool.get_now_date_str()}.log" + fdatas = [] + lines = __load_file_content(path) + for line in lines: + if line.find("鐐告澘") > 0: + time_str = __get_log_time(line) + data = line[line.find("锛�") + 1:] + codes = eval(data) + fdatas.append((time_str, codes)) + return fdatas + # 鍔犺浇鍗庨懌鏈湴涔板叆璁㈠崟鍙� def load_huaxin_local_buy_no(): path = f"{constant.get_path_prefix()}/logs/huaxin_local/l2/l2_buy_no.{tool.get_now_date_str()}.log" @@ -488,7 +500,7 @@ if __name__ == '__main__': - fdatas = get_l2_cant_buy_reasons("002731") + fdatas = load_kpl_open_limit_up() print(len(fdatas)) # print(get_h_cancel_compute_info("603912")) diff --git a/third_data/data_server.py b/third_data/data_server.py index dec747d..42701ae 100644 --- a/third_data/data_server.py +++ b/third_data/data_server.py @@ -495,6 +495,26 @@ code_info[5] = 1 response_data = json.dumps({"code": 0, "data": codes_info}) + elif url.path == "/kpl/get_open_limit_up_count_rank": + # 鑾峰彇鐐告澘娆℃暟鎺掕 + ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) + code = ps_dict.get("code") + results = log_export.load_kpl_open_limit_up() + statistic = {} + for result in results: + for c in result[1]: + if code and code != c: + continue + if c not in statistic: + statistic[c] = 0 + statistic[c] += 1 + # 鍊掑簭鎺� + statistic_list = [(k, statistic[k]) for k in statistic] + statistic_list.sort(key=lambda x: x[1], reverse=True) + fresults = [] + for x in statistic_list: + fresults.append((x[0], gpcode_manager.get_code_name(x[0]), x[1])) + response_data = json.dumps({"code": 0, "data": fresults}) elif url.path == "/get_h_cancel_data": ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) code = ps_dict["code"] diff --git a/third_data/kpl_data_manager.py b/third_data/kpl_data_manager.py index 01d2c1f..b2ae85d 100644 --- a/third_data/kpl_data_manager.py +++ b/third_data/kpl_data_manager.py @@ -14,7 +14,8 @@ # 寮�鐩樺暒鍘嗗彶娑ㄥ仠鏁版嵁绠$悊 from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager -from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up +from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up, \ + logger_kpl_open_limit_up from third_data import kpl_util, kpl_api from third_data.code_plate_key_manager import LimitUpCodesPlateKeyManager, CodesHisReasonAndBlocksManager @@ -67,6 +68,20 @@ @classmethod def save_record(cls, day, records): + # 缁熻鐐告澘 + try: + last_codes = set() + if cls.latest_origin_datas: + last_codes = set([x[0] for x in cls.latest_origin_datas]) + now_codes = set() + if records: + now_codes = set([x[0] for x in records]) + open_limit_up_codes = last_codes - now_codes + if open_limit_up_codes: + logger_kpl_open_limit_up.info(f"鐐告澘浠g爜锛歿open_limit_up_codes}") + except Exception as e: + pass + # 缁熻浠g爜鎵�灞炴澘鍧� code_block_dict = {} for data in records: @@ -77,6 +92,7 @@ code_block_dict[code] = set() code_block_dict[code].add(b) # 璁剧疆娑ㄥ仠鏁版嵁 + if records: cls.latest_origin_datas = records cls.__LimitUpCodesPlateKeyManager.set_today_limit_up([(r[0], r[5]) for r in records]) -- Gitblit v1.8.0