Administrator
15 小时以前 cb4589db74aac2822f2aeb97eb3c28d2b7d59338
l2/l2_sell_manager.py
@@ -64,17 +64,18 @@
            RedisUtils.delete_async(self.__db, k)
    # 设置当前的总卖
    def set_current_total_sell_data(self, code, time_str, money, volume, sell_1_info):
    def set_current_total_sell_data(self, code, time_str, money, volume, sell_1_info, sell_n_info):
        """
        @param code:
        @param time_str:
        @param money:
        @param volume:
        @param sell_1_info: 格式(卖1价格,卖1量)
        @param sell_n_info:卖挡位
        @return:
        """
        # 记录日志
        async_log_util.info(logger_l2_market_sell, f"{code}: {time_str}-{money} {sell_1_info}")
        async_log_util.info(logger_l2_market_sell, f"{code}: {time_str}-{money} {sell_1_info} {sell_n_info}")
        if code not in self.__total_sell_data_cache_list_cache:
            self.__total_sell_data_cache_list_cache[code] = []
@@ -82,7 +83,7 @@
            0] == time_str:
            return
        self.__total_sell_data_cache_list_cache[code].append((time_str, round(money), volume, sell_1_info))
        self.__total_sell_data_cache_list_cache[code].append((time_str, round(money), volume, sell_1_info, sell_n_info))
        # 保留最多10条数据
        if len(self.__total_sell_data_cache_list_cache[code]) > 10:
            self.__total_sell_data_cache_list_cache[code] = self.__total_sell_data_cache_list_cache[code][-10:]
@@ -90,7 +91,7 @@
    def get_current_total_sell_data(self, code):
        """
        @param code:
        @return:(时间, 总买额, 总量, 卖1信息)
        @return:(时间, 总买额, 总量, 卖1信息, 卖挡位信息)
        """
        total_sell_data_cache_list = self.__total_sell_data_cache_list_cache.get(code)
        if not total_sell_data_cache_list:
@@ -103,7 +104,7 @@
        获取可引用的总卖额
        @param code:
        @param time_str: 当前数据截止时间
        @return: (time_str, round(money), volume, sell_1_info)
        @return: (time_str, round(money), volume, sell_1_info, sell_n_infos)
        """
        total_sell_data_cache_list = self.__total_sell_data_cache_list_cache.get(code)
        if total_sell_data_cache_list:
@@ -114,6 +115,27 @@
                    return sell_data
        return None
    def get_latest_refer_sell_data_with_not_zero(self, code):
        """
        获取最近的非0的总卖数据
        @param code:
        @return:
        """
        total_sell_data_cache_list = self.__total_sell_data_cache_list_cache.get(code)
        if total_sell_data_cache_list:
            count = 0
            for i in range(len(total_sell_data_cache_list) - 1, -1, -1):
                count += 1
                if count > 20:
                    # 最多往前找20个tick
                    break
                sell_data = total_sell_data_cache_list[i]
                if sell_data[1] > 1:
                    # 获取非0总卖额
                    return sell_data
        return None
# 板上卖统计
class L2LimitUpSellManager: