Administrator
2024-04-25 331a177ada569d85107b6e294f904b37f386d33a
l2/l2_data_manager_new.py
@@ -640,6 +640,18 @@
        cls.__buy(code, 0, last_data, last_data_index, is_first_code)
    @classmethod
    def get_active_buy_blocks(cls, code):
        """
        获取激进买入的板块
        @param code:
        @return:
        """
        can_buy_result = CodePlateKeyBuyManager.can_buy(code)
        if can_buy_result:
            return can_buy_result[5]
        return None
    @classmethod
    def __buy(cls, code, capture_timestamp, last_data, last_data_index, is_first_code):
        # 添加买入锁
        if code not in cls.__buy_lock_dict:
@@ -699,6 +711,7 @@
                        info = cls.__trade_log_placr_order_info_dict[code]
                        info.mode = order_begin_pos.mode
                        info.mode_desc = order_begin_pos.mode_desc
                        info.set_buy_index(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
                        info.set_sell_info(order_begin_pos.sell_info)
                        if jx_blocks:
@@ -1343,6 +1356,7 @@
            fast_msg = None
            if has_single:
                order_begin_pos.mode = mode
                order_begin_pos.mode_desc = f"委托触发: {single_msg}"
                order_begin_pos.sell_info = sell_info
                fast_msg = sell_info
                # 用了信号就必须清除掉原有信号
@@ -1423,6 +1437,7 @@
                                                                max_num_set=max_num_set_new,
                                                                buy_volume_rate=cls.volume_rate_info[code][0],
                                                                mode=order_begin_pos.mode,
                                                                mode_desc=order_begin_pos.mode_desc,
                                                                sell_info=order_begin_pos.sell_info,
                                                                threshold_money=threshold_money))
            cls.__LimitUpTimeManager.save_limit_up_time(code, total_datas[new_buy_exec_index]["val"]["time"])
@@ -1445,6 +1460,7 @@
            cls.__save_order_begin_data(code, OrderBeginPosInfo(buy_single_index=buy_single_index, buy_exec_index=-1,
                                                                buy_compute_index=compute_end_index, num=buy_nums,
                                                                count=buy_count,
                                                                mode_desc=order_begin_pos.mode_desc,
                                                                max_num_set=max_num_set_new, mode=order_begin_pos.mode,
                                                                sell_info=order_begin_pos.sell_info,
                                                                threshold_money=threshold_money))
@@ -1639,6 +1655,7 @@
        # 获取最近的总卖信息
        # (time_str, round(money), volume, sell_1_info)
        refer_sell_data = cls.__L2MarketSellManager.get_refer_sell_data(code, start_time_str)
        active_buy_blocks = cls.get_active_buy_blocks(code)
        if code.find("60") == 0:
            if refer_sell_data is None:
                # 设置默认卖信息
@@ -1654,7 +1671,8 @@
                # 金额要大于50万
                if _val["num"] * float(_val["price"]) < 5000:
                    continue
                return True, i, [refer_sell_data[0], 0], '上证买入', OrderBeginPosInfo.MODE_FAST
                return True, i, [refer_sell_data[0], 0], '上证买入',  OrderBeginPosInfo.MODE_ACTIVE if active_buy_blocks else  OrderBeginPosInfo.MODE_FAST
            return False, -1, "未获取到激进买的起始信号", '', OrderBeginPosInfo.MODE_NORMAL
        else:
            # 深证
@@ -1696,20 +1714,20 @@
                                                                           valid_single=False)
                    if buy_single_index is not None:
                        return True, buy_single_index, [refer_sell_data[0],
                                                        threshold_money], "上板无涨停卖", OrderBeginPosInfo.MODE_NORMAL
                                                        threshold_money], "上板无涨停卖", OrderBeginPosInfo.MODE_ACTIVE if active_buy_blocks else OrderBeginPosInfo.MODE_NORMAL
                else:
                    # 按照成交买入信号计算
                    buy_single_index = cls.__get_active_single_start_index(code, start_index, end_index, continue_count,
                                                                           valid_single=True)
                    if buy_single_index is not None:
                        return True, buy_single_index, [refer_sell_data[0], 0], "上板有成交买入信号", OrderBeginPosInfo.MODE_FAST
                        return True, buy_single_index, [refer_sell_data[0], 0], "上板有成交买入信号", OrderBeginPosInfo.MODE_ACTIVE if active_buy_blocks else  OrderBeginPosInfo.MODE_FAST
            else:
                # 板上放量:只需要一笔涨停买可作为信号
                buy_single_index = cls.__get_active_single_start_index(code, start_index, end_index, continue_count,
                                                                       valid_single=False)
                if buy_single_index is not None:
                    return True, buy_single_index, [refer_sell_data[0], 0], "板上放量", OrderBeginPosInfo.MODE_NORMAL
                    return True, buy_single_index, [refer_sell_data[0], 0], "板上放量", OrderBeginPosInfo.MODE_ACTIVE if active_buy_blocks else OrderBeginPosInfo.MODE_NORMAL
        return False, -1, "未获取到激进买的起始信号", '', OrderBeginPosInfo.MODE_NORMAL
@@ -2101,6 +2119,7 @@
        # 不下单的信息
        not_buy_msg = ""
        max_buy_num_set = set(max_num_set)
        active_buy_blocks = cls.get_active_buy_blocks(code)
        for i in range(compute_start_index, compute_end_index + 1):
            data = total_datas[i]
            _val = total_datas[i]["val"]
@@ -2180,13 +2199,20 @@
                continue
            safe_count = 1
            if active_buy_blocks:
                # 有激进板块
                safe_count = 1
            else:
                # 无激进下单板块
            if total_sell_money <= 0:
                    # 所有的板上放量都需要3笔
                # 板上下单需要安全笔数3笔
                safe_count = 3
            elif code.find("00") == 0:
                # 深证非板上放量
                else:
                    if code.find("00") == 0:
                        # 深证上板
                safe_count = 2
            if code.find("60") == 0:
                    elif code.find("60") == 0:
                # 上证安全笔数为3
                safe_count = 3
            if buy_count < safe_count: