From 556942d1132123ef608c174d9bca91aa818f6ccb Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 19 八月 2025 16:57:32 +0800 Subject: [PATCH] bug修复/接口修改/续买bug修改 --- cancel_strategy/s_l_h_cancel_strategy.py | 61 ++++++++++++++++++++++++------ 1 files changed, 49 insertions(+), 12 deletions(-) diff --git a/cancel_strategy/s_l_h_cancel_strategy.py b/cancel_strategy/s_l_h_cancel_strategy.py index 16ce320..cf06136 100644 --- a/cancel_strategy/s_l_h_cancel_strategy.py +++ b/cancel_strategy/s_l_h_cancel_strategy.py @@ -615,7 +615,7 @@ deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, gpcode_manager.get_limit_up_price_as_num( code)) - if deal_big_order_info and deal_big_order_info[5]>5000e4: + if deal_big_order_info and deal_big_order_info[5] > 5000e4: temp_rate = round(deal_big_order_info[1] / deal_big_order_info[5], 2) threshold_rate = min(max(temp_rate, 0.3), 0.9) except: @@ -711,10 +711,32 @@ def __init__(self): # L鍚庢挙鍗� self.l_down = {} + self.__db = 3 + self.__redis_manager = redis_manager.RedisManager(self.__db) + self.__load_data() + + def __load_data(self): + keys = RedisUtils.keys(self.__get_redis(), "l_down_cancel_rate_human-{}") + if keys: + for k in keys: + code = k.split("-")[1] + val = RedisUtils.get(self.__get_redis(), k) + if val: + self.l_down[code] = round(float(val), 2) + + def __get_redis(self): + return self.__redis_manager.getRedis() def set_l_down(self, code, rate): + """ + 璁剧疆L鍚庢挙姣斾緥 + @param code: + @param rate: + @return: + """ async_log_util.info(logger_l2_l_cancel, f"浜轰负淇敼L鍚庢挙鍗曟瘮渚�:{code}-{rate}") self.l_down[code] = rate + RedisUtils.setex_async(self.__db, f"l_down_cancel_rate_human-{code}", tool.get_expire(), rate) def get_l_down(self, code): return self.l_down.get(code) @@ -722,6 +744,7 @@ def remove_l_down(self, code): if code in self.l_down: self.l_down.pop(code) + RedisUtils.delete_async(self.__db, f"l_down_cancel_rate_human-{code}") @tool.singleton @@ -1085,6 +1108,10 @@ logger_l2_l_cancel.exception(e) if len(watch_indexes) >= MAX_COUNT: break + if not watch_indexes: + l2_log.l_cancel_debug(code, f"璁$畻L鍚庡泭鎷寖鍥存病鎵惧埌鍙泭鎷储寮曪紝{start_index}, {re_start_index}, {end_index}") + return + if watch_indexes: ##鍒ゆ柇鐩戝惉鐨勬暟鎹腑鏄惁鏈夊ぇ鍗�## # 涔嬪墠鐨勫ぇ鍗曚负100w锛岀幇鍦ㄦ敼涓烘甯稿ぇ鍗� @@ -1775,7 +1802,8 @@ real_place_order_info = self.__real_place_order_index_dict.get(code) is_default_place_order_index = real_place_order_info[1] if real_place_order_info else False - if is_default_place_order_index: + if is_default_place_order_index and not cancel_rate_info[2][1]: + # 浜轰负璁剧疆鐨勪笉鑳藉彇鏈�灏� thresh_hold_rate = min(0.49, thresh_hold_rate) l2_log.l_cancel_debug(code, f"L鍚庤绠楄寖鍥达細{start_index}-{end_index},宸叉挙鍗曟瘮渚嬶細{rate}/{thresh_hold_rate}, 涓嬪崟浣嶄箣鍚庣殑绱㈠紩锛歿after_place_order_index_dict}, 鏈�澶у崟-({max_num}锛寋max_num_count}), 浜轰负璁剧疆-{cancel_rate_info}, 鐪熷疄涓嬪崟浣�-{real_place_order_info}") @@ -2064,7 +2092,7 @@ """ 缁熻L鍚庣殑澶у崟淇℃伅 @param code: - @return: 鍥婃嫭閲戦鍒楄〃, 鎴愪氦閲戦鍒楄〃, 鎾ゅ崟閲戦鍒楄〃, 寰呮垚浜ゅ垪琛� + @return: [(绱㈠紩,閲戦,鎵嬫暟,鐘舵��)] """ watch_indexes_info = self.__get_watch_indexes_cache(code) if not watch_indexes_info: @@ -2100,15 +2128,20 @@ deal_indexes.add(index) continue not_deal_indexes.add(index) - all_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in - all_indexes] - deal_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in - deal_indexes] - canceled_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in - canceled_indexes] - not_deal_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in - not_deal_indexes] - return all_money_list, deal_money_list, canceled_money_list, not_deal_money_list + fdatas = [] + for x in all_indexes: + item = [x, int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)), total_datas[x]['val']['num']] + if x in deal_indexes: + item.append(trade_constant.TRADE_STATE_BUY_SUCCESS) + elif x in canceled_indexes: + item.append(trade_constant.TRADE_STATE_BUY_CANCEL_SUCCESS) + elif x in not_deal_indexes: + item.append(trade_constant.TRADE_STATE_BUY_DELEGATED) + else: + item.append(trade_constant.TRADE_STATE_NOT_TRADE) + fdatas.append(item) + fdatas.sort(key=lambda x: x[0]) + return fdatas # def statistic_total_big_order_info(self, code): # """ @@ -2862,3 +2895,7 @@ """ self.__l_cancel_triggered_codes.add(code) self.__compute_watch_index(code, buy_single_index) + + +if __name__ == "__main__": + CancelRateHumanSettingManager() -- Gitblit v1.8.0