From 4f16bf0f1686e2a15fcbc43e17c727c81550609f Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 17 七月 2025 14:19:18 +0800 Subject: [PATCH] 人为设置的累计大单的策略修改 --- trade/buy_radical/radical_buy_data_manager.py | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/trade/buy_radical/radical_buy_data_manager.py b/trade/buy_radical/radical_buy_data_manager.py index 26df339..4e7f691 100644 --- a/trade/buy_radical/radical_buy_data_manager.py +++ b/trade/buy_radical/radical_buy_data_manager.py @@ -73,9 +73,10 @@ def __get_redis(self): return self.__redis_manager.getRedis() - def set_big_order_threshold(self, code, threshold_money): + def set_big_order_threshold(self, code, threshold_money, big_order_threshold_callback): """ 璁剧疆澶у崟鐨勯槇鍊� + @param big_order_threshold_callback: 澶у崟璁剧疆鍥炶皟鍑芥暟 @param code: @param threshold_money: @return: @@ -89,6 +90,7 @@ self.__big_order_threshold[code] = threshold_money redis_manager.RedisUtils.setex_async(self.__db, f"radical_big_order_threshold-{code}", tool.get_expire(), f"{threshold_money}") + big_order_threshold_callback(code, threshold_money) def set_big_sell_order_threshold(self, code, threshold_money): """ @@ -120,9 +122,11 @@ threshold_money = max((max_money // 2 + average_money) // 2, average_money) return threshold_money - def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price): + def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price, + big_order_threshold_callback): """ 璁剧疆澶у崟鎴愪氦鏁版嵁 + @param big_order_threshold_callback: 鍧囧ぇ鍗曡缃洖璋冨嚱鏁� @param code: @param buy_money_list:[(閲戦,浠锋牸,璁㈠崟鍙�)] @param sell_money_list:[(閲戦,浠锋牸,璁㈠崟鍙�)] @@ -160,7 +164,7 @@ total_deal_buy_money_info_list.append(info) if limit_up_price_money_list: threshold_money = self.compute_re_limit_up_big_money_threshold(limit_up_price_money_list) - self.set_big_order_threshold(code, threshold_money) + self.set_big_order_threshold(code, threshold_money, big_order_threshold_callback) self.__already_total_deal_big_order_money[code] = (total_deal_buy_money, pre_limit_up_price_money_list) async_log_util.info(logger_l2_radical_buy_data, f"寮�鏉挎椂闂达細{opened_time} 涔嬪墠鐨勫ぇ涔板崟锛歿code}-{total_deal_buy_money}-{total_deal_buy_money_info_list}") @@ -2214,16 +2218,40 @@ @param code_: @return: """ + + def big_order_threshold_callback(code, money): + """ + 璁剧疆鍧囧ぇ鍗曠殑鍥炶皟 + @param money: + @return: + """ + async_log_util.info(logger_l2_radical_buy_data, f"鍧囧ぇ鍗曞洖璋冨嚱鏁帮細{code}-{money}锛屽師鍧囧ぇ鍗�-{THRESHOLD_MONEY}") + if money - THRESHOLD_MONEY > 10: + # 鏂扮殑闃堝ぇ浜庤�佺殑闃堝�� + old_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code) + if old_setting_money: + new_setting_money = int(old_setting_money * money / THRESHOLD_MONEY) + async_log_util.info(logger_l2_radical_buy_data, + f"绱澶у崟鍥炶皟浜轰负璁剧疆({code}): {old_setting_money}->{new_setting_money}") + TotalDealBigOrderThresholdMoneyManager().set_money(code, new_setting_money, + trade_manager.CodesTradeStateManager().get_trade_state_cache( + code)) + # 鍙湁娑ㄥ仠杩囩殑浠g爜鎵嶉渶瑕佹媺澶у崟 if code_ not in LimitUpDataConstant.get_history_limit_up_codes(): return result = request_deal_big_orders(code_) + THRESHOLD_MONEY = 0 if result: try: buy_datas, sell_datas = result[0], result[1] + # 鑾峰彇鍘熷鍧囧ぇ鍗� + THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info( + code_) BeforeSubDealBigOrderManager().set_big_deal_order_list(code_, buy_datas, sell_datas, - gpcode_manager.get_limit_up_price_as_num(code_)) + gpcode_manager.get_limit_up_price_as_num(code_), + big_order_threshold_callback) except Exception as e: logger_debug.exception(e) -- Gitblit v1.8.0