Administrator
5 天以前 48fb7a00951f91bdc707e5dd2d196e5bccb752c3
l2/cancel_buy_strategy.py
@@ -151,6 +151,31 @@
                    max_info = (i, val["num"])
        return total_datas[max_info[0]]
    @classmethod
    def is_canceled(cls, code, index, total_datas, canceled_buyno_map, trade_index, deal_order_nos):
        """
        是否已经撤单
        @param deal_order_nos: 成交大单集合
        @param trade_index: 成交进度位
        @param index: 索引
        @param code: 代码
        @param total_datas:
        @param canceled_buyno_map:撤单的订单号
        @return:
        """
        cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, index,
                                                                                              total_datas,
                                                                                              canceled_buyno_map)
        if cancel_data:
            # 已经撤单
            return True
        else:
            if trade_index and trade_index > index:
                # 成交进度大于索引位置,且还没成交
                if total_datas[index]["val"]["orderNo"] not in deal_order_nos:
                    return True
            return False
# ---------------------------------D撤-------------------------------
# 计算 成交位->真实下单位置 总共还剩下多少手没有撤单
@@ -255,7 +280,7 @@
    def set_real_place_order_index(self, code, index, buy_single_index, is_default):
        if is_default:
            return
        if  code  in self.__watch_indexes_cache and len(self.__watch_indexes_cache[code]) > 1:
        if code in self.__watch_indexes_cache and len(self.__watch_indexes_cache[code]) > 1:
            # 囊括的单大于1个
            return
        # 从买入信号位开始囊括
@@ -290,6 +315,7 @@
        @param end_index:
        @return: 是否需要撤单,撤单索引, 消息
        """
        buyno_map = local_today_buyno_map.get(code)
        watch_indexes = self.__watch_indexes_cache.get(code)
        if not watch_indexes:
            return False, None, "无大单监听"
@@ -302,24 +328,28 @@
                continue
            if val["num"] * float(val["price"]) < 5000:
                continue
            buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(data,
                                                                                                local_today_buyno_map.get(
                                                                                                    code))
            buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(data, buyno_map)
            if buy_index is None:
                continue
            if buy_index in watch_indexes:
                need_compute = True
                break
        cancel_indexes = set()
        if need_compute:
        canceled_buyno_map = local_today_canceled_buyno_map.get(code)
        if need_compute or True:
            cancel_count = 0
            cancel_data = None
            # 成交买单号
            deal_order_nos = HuaXinBuyOrderManager().get_deal_buy_order_nos(code)
            if deal_order_nos is None:
                deal_order_nos = set()
            trade_index, is_default = TradeBuyQueue().get_traded_index(code)
            if is_default:
                trade_index = None
            for index in watch_indexes:
                cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, index,
                                                                                                      total_datas,
                                                                                                      local_today_canceled_buyno_map.get(
                                                                                                          code))
                if cancel_data:
                if L2DataComputeUtil.is_canceled(code, index, total_datas, canceled_buyno_map, trade_index,
                                                 deal_order_nos):
                    # 买单已撤单
                    cancel_count += 1
                    cancel_indexes.add(index)
            rate = round(cancel_count / len(watch_indexes), 2)
@@ -520,9 +550,10 @@
                if dealing_info and str(dealing_info[0]) == str(val["orderNo"]):
                    total_left_num -= dealing_info[1] // 100
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        total_left_money = total_left_num * float(limit_up_price)*100
        total_left_money = total_left_num * float(limit_up_price) * 100
        if total_left_money < 1e8:
            if total_left_count <= 1 or (total_left_count <= THRESHOLD_COUNT and limit_up_price and total_left_num * float(
            if total_left_count <= 1 or (
                    total_left_count <= THRESHOLD_COUNT and limit_up_price and total_left_num * float(
                    limit_up_price) < THRESHOLD_MONEY_W * 100):
                return True, f"剩余笔数({total_left_count})/金额({round(total_left_num * float(limit_up_price) * 100)})不足,成交进度:{trade_index},真实下单位置:{real_order_index} 阈值:({THRESHOLD_MONEY_W},{THRESHOLD_COUNT}) "
        return False, f"不满足撤单条件: 成交进度-{trade_index} 真实下单位置-{real_order_index} total_left_count-{total_left_count} total_left_num-{total_left_num}"
@@ -587,13 +618,13 @@
        # 计算我们后面的大单与涨停纯买额
        total_left_num = 0
        total_big_num_count = 0
        canceled_buyno_map =  local_today_canceled_buyno_map.get(code)
        canceled_buyno_map = local_today_canceled_buyno_map.get(code)
        for i in range(real_order_index + 1, len(total_datas)):
            data = total_datas[i]
            val = data["val"]
            if not L2DataUtil.is_limit_up_price_buy(val):
                continue
            money = val["num"] * float(val["price"])*100
            money = val["num"] * float(val["price"]) * 100
            if money < 500000:
                continue
            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,