Administrator
2023-08-07 f0bd15f2eb0bf5539010c957c295af6ec1d50bf9
redis批量提交数据
4个文件已修改
36 ■■■■ 已修改文件
code_attribute/big_money_num_manager.py 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/transaction_progress.py 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/l2_trade_factor.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/big_money_num_manager.py
@@ -18,8 +18,14 @@
        return False
__big_money_cache = {}
def add_num(code, num):
    RedisUtils.incrby(__redisManager.getRedis(), "big_money-{}".format(code), num)
    if code not in __big_money_cache:
        __big_money_cache[code] = 0
    __big_money_cache[code] += num
    RedisUtils.incrby_async(__redisManager.getRedis(), "big_money-{}".format(code), num)
# 设置过期时间
@@ -28,6 +34,7 @@
def reset(code):
    __big_money_cache[code] = 0
    RedisUtils.set(__redisManager.getRedis(), "big_money-{}".format(code), 0)
@@ -38,6 +45,14 @@
    return round(int(num) / 1000 / 4)
def get_num_cache(code):
    if code in __big_money_cache:
        return __big_money_cache[code]
    num = get_num(code)
    __big_money_cache[code] = num
    return num
def reset_all():
    redis = __redisManager.getRedis()
    try:
l2/l2_data_manager.py
@@ -85,7 +85,7 @@
            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_)
        RedisUtils.setex(
        RedisUtils.setex_async(
            TradePointManager.__get_redis(), _key, expire,
            json.dumps(data_))
l2/transaction_progress.py
@@ -13,6 +13,8 @@
import l2.l2_data_util
from log_module.log import logger_l2_trade_buy_queue, logger_l2_trade_buy_progress
buy_progress_index_cache = {}
class TradeBuyQueue:
    __redis_manager = redis_manager.RedisManager(0)
@@ -37,8 +39,9 @@
        return val[0], [1]
    def __save_buy_progress_index(self, code, index, is_default):
        tool.CodeDataCacheUtil.set_cache(buy_progress_index_cache, code, (index, is_default))
        key = "trade_buy_progress_index-{}".format(code)
        RedisUtils.setex(self.__getRedis(), key, tool.get_expire(), json.dumps((index, is_default)))
        RedisUtils.setex_async(self.__getRedis(), key, tool.get_expire(), json.dumps((index, is_default)))
        # 返回数据与更新时间
    def __get_buy_progress_index(self, code):
@@ -48,6 +51,14 @@
            return None, True
        val = json.loads(val)
        return int(val[0]), bool(val[1])
    def __get_buy_progress_index_cache(self, code):
        cache_result = tool.CodeDataCacheUtil.get_cache(buy_progress_index_cache, code)
        if cache_result[0]:
            return cache_result[1]
        val = self.__get_buy_progress_index(code)
        tool.CodeDataCacheUtil.set_cache(buy_progress_index_cache, code, val)
        return val
    # 最近的非涨停买1的时间
    def __save_latest_not_limit_up_time(self, code, time_str):
@@ -146,7 +157,7 @@
    # 获取成交进度索引
    def get_traded_index(self, code):
        index, is_default = self.__get_buy_progress_index(code)
        index, is_default = self.__get_buy_progress_index_cache(code)
        return index, is_default
    def set_traded_index(self, code, index):
trade/l2_trade_factor.py
@@ -435,7 +435,7 @@
        big_money_num = global_util.big_money_num.get(code)
        if big_money_num is None:
            big_money_num = big_money_num_manager.get_num(code)
            big_money_num = big_money_num_manager.get_num_cache(code)
        return (
            zyltgb, total_industry_limit_percent, volumn_day60_max, volumn_yest, volumn_today, limit_up_time,
            big_money_num)