Administrator
2024-02-02 df4cee929486a993868a15c13cd67e56b861907b
修改G撤无大单情况/仓位不足主动撤单比例修改
3个文件已修改
37 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -1810,7 +1810,7 @@
                        # 在成交位置之后
                        need_find_by = False
                        break
            if need_find_by and not is_default:
            if need_find_by and (not is_default or not watch_indexes):
                l2_log.g_cancel_debug(code, f"启动小单备用监听:{start_index}-{real_order_index}")
                temp_list = []
                for i in range(start_index, real_order_index):
l2/l2_data_manager_new.py
@@ -1356,14 +1356,14 @@
        if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
            threshold_money = order_begin_pos.threshold_money
            new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, not_buy_msg = cls.__sum_buy_num_for_order_fast(
            new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, max_num_set_new, not_buy_msg = cls.__sum_buy_num_for_order_fast(
                code,
                start_process_index,
                compute_end_index,
                order_begin_pos.num,
                order_begin_pos.count,
                threshold_money,
                order_begin_pos.buy_single_index)
                order_begin_pos.buy_single_index, order_begin_pos.max_num_set)
            threshold_money = threshold_money_new
            order_begin_pos.threshold_money = threshold_money
        else:
@@ -1513,8 +1513,8 @@
            return False, -1, "总卖为空"
        if cls.__L2MarketSellManager.is_refer_sell_time_used(code, refer_sell_data[0]):
            return False, -1, "总卖统计时间已被使用"
        # 是否大于500万
        if refer_sell_data[1] <= 500 * 10000:
        # 是否大于2000万
        if refer_sell_data[1] <= 2000 * 10000:
            return False, -1, "总卖小于指定金额"
        # 统计之前的卖
        threshold_money = refer_sell_data[1]
@@ -1733,7 +1733,7 @@
    # 计算快速买入
    @classmethod
    def __sum_buy_num_for_order_fast(cls, code, compute_start_index, compute_end_index, origin_num, origin_count,
                                     threshold_money_origin, buy_single_index):
                                     threshold_money_origin, buy_single_index, max_num_set):
        _start_time = t.time()
        total_datas = local_today_datas[code]
        # is_first_code = gpcode_manager.FirstCodeManager().is_in_first_record_cache(code)
@@ -1757,6 +1757,10 @@
        max_space_time_ms = 3 * 1000
        # 不下单的信息
        not_buy_msg = ""
        max_buy_num_set = set(max_num_set)
        place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code)
        if place_order_count is None:
            place_order_count = 0
        for i in range(compute_start_index, compute_end_index + 1):
            data = total_datas[i]
            _val = total_datas[i]["val"]
@@ -1766,12 +1770,12 @@
                cls.__TradePointManager.delete_buy_point(code)
                if i == compute_end_index:
                    # 数据处理完毕
                    return None, buy_nums, buy_count, None, threshold_money, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms"
                    return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms"
                else:
                    # 计算买入信号,不能同一时间开始计算
                    for ii in range(buy_single_index + 1, compute_end_index + 1):
                        if total_datas[buy_single_index]["val"]["time"] != total_datas[ii]["val"]["time"]:
                            return None, buy_nums, buy_count, ii, threshold_money, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms"
                            return None, buy_nums, buy_count, ii, threshold_money, max_buy_num_set, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms"
            if L2DataUtil.is_sell(_val):
                threshold_money += _val["num"] * int(float(_val["price"]) * 100)
                threshold_num = round(threshold_money / (limit_up_price * 100))
@@ -1780,6 +1784,8 @@
                threshold_num = round(threshold_money / (limit_up_price * 100))
            # 涨停买
            elif L2DataUtil.is_limit_up_price_buy(_val):
                if l2_data_util.is_big_money(_val):
                    max_buy_num_set.add(i)
                trigger_buy = True
                # 只统计59万以上的金额
                buy_nums += int(_val["num"]) * int(total_datas[i]["re"])
@@ -1793,8 +1799,10 @@
                                                                                                    local_today_buyno_map.get(
                                                                                                        code))
                if buy_index is not None:
                    # 找到买撤数据的买入点
                    if buy_index >= buy_single_index:
                        max_buy_num_set.discard(buy_index)
                        buy_nums -= int(_val["num"]) * int(data["re"])
                        buy_count -= int(data["re"])
                        l2_log.buy_debug(code, "{}数据在买入信号之后 撤买纯买手数:{} 目标手数:{}", i, buy_nums, threshold_num)
@@ -1804,6 +1812,7 @@
                            # 同一秒,当作买入信号之后处理
                            buy_nums -= int(_val["num"]) * int(data["re"])
                            buy_count -= int(data["re"])
                            max_buy_num_set.discard(buy_index)
                            # 大单撤销
                            l2_log.buy_debug(code, "{}数据买入位与预估买入位在同一秒", i)
                else:
@@ -1823,20 +1832,26 @@
            if buy_count < 5:
                not_buy_msg = f"【{i}】安全笔数不足,{buy_count}/{5}"
                continue
            if place_order_count == 0:
                if len(max_buy_num_set) < 1:
                    not_buy_msg = f"【{i}】首次下单无大单"
                    continue
            try:
                info = cls.__trade_log_placr_order_info_dict[code]
                info.set_trade_factor(threshold_money, 0, [])
            except Exception as e:
                async_log_util.error(logger_l2_error, f"记录交易因子出错:{str(e)}")
            return i, buy_nums, buy_count, None, threshold_money, "可以下单"
            return i, buy_nums, buy_count, None, threshold_money, max_buy_num_set, "可以下单"
        l2_log.buy_debug(code, "尚未获取到买入执行点(快速买入),起始计算位置:{} 统计纯买手数:{} 目标纯买手数:{}  统计纯买单数:{}",
                         compute_start_index,
                         buy_nums,
                         threshold_num, buy_count)
        return None, buy_nums, buy_count, None, threshold_money, not_buy_msg
        return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, not_buy_msg
def test_trade_record():
trade/huaxin/huaxin_trade_server.py
@@ -572,7 +572,7 @@
                if buy1_money > 0:
                    total_left_money = total_left_num * 100 * float(limit_up_price)
                    rate = total_left_money / buy1_money
                    if rate > 0.66:
                    if rate > 0.5:
                        can_cancel_codes.append((code, rate))
            if can_cancel_codes:
                can_cancel_codes.sort(key=lambda x: x[1], reverse=True)