Administrator
2023-08-02 079946d7bedd10151b6b6ea7ba25fd8ad1019777
redis缓存加入内存缓存
7个文件已修改
214 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 150 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager.py 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
output/code_info_output.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_server.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_result_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/tool.py 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -22,11 +22,13 @@
from l2.l2_data_util import L2DataUtil, local_today_num_operate_map, local_today_datas
from log_module.log import logger_buy_1_volumn, logger_l2_h_cancel, logger_l2_s_cancel, logger_l2_d_cancel, \
    logger_l2_l_cancel
from utils.tool import CodeDataCacheUtil
class SecondCancelBigNumComputer:
    __redis_manager = redis_manager.RedisManager(0)
    __sCancelParamsManager = l2_trade_factor.SCancelParamsManager
    __s_big_num_cancel_compute_data_cache = {}
    @classmethod
    def __getRedis(cls):
@@ -35,6 +37,8 @@
    # 保存结束位置
    @classmethod
    def __save_compute_data(cls, code, process_index, buy_num, cancel_num):
        CodeDataCacheUtil.set_cache(cls.__s_big_num_cancel_compute_data_cache, code,
                                    (process_index, buy_num, cancel_num))
        key = "s_big_num_cancel_compute_data-{}".format(code)
        cls.__getRedis().setex(key, tool.get_expire(), json.dumps((process_index, buy_num, cancel_num)))
@@ -48,7 +52,17 @@
        return val[0], val[1], val[2]
    @classmethod
    def __get_compute_data_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__s_big_num_cancel_compute_data_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_compute_data(code)
        CodeDataCacheUtil.set_cache(cls.__s_big_num_cancel_compute_data_cache, code, val)
        return val
    @classmethod
    def __clear_data(cls, code):
        CodeDataCacheUtil.clear_cache(cls.__s_big_num_cancel_compute_data_cache, code)
        ks = ["s_big_num_cancel_compute_data-{}".format(code)]
        for key in ks:
            cls.__getRedis().delete(key)
@@ -59,7 +73,8 @@
        for key in ks:
            keys = cls.__getRedis().keys(key)
            for k in keys:
                cls.__getRedis().delete(k)
                code = k.replace("s_big_num_cancel_compute_data-","")
                cls.__clear_data(code)
    # 计算净大单
    @classmethod
@@ -132,7 +147,7 @@
                    break
        # 获取处理进度
        process_index_old, buy_num, cancel_num = cls.__get_compute_data(code)
        process_index_old, buy_num, cancel_num = cls.__get_compute_data_cache(code)
        # 如果start_index与buy_single_index相同,即是下单后的第一次计算
        # 需要查询买入信号之前的同1s是否有涨停撤的数据
@@ -237,6 +252,12 @@
    __tradeBuyQueue = TradeBuyQueue()
    __buyL2SafeCountManager = BuyL2SafeCountManager()
    __hCancelParamsManager = l2_trade_factor.HCancelParamsManager()
    # 缓存
    __cancel_watch_indexs_cache = {}
    __cancel_watch_indexs_exec_cache = {}
    __cancel_watch_canceled_indexs_cache = {}
    __cancel_traded_progress_cache = {}
    __cancel_compute_data_cache = {}
    @classmethod
    def __getRedis(cls):
@@ -245,6 +266,7 @@
    # 保存成交位置到执行位置的揽括范围数据
    @classmethod
    def __save_watch_index_set(cls, code, datas, process_index, finish):
        CodeDataCacheUtil.set_cache(cls.__cancel_watch_indexs_cache, code, (list(datas), process_index, finish))
        key = f"h_cancel_watch_indexs-{code}"
        cls.__getRedis().setex(key, tool.get_expire(), json.dumps((list(datas), process_index, finish)))
