Administrator
2025-08-19 89e49e197ec232fc6ae99c22b8ffb2be64108ee4
servers/huaxin_trade_server.py
@@ -673,101 +673,17 @@
        @param data:
        @return:
        """
        l2_log.debug(code, "最近涨停卖被吃掉{}, {}", code, f"{data}")
        # 暂时不处理
        if True:
            return
        # 只处理深证的票
        try:
            # 判断是否下单
            state = CodesTradeStateManager().get_trade_state_cache(code)
            if state == trade_constant.TRADE_STATE_BUY_DELEGATED or state == trade_constant.TRADE_STATE_BUY_PLACE_ORDER or state == trade_constant.TRADE_STATE_BUY_SUCCESS:
                # 已经下单了
                return
            l2_log.debug(code, "成交触发买入计算 触发模式:{} 大单数量:{}", _type, big_buy_order_count)
            total_datas = l2_data_util.local_today_datas.get(code)
            mode_descs = []
            # if big_buy_order_count > 0:
            #     mode_descs.append("300w")
            if l2_data_manager_new.L2TradeDataProcessor.get_active_buy_blocks(code):
                mode_descs.append("身位")
            current_total_sell_data = L2MarketSellManager().get_current_total_sell_data(code)
            sell_info = None
            if current_total_sell_data:
                sell_info = (current_total_sell_data[0], current_total_sell_data[1])
            if _type == L2TradeSingleDataManager.TYPE_PASSIVE and mode_descs:
                # 可以激进下单且必须是首次下单才能激进
                place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code)
                if tool.is_sz_code(code) and place_order_count == 0 and current_total_sell_data[
                    1] > 500 * 10000 and global_util.zyltgb_map.get(
                    code) < 50 * 100000000:
                    # 首次下单,自由流通50亿以下,总卖额500w才能激进下单
                    mode_descs.insert(0, "成交触发")
                    last_index = total_datas[-1]["index"]
                    volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate(code)
                    order_begin_pos = OrderBeginPosInfo(buy_single_index=last_index,
                                                        buy_exec_index=last_index,
                                                        buy_compute_index=last_index,
                                                        num=0, count=1,
                                                        max_num_set=set(),
                                                        buy_volume_rate=volume_rate,
                                                        mode=OrderBeginPosInfo.MODE_ACTIVE,
                                                        mode_desc=",".join(mode_descs),
                                                        sell_info=sell_info,
                                                        threshold_money=0)
                    l2_data_manager_new.L2TradeDataProcessor.save_order_begin_data(code, order_begin_pos)
                    l2_log.debug(code, "积极下单,获取到买入执行位置:{} 成交数据触发模式:{} 大单数量:{}",
                                 order_begin_pos.buy_exec_index,
                                 _type, big_buy_order_count)
                    l2_data_manager_new.L2TradeDataProcessor.start_buy(code, total_datas[-1], total_datas[-1]["index"],
                                                                       True, None)
                else:
                    l2_log.debug(code, "积极下单,不满足扫入下单条件,无法扫入")
            else:
                if not tool.is_sz_code(code):
                    return
                # 找到最近的大买单
                for i in range(len(total_datas) - 1, -1, -1):
                    d = total_datas[i]
                    val = d['val']
                    if not L2DataUtil.is_limit_up_price_buy(val):
                        continue
                    if val['num'] * float(val['price']) < 5000:
                        continue
                    if val['orderNo'] < data[0][6]:
                        continue
                    result = L2TradeSingleDataManager.is_can_place_order(code, d)
                    if result and result[0]:
                        volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate(code)
                        order_begin_pos = OrderBeginPosInfo(buy_single_index=i,
                                                            buy_exec_index=i,
                                                            buy_compute_index=i,
                                                            num=0, count=1,
                                                            max_num_set=set(),
                                                            buy_volume_rate=volume_rate,
                                                            mode=OrderBeginPosInfo.MODE_FAST,
                                                            mode_desc="成交触发",
                                                            sell_info=sell_info,
                                                            threshold_money=0)
                        l2_data_manager_new.L2TradeDataProcessor.save_order_begin_data(code, order_begin_pos)
                        l2_log.debug(code, "非激进下单,获取到买入执行位置:{} 成交数据触发模式:{}",
                                     order_begin_pos.buy_exec_index,
                                     _type)
                        l2_data_manager_new.L2TradeDataProcessor.start_buy(code, total_datas[-1],
                                                                           total_datas[-1]["index"],
                                                                           True, None)
                        break
        except Exception as e:
            logger_debug.exception(e)
        self.process_limit_up_active_buy(code, [data[0]], is_last_sell_deal=True)
    def process_limit_up_active_buy(self, code, transaction_datas, is_almost_open_limit_up=False,
                                    l2_market_time_str='', no_left_limit_up_sell=False):
                                    l2_market_time_str='', no_left_limit_up_sell=False, is_last_sell_deal=False):
        """
        处理涨停主动买
        @param is_last_sell_deal: 是否最近一笔涨停卖被吃
        @param no_left_limit_up_sell: 是否还有剩余涨停卖尚未成交
        @param code:
        @param transaction_datas:
@@ -821,9 +737,12 @@
                        return True
                    # -----根据成交比例判断是否可买------
                    if not is_last_sell_deal:
                    result_by_volume = radical_buy_strategy.process_limit_up_active_buy_deal(code, transaction_datas,
                                                                                             is_almost_open_limit_up,
                                                                                             no_left_limit_up_sell=no_left_limit_up_sell)
                    else:
                        result_by_volume = radical_buy_strategy.BUY_MODE_BY_L2, f"最后一笔涨停卖成交"
                    l2_log.info(code, logger_l2_radical_buy, f"量买入结果判断:{code}, 结果:{result_by_volume} 板块:{buy_blocks}")
                    in_blocks = RealTimeKplMarketData.get_top_market_jingxuan_blocks()
                    buy_blocks_with_money = [(b, RealTimeKplMarketData.get_jx_block_in_money(b),