Administrator
2024-08-30 302500d0ddcaf02b6dc3e182ad77d78178deaa44
l2/l2_data_manager_new.py
@@ -263,6 +263,9 @@
    # 中断本批次买入数据处理
    __break_current_batch_data_for_buy_dict = {}
    # 最近的执行位置
    __latest_exec_indexes = {}
    # 获取代码评分
    @classmethod
    def get_code_scores(cls):
@@ -947,13 +950,28 @@
            # 1.当前成交价为涨停价
            # 2.距离最近的非板上成交的时间大于一个阈值
            if abs(limit_up_price - float(trade_price)) < 0.001:
                latest_exec_indexes = cls.__latest_exec_indexes[code]
                # 判断是否是炸开后买入
                last_exec_index = 0
                if len(latest_exec_indexes) > 1:
                    last_exec_index = latest_exec_indexes[-2]
                # 获取最近的非涨停价成交时间
                not_limit_up_trade_time_with_ms = current_price_process_manager.get_trade_not_limit_up_time_with_ms(
                    code)
                threshold_time_space = buy_condition_util.get_cancel_and_buy_space_time(code)
                if not not_limit_up_trade_time_with_ms or tool.trade_time_sub_with_ms(
                        L2DataUtil.get_time_with_ms(total_data[-1]['val']),
                        not_limit_up_trade_time_with_ms) >= threshold_time_space:
                is_limit_up_buy = True
                if not_limit_up_trade_time_with_ms:
                    t1 = int(
                        L2DataUtil.get_time_with_ms(total_data[last_exec_index]["val"]).replace(":", "").replace(".",
                                                                                                                 ""))
                    t2 = int(not_limit_up_trade_time_with_ms.replace(":", "").replace(".", ""))
                    t3 = int(L2DataUtil.get_time_with_ms(total_data[order_begin_pos.buy_exec_index]["val"]).replace(":",
                                                                                                                    "").replace(
                        ".", ""))
                    if t1 < t2 <= t3:
                        # 炸板时间在两次下单时间中间
                        is_limit_up_buy = False
                if is_limit_up_buy:
                    # 判断成交进度到当前数据的笔数,如果少于10笔且还有未成交的大单(>=299)就可以下单
                    trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code)
                    if trade_index is None:
@@ -1390,8 +1408,10 @@
            if not has_single:
                # 没有信号,如果当前数据是涨停买就记录日志,防止记录过多的日志
                if L2DataUtil.is_limit_up_price_buy(
                        total_datas[compute_start_index]["val"]) and L2DataUtil.is_limit_up_price_buy(total_datas[compute_end_index]["val"]):
                    async_log_util.info(logger_l2_trade_buy_queue, "尚未获取到买入信号: code-{} start_index-{}  end_index-{} msg-{}", code,
                        total_datas[compute_start_index]["val"]) and L2DataUtil.is_limit_up_price_buy(
                    total_datas[compute_end_index]["val"]):
                    async_log_util.info(logger_l2_trade_buy_queue,
                                        "尚未获取到买入信号: code-{} start_index-{}  end_index-{} msg-{}", code,
                                        compute_start_index, compute_end_index, sell_info)
            fast_msg = None
            if has_single:
@@ -1484,6 +1504,13 @@
                                                                threshold_money=threshold_money))
            cls.__LimitUpTimeManager.save_limit_up_time(code, total_datas[new_buy_exec_index]["val"]["time"])
            l2_log.debug(code, "delete_buy_cancel_point")
            if code not in cls.__latest_exec_indexes:
                cls.__latest_exec_indexes[code] = []
            cls.__latest_exec_indexes[code].append(new_buy_exec_index)
            # 保留最近3次的买入执行位置
            if len(cls.__latest_exec_indexes[code]) > 3:
                cls.__latest_exec_indexes[code] = cls.__latest_exec_indexes[code][-3:]
            # 直接下单
            ordered = cls.__buy(code, capture_time, total_datas[-1], total_datas[-1]["index"], is_first_code)