@@ -258,9 +280,20 @@
        val = json.loads(val)
        return val[0], val[1], val[2]
    @classmethod
    def __get_watch_index_set_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_watch_indexs_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_watch_index_set(code)
        CodeDataCacheUtil.set_cache(cls.__cancel_watch_indexs_cache, code, val)
        return val
    # 保存执行位置后面的守护数据
    @classmethod
    def __save_watch_index_set_after_exec(cls, code, datas, process_index, total_count, big_num_count, finished):
        CodeDataCacheUtil.set_cache(cls.__cancel_watch_indexs_exec_cache, code,
                                    (list(datas), process_index, total_count, big_num_count, finished))
        key = f"h_cancel_watch_indexs_exec-{code}"
        cls.__getRedis().setex(key, tool.get_expire(),
                               json.dumps((list(datas), process_index, total_count, big_num_count, finished)))
@@ -275,9 +308,19 @@
        val = json.loads(val)
        return val[0], val[1], val[2], val[3], val[4]
    @classmethod
    def __get_watch_index_set_after_exec_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_watch_indexs_exec_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_watch_index_set_after_exec(code)
        CodeDataCacheUtil.set_cache(cls.__cancel_watch_indexs_exec_cache, code, val)
        return val
    # 保存已经撤单的监听位置
    @classmethod
    def __add_watch_canceled_index(cls, code, index):
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_canceled_indexs_cache, code)
        key = f"h_cancel_watch_canceled_indexs-{code}"
        cls.__getRedis().sadd(key, index)
        cls.__getRedis().expire(key, tool.get_expire())
@@ -288,13 +331,25 @@
        return cls.__getRedis().smembers(key)
    @classmethod
    def __get_watch_canceled_index_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_watch_canceled_indexs_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_watch_canceled_index(code)
        CodeDataCacheUtil.set_cache(cls.__cancel_watch_canceled_indexs_cache, code, val)
        return val
    @classmethod
    def __del_watch_canceled_index(cls, code):
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_canceled_indexs_cache, code)
        key = f"h_cancel_watch_canceled_indexs-{code}"
        cls.__getRedis().delete(key)
    # 保存成交进度
    @classmethod
    def __save_traded_progress(cls, code, origin_process_index, latest_process_index):
        CodeDataCacheUtil.set_cache(cls.__cancel_traded_progress_cache, code,
                                    (origin_process_index, latest_process_index))
        key = "h_cancel_traded_progress-{}".format(code)
        cls.__getRedis().setex(key, tool.get_expire(), json.dumps((origin_process_index, latest_process_index)))
@@ -307,9 +362,20 @@
        val = json.loads(val)
        return val[0], val[1]
    @classmethod
    def __get_traded_progress_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_traded_progress_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_traded_progress(code)
        CodeDataCacheUtil.set_cache(cls.__cancel_traded_progress_cache, code, val)
        return val
    # 保存结算位置
    @classmethod
    def __save_compute_data(cls, code, process_index, cancel_num):
        CodeDataCacheUtil.set_cache(cls.__cancel_compute_data_cache, code,
                                    (process_index, cancel_num))
        key = "h_cancel_compute_data-{}".format(code)
        cls.__getRedis().setex(key, tool.get_expire(), json.dumps((process_index, cancel_num)))
@@ -323,12 +389,29 @@
        return val[0], val[1]
    @classmethod
    def __get_compute_data_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_compute_data_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_compute_data(code)
        CodeDataCacheUtil.set_cache(cls.__cancel_compute_data_cache, code, val)
        return val
    @classmethod
    def __del_compute_data(cls, code):
        CodeDataCacheUtil.clear_cache(cls.__cancel_compute_data_cache, code)
        key = "h_cancel_compute_data-{}".format(code)
        cls.__getRedis().delete(key)
    @classmethod
    def __clear_data(cls, code):
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_indexs_cache, code)
        CodeDataCacheUtil.clear_cache(cls.__cancel_traded_progress_cache, code)
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_canceled_indexs_cache, code)
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_indexs_exec_cache, code)
        CodeDataCacheUtil.clear_cache(cls.__cancel_compute_data_cache, code)
        ks = ["h_cancel_compute_data-{}".format(code), f"h_cancel_watch_indexs_exec-{code}",
              f"h_cancel_watch_indexs-{code}", f"h_cancel_traded_progress-{code}",
              f"h_cancel_watch_canceled_indexs-{code}"]
