From 624ba42492b8525cef224db3488a4c5badcc8bb7 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 03 九月 2025 17:32:49 +0800 Subject: [PATCH] L撤比例修改 --- utils/buy_strategy_util.py | 66 +++++++++++++++++++-------------- 1 files changed, 38 insertions(+), 28 deletions(-) diff --git a/utils/buy_strategy_util.py b/utils/buy_strategy_util.py index 8ab6868..7d0960d 100644 --- a/utils/buy_strategy_util.py +++ b/utils/buy_strategy_util.py @@ -45,7 +45,7 @@ break continue # 涓庡綋鍓嶆椂闂寸浉宸�3s鐨勭粨鏉� - if tool.trade_time_sub_with_ms(end_time_with_ms, l2_data_util.L2DataUtil.get_time_with_ms(val)) > 6000: + if tool.trade_time_sub_with_ms(end_time_with_ms, l2_data_util.L2DataUtil.get_time_with_ms(val)) > 10000: break cancel_count += 1 @@ -147,8 +147,8 @@ # today = get_today_volumn(code) # max60, yesterday = get_histry_volumn(code) try: - today_volume = code_volumn_manager.get_today_volumn_cache(code) - histry_volumn = code_volumn_manager.get_histry_volumn(code) + today_volume = code_volumn_manager.CodeVolumeManager().get_today_volumn_cache(code) + histry_volumn = code_volumn_manager.CodeVolumeManager().get_histry_volumn(code) if not today_volume or not histry_volumn: return False, "灏氭湭鑾峰彇鍒伴噺" threshhold_volume = (histry_volumn[0][0] - today_volume) // 3 @@ -199,18 +199,33 @@ @param end_index: @return:(鏄惁鏄噺鍖�, 涓嬫鍙互涓嬪崟鏃堕棿) """ - THRESHOLD_BUY_COUNT = 20 - if end_index - start_index + 1 < THRESHOLD_BUY_COUNT: - # 鎬绘暟灏忎簬闃堝�� - return False, None + + # 闃堝�肩殑鍙栧�艰寖鍥� + THRESHOLD_MONEY_RANGE = 1e5, 3e5 + today_volume = code_volumn_manager.CodeVolumeManager().get_today_volumn_cache(code) + histry_volumn = code_volumn_manager.CodeVolumeManager().get_histry_volumn(code) + if not today_volume or not histry_volumn: + return False, "灏氭湭鑾峰彇鍒伴噺" + threshhold_volume = (histry_volumn[0][0] - today_volume) // 6 // 100 + limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) + threshhold_volumes_range = int(THRESHOLD_MONEY_RANGE[0] / limit_up_price), int( + THRESHOLD_MONEY_RANGE[1] / limit_up_price) + if threshhold_volume < threshhold_volumes_range[0]: + threshhold_volume = threshhold_volumes_range[0] + if threshhold_volume > threshhold_volumes_range[1]: + threshhold_volume = threshhold_volumes_range[1] total_datas = l2_data_util.local_today_datas.get(code) + + time_as_ms = tool.trade_time_sub_with_ms( + L2DataUtil.get_time_with_ms(total_datas[end_index]["val"]), + L2DataUtil.get_time_with_ms(total_datas[start_index]["val"])) + if time_as_ms > (10 if tool.is_sz_code(code) else 100): + return False, "闈為噺鍖�" + limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) - buy_count = 0 + total_buy_nums = 0 min_num = int(5000 / limit_up_price) - trade_index, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code) - if trade_index is None: - trade_index = 0 # 鑾峰彇鎴愪氦杩涘害浣� for i in range(start_index, end_index + 1): val = total_datas[i]["val"] @@ -218,25 +233,20 @@ continue if val["num"] < min_num: continue - buy_count += 1 - if buy_count > THRESHOLD_BUY_COUNT: + total_buy_nums += val["num"] + if total_buy_nums > threshhold_volume: break - if buy_count > THRESHOLD_BUY_COUNT: + if total_buy_nums > threshhold_volume: # 鍒ゆ柇鏄惁涓洪噺鍖� - time_as_ms = tool.trade_time_sub_with_ms( - L2DataUtil.get_time_with_ms(total_datas[end_index]["val"]), - L2DataUtil.get_time_with_ms(total_datas[start_index]["val"])) - if time_as_ms <= 10 if tool.is_sz_code(code) else 100: - # 娣辫瘉10ms鍐咃紝涓婅瘉100ms鍐呭氨鍒ゅ畾涓洪噺鍖� - HuaXinSellOrderStatisticManager.clear_latest_deal_volume(code) - next_buy_time = time.time() + buy_condition_util.get_cancel_and_buy_space_time( - code) / 1000 - # 濡傛灉鏄娆′笅鍗曪紝澧炲姞涓�娆′笅鍗曟鏁� - place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) - if place_order_count == 0: - trade_data_manager.PlaceOrderCountManager().place_order(code) - return True, next_buy_time, f"鎵ц浣嶆壒娆℃暟鎹噺({buy_count})澶т簬{THRESHOLD_BUY_COUNT} {start_index}-{end_index}" - return False, None + # 娣辫瘉10ms鍐咃紝涓婅瘉100ms鍐呭氨鍒ゅ畾涓洪噺鍖� + HuaXinSellOrderStatisticManager.clear_latest_deal_volume(code) + next_buy_time = time.time() + buy_condition_util.get_cancel_and_buy_space_time( + code) / 1000 + # 濡傛灉鏄娆′笅鍗曪紝澧炲姞涓�娆′笅鍗曟鏁� + place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) + if place_order_count == 0: + trade_data_manager.PlaceOrderCountManager().place_order(code) + return True, next_buy_time, f"鎵ц浣嶆壒娆℃暟鎹噺({total_buy_nums})澶т簬{threshhold_volume} {start_index}-{end_index}" else: return False, None -- Gitblit v1.8.0