Administrator
2024-12-26 e86f134bd0ea5c99fc25fba05c8528440448a0e3
RD撤重新囊括
1个文件已修改
39 ■■■■■ 已修改文件
l2/cancel_buy_strategy.py 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -41,6 +41,7 @@
    FCancelBigNumComputer().set_real_order_index(code, index, is_default)
    JCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default)
    NBCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default)
    RDCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default)
class BaseCancel:
@@ -251,6 +252,36 @@
        RedisUtils.setex_async(self.__db, f"radical_big_order_watch-{code}", tool.get_expire(),
                               json.dumps(list(indexes)))
    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:
            # 囊括的单大于1个
            return
        # 从买入信号位开始囊括
        limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
        min_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code))
        min_num = int(round(min_money / limit_up_price / 100))
        total_datas = local_today_datas.get(code)
        watch_indexes = set()
        for i in range(buy_single_index, index):
            data = total_datas[i]
            val = data["val"]
            if not L2DataUtil.is_limit_up_price_buy(val):
                continue
            if val["num"] < min_num:
                continue
            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                     i,
                                                                                                     total_datas,
                                                                                                     local_today_canceled_buyno_map.get(
                                                                                                         code))
            if left_count > 0:
                watch_indexes.add(i)
        if watch_indexes:
            l2_log.d_cancel_debug(code, f"更新扫入大单监听:{watch_indexes}")
            self.__watch_indexes_cache[code] = watch_indexes
    def need_cancel(self, code, start_index, end_index):
        """
        是否需要撤单
@@ -279,7 +310,7 @@
            if buy_index in watch_indexes:
                need_compute = True
                break
        cancel_indexes = set()
        if need_compute:
            cancel_count = 0
            cancel_data = None
@@ -290,8 +321,10 @@
                                                                                                          code))
                if cancel_data:
                    cancel_count += 1
            if cancel_count >= len(watch_indexes):
                return True, cancel_data, f"大单撤单({watch_indexes})"
                    cancel_indexes.add(index)
            rate = round(cancel_count / len(watch_indexes), 2)
            if rate >= 0.8:
                return True, cancel_data, f"撤单比例-{rate},大单撤单({cancel_indexes})"
        return False, None, "无大单撤单"
    def __clear_data(self, code):