@@ -351,7 +434,7 @@
        if time_space <= constant.S_CANCEL_EXPIRE_TIME:
            return False, None
        # 获取成交进度
        origin_progress_index, latest_progress_index = cls.__get_traded_progress(code)
        origin_progress_index, latest_progress_index = cls.__get_traded_progress_cache(code)
        if latest_progress_index is None:
            latest_progress_index = -1
        # 监听的数据
@@ -362,7 +445,7 @@
        total_nums = 1
        if origin_progress_index is not None:
            # 获取成交位置到执行位置的监控数据
            watch_indexs = cls.__get_watch_index_set(code)[0]
            watch_indexs = cls.__get_watch_index_set_cache(code)[0]
            # 监听的总数
            for indexs in watch_indexs:
                index = indexs[0]
@@ -372,7 +455,7 @@
                watch_indexs_dict[index] = indexs
                total_nums += total_data[index]["val"]["num"] * indexs[2]
        # 获取到执行位后的监听数据
        datas, process_index, total_count, big_num_count, finished = cls.__get_watch_index_set_after_exec(code)
        datas, process_index, total_count, big_num_count, finished = cls.__get_watch_index_set_after_exec_cache(code)
        if datas:
            for indexs in datas:
                index = indexs[0]
@@ -381,7 +464,7 @@
                watch_indexs_dict[index] = indexs
                total_nums += total_data[index]["val"]["num"] * indexs[2]
        processed_index, cancel_num = cls.__get_compute_data(code)
        processed_index, cancel_num = cls.__get_compute_data_cache(code)
        l2_log.cancel_debug(code, "H级是否需要撤单,数据范围:{}-{} ", start_index, end_index)
        # 获取下单次数
@@ -391,7 +474,7 @@
        # 是否有观测的数据撤单
        has_watch_canceled = False
        # 获取之前已经撤单的数据
        old_canceld_indexs = cls.__get_watch_canceled_index(code)
        old_canceld_indexs = cls.__get_watch_canceled_index_cache(code)
        # 重新计算撤单
        cancel_num = 0
        if old_canceld_indexs:
@@ -448,7 +531,7 @@
            logger_l2_h_cancel.info(
                f"code-{code} H级撤单计算结果 范围:{start_index}-{end_index} 处理进度:{process_index} 目标比例:{cancel_rate_threshold} 取消计算结果:{cancel_num}/{total_nums}")
            # H撤已撤订单
            logger_l2_h_cancel.info(f"code-{code} H撤已撤订单:{cls.__get_watch_canceled_index(code)}")
            logger_l2_h_cancel.info(f"code-{code} H撤已撤订单:{cls.__get_watch_canceled_index_cache(code)}")
            # 保存处理进度与数据
            cls.__save_compute_data(code, process_index, cancel_num)
            # 有观测数据撤单
@@ -476,7 +559,7 @@
                                                                                   "time"]) < constant.S_CANCEL_EXPIRE_TIME - 1:
            return
        # 保存成交进度
        origin_index, latest_index = cls.__get_traded_progress(code)
        origin_index, latest_index = cls.__get_traded_progress_cache(code)
        if origin_index is None:
            cls.__save_traded_progress(code, index, index)
            # 计算揽括范围
@@ -572,7 +655,7 @@
    @classmethod
    def __compute_watch_indexs_after_single(cls, code, buy_single_index, buy_exec_index, total_data,
                                            local_today_num_operate_map, buy_volume_index):
        watch_list, process_index_old, total_count_old, big_num_count_old, finish = cls.__get_watch_index_set_after_exec(
        watch_list, process_index_old, total_count_old, big_num_count_old, finish = cls.__get_watch_index_set_after_exec_cache(
            code)
        if watch_list and finish:
            # 已经计算完了不需要再进行计算
@@ -634,13 +717,13 @@
    # 返回监听范围与已撤单索引
    @classmethod
    def get_watch_index_dict(cls, code):
        origin_progress_index, latest_progress_index = cls.__get_traded_progress(code)
        origin_progress_index, latest_progress_index = cls.__get_traded_progress_cache(code)
        # 监听的数据
        watch_indexs_dict = {}
        total_nums = 0
        if origin_progress_index is not None:
            # 获取成交位置到执行位置的监控数据
            watch_indexs = cls.__get_watch_index_set(code)[0]
            watch_indexs = cls.__get_watch_index_set_cache(code)[0]
            # 监听的总数
            for indexs in watch_indexs:
                index = indexs[0]
@@ -649,12 +732,12 @@
                # 只计算最近的执行位之后的数据
                watch_indexs_dict[index] = indexs
        # 获取到执行位后的监听数据
        datas, process_index, total_count, big_num_count, finished = cls.__get_watch_index_set_after_exec(code)
        datas, process_index, total_count, big_num_count, finished = cls.__get_watch_index_set_after_exec_cache(code)
        if datas:
            for indexs in datas:
                index = indexs[0]
                watch_indexs_dict[index] = indexs
        return watch_indexs_dict, cls.__get_watch_canceled_index(code)
        return watch_indexs_dict, cls.__get_watch_canceled_index_cache(code)
# ---------------------------------D撤-------------------------------
@@ -662,6 +745,7 @@
# 成交位变化之后重新计算
class DCancelBigNumComputer:
    __redis_manager = redis_manager.RedisManager(0)
    __cancel_real_order_index_cache = {}
    @classmethod
    def __getRedis(cls):
@@ -669,6 +753,7 @@
    @classmethod
    def __set_real_order_index(cls, code, index):
        CodeDataCacheUtil.set_cache(cls.__cancel_real_order_index_cache, code, index)
        cls.__getRedis().setex(f"d_cancel_real_order_index-{code}", tool.get_expire(), f"{index}")
    @classmethod
@@ -679,6 +764,15 @@
        return None
    @classmethod
    def __get_real_order_index_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_real_order_index_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_real_order_index(code)
        CodeDataCacheUtil.set_cache(cls.__cancel_real_order_index_cache, code, val)
        return val
    @classmethod
    def clear(cls, code=None):
        if code:
            cls.__getRedis().delete(f"d_cancel_real_order_index-{code}")
@@ -686,6 +780,8 @@
            keys = cls.__getRedis().keys("d_cancel_real_order_index-*")
            if keys:
                for k in keys:
                    code = k.replace("d_cancel_real_order_index-", "")
                    CodeDataCacheUtil.clear_cache(cls.__cancel_real_order_index_cache, code)
                    cls.__getRedis().delete(k)
    # 设置成交位
@@ -697,7 +793,7 @@
                               total_data[buy_exec_index]['val']['time']) > constant.D_CANCEL_EXPIRE_TIME:
            return False, "超过D撤守护时间"
        real_order_index = cls.__get_real_order_index(code)
        real_order_index = cls.__get_real_order_index_cache(code)
        if not real_order_index:
            return False, "尚未获取到真实下单位置"
@@ -743,6 +839,7 @@
class LCancelBigNumComputer:
    __redis_manager = redis_manager.RedisManager(0)
    __last_trade_progress_dict = {}
    __cancel_watch_index_cache = {}
    @classmethod
    def __getRedis(cls):
@@ -750,11 +847,13 @@
    @classmethod
    def __add_watch_index(cls, code, index):
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_index_cache, code)
        cls.__getRedis().sadd(f"l_cancel_watch_index-{code}", index)
        cls.__getRedis().expire(f"l_cancel_watch_index-{code}", tool.get_expire())
    @classmethod
    def __del_watch_index(cls, code, index):
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_index_cache, code)
        cls.__getRedis().srem(f"l_cancel_watch_index-{code}", index)
    @classmethod
@@ -762,22 +861,34 @@
        return cls.__getRedis().smembers(f"l_cancel_watch_index-{code}")
    @classmethod
    def __get_watch_indexes_cache(cls, code):
        cache_result = CodeDataCacheUtil.get_cache(cls.__cancel_watch_index_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = cls.__get_watch_indexes(code)
        cls.__cancel_watch_index_cache[code] = val
        CodeDataCacheUtil.set_cache(cls.__cancel_watch_index_cache, code, val)
        return val
    @classmethod
    def del_watch_index(cls, code):
        CodeDataCacheUtil.clear_cache(cls.__cancel_watch_index_cache, code)
        cls.__getRedis().delete(f"l_cancel_watch_index-{code}")
    @classmethod
    def clear(cls,code=None):
    def clear(cls, code=None):
        if code:
            cls.del_watch_index(code)
        else:
            keys = cls.__getRedis().keys(f"l_cancel_watch_index-*")
            for k in keys:
                cls.__getRedis().delete(k)
                code = k.replace("l_cancel_watch_index-", "")
                cls.del_watch_index(code)
    # 设置成交位置,成交位置变化之后相应的监听数据也会发生变化
    @classmethod
    def set_trade_progress(cls, code, index, total_data):
        old_watch_indexes = cls.__get_watch_indexes(code)
        old_watch_indexes = cls.__get_watch_indexes_cache(code)
        if cls.__last_trade_progress_dict.get(code) == index and len(
                old_watch_indexes) >= constant.L_CANCEL_MAX_WATCH_COUNT:
            # 成交进度尚未发生变化且已经监听到了足够的数据
@@ -822,7 +933,7 @@
        # 守护S撤以外的数据
        if time_space <= constant.S_CANCEL_EXPIRE_TIME or int(tool.get_now_time_str().replace(":", "")) > int("145000"):
            return False, None
        watch_indexes = cls.__get_watch_indexes(code)
        watch_indexes = cls.__get_watch_indexes_cache(code)
        if not watch_indexes:
            return False, None
        watch_indexes = set([int(i) for i in watch_indexes])
@@ -866,6 +977,7 @@
    def cancel_success(cls, code):
        cls.clear(code)
# --------------------------------封单额变化撤------------------------
# 涨停封单额统计
class L2LimitUpMoneyStatisticUtil:
l2/l2_data_manager.py
@@ -6,6 +6,7 @@
from db import redis_manager
from utils import tool
from log_module.log import logger_l2_trade_buy
from utils.tool import CodeDataCacheUtil
_redisManager = redis_manager.RedisManager(1)
@@ -30,6 +31,8 @@
# 交易点管理器,用于管理买入点;买撤点;距离买入点的净买入数据;距离买撤点的买撤数据
class TradePointManager:
    __buy_compute_index_info_cache = {}
    @staticmethod
    def __get_redis():
        return _redisManager.getRedis()
@@ -37,6 +40,7 @@
    # 删除买入点数据
    @staticmethod
    def delete_buy_point(code):
        CodeDataCacheUtil.clear_cache(TradePointManager.__buy_compute_index_info_cache, code)
        redis = TradePointManager.__get_redis()
        redis.delete("buy_compute_index_info-{}".format(code))
@@ -48,9 +52,18 @@
        _key = "buy_compute_index_info-{}".format(code)
        _data_json = redis.get(_key)
        if _data_json is None:
            return None, None, None, 0, 0, [],0
            return None, None, None, 0, 0, [], 0
        _data = json.loads(_data_json)
        return _data[0], _data[1], _data[2], _data[3], _data[4], _data[5], _data[6]
    @staticmethod
    def get_buy_compute_start_data_cache(code):
        cache_result = CodeDataCacheUtil.get_cache(TradePointManager.__buy_compute_index_info_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = TradePointManager.get_buy_compute_start_data_cache(code)
        CodeDataCacheUtil.set_cache(TradePointManager.__buy_compute_index_info_cache, code, val)
        return val
    # 设置买入点的值
    # buy_single_index 买入信号位
@@ -58,17 +71,24 @@
    # compute_index 计算位置
    # nums 累计纯买额
    @staticmethod
    def set_buy_compute_start_data(code, buy_single_index, buy_exec_index, compute_index, nums, count, max_num_sets, volume_rate):
    def set_buy_compute_start_data(code, buy_single_index, buy_exec_index, compute_index, nums, count, max_num_sets,
                                   volume_rate):
        redis = TradePointManager.__get_redis()
        expire = tool.get_expire()
        _key = "buy_compute_index_info-{}".format(code)
        data_ = None
        if buy_single_index is not None:
            redis.setex(_key, expire,
                        json.dumps((buy_single_index, buy_exec_index, compute_index, nums, count, list(max_num_sets),volume_rate)))
            data_ = (buy_single_index, buy_exec_index, compute_index, nums, count, list(max_num_sets),
                     volume_rate)
        else:
            _buy_single_index, _buy_exec_index, _compute_index, _nums, _count, _max_num_index,_volume_rate = TradePointManager.get_buy_compute_start_data(code)
            redis.setex(_key, expire,
                        json.dumps((_buy_single_index, buy_exec_index, compute_index, nums, count, list(max_num_sets),volume_rate)))
            _buy_single_index, _buy_exec_index, _compute_index, _nums, _count, _max_num_index, _volume_rate = TradePointManager.get_buy_compute_start_data_cache(
                code)
            data_ = (_buy_single_index, buy_exec_index, compute_index, nums, count, list(max_num_sets),
                     volume_rate)
        CodeDataCacheUtil.set_cache(TradePointManager.__buy_compute_index_info_cache, code, data_)
        redis.setex(_key, expire,
                    json.dumps(data_))
    # 获取撤买入开始计算的信息
    # 返回数据的内容为:撤销点索引 撤买纯买额 计算的数据索引
@@ -145,7 +165,6 @@
        redis.delete("count_info_for_cancel_buy-{}".format(code))
# 清除l2数据
def clear_l2_data(code):
    redis_l2 = redis_manager.RedisManager(1).getRedis()
@@ -156,10 +175,9 @@
    redis_l2.delete("l2-data-latest-{}".format(code))
second_930 = 9 * 3600 + 30 * 60 + 0
#  初始化l2固定代码库
def init_l2_fixed_codes():
    key = "l2-fixed-codes"
l2/l2_data_manager_new.py
@@ -1132,7 +1132,7 @@
    # 获取下单起始信号
    @classmethod
    def __get_order_begin_pos(cls, code):
        buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data(
        buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data_cache(
            code)
        return buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate
output/code_info_output.py
@@ -324,7 +324,7 @@
                        data['val']['num'] * float(data['val']['price']) * 100 / 10000, 1)}
        # 买入信号
        buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data(
        buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data_cache(
            code)
        if buy_single_index is None:
trade/huaxin/trade_server.py
@@ -194,7 +194,7 @@
                                        break
                                # 获取执行位时间
                                buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data(
                                buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data_cache(
                                    code)
                                if True:
                                    if buy_progress_index is not None:
trade/trade_result_manager.py
@@ -71,7 +71,7 @@
            logging.exception(e)
            logger_l2_error.exception(e)
    buy_single_index, buy_exec_index, buy_compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data(
    buy_single_index, buy_exec_index, buy_compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data_cache(
        code)
    f1 = clear_max_buy1_volume(code)
utils/tool.py
@@ -216,3 +216,21 @@
    # print(trade_time_sub("11:29:59", 5))
    # print(trade_time_sub("10:29:59", 10))
    # print(trade_time_add_second("13:29:59", 60))
class CodeDataCacheUtil:
    # --缓存操作--
    @classmethod
    def clear_cache(cls, cache_dict, code):
        if code in cache_dict:
            cache_dict.pop(code)
    @classmethod
    def set_cache(cls, cache_dict, code, data):
        cache_dict[code] = data
    @classmethod
    def get_cache(cls, cache_dict, code):
        if code in cache_dict:
            return True, cache_dict.get(code)
        return False, None