Administrator
2024-11-29 b8dd6ca5f8a8da42531e8308e842c70bc5b1a7a4
收盘之后的日志系统添加缓存
1个文件已修改
37 ■■■■ 已修改文件
log_module/log_export.py 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log_export.py
@@ -11,6 +11,26 @@
from log_module.log import logger_l2_process_time
from utils import tool
__log_cache_data = {}
# 日志缓存
def cache_log(fn):
    def wrapper(*args, **kwargs):
        can_cache = tool.get_now_time_as_int() > 150000
        cache_key = f"{fn.__name__}#{args}#{kwargs}"
        if can_cache:
            # 15:00:00之后才能缓存
            if cache_key in __log_cache_data:
                return __log_cache_data[cache_key]
        result = fn(*args, **kwargs)
        if can_cache:
            __log_cache_data[cache_key] = result
        return result
    return wrapper
class LogUtil:
    @classmethod
@@ -77,6 +97,7 @@
    return tool.time_seconds_format(s - 2 - cha)
@cache_log
def load_l2_from_log(date=None):
    today_data = {}
    if date is None:
@@ -121,6 +142,7 @@
# 获取L2每次批量处理数据的位置范围
@cache_log
def get_l2_process_position(code, date=None):
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
@@ -149,6 +171,7 @@
# 获取L2每次批量处理数据的位置范围
@cache_log
def get_l2_trade_position(code, date=None):
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
@@ -197,6 +220,7 @@
# 获取L2每次批量处理数据的位置范围
@cache_log
def get_real_place_order_positions(code, date=None):
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
@@ -405,10 +429,10 @@
            code = data_json["code"]
            if type != type_:
                continue
            fdatas.append((time_str,code, type, data_json["data"]))
            fdatas.append((time_str, code, type, data_json["data"]))
    return fdatas
@cache_log
def load_cancel_buy_reasons(code, date=tool.get_now_date_str()):
    """
    获取撤单原因
@@ -429,6 +453,7 @@
# 加载l2订单成交数据
@cache_log
def load_huaxin_deal_record(code, date=tool.get_now_date_str()):
    path = f"{constant.get_path_prefix()}/logs/huaxin/l2/transaction_desc.{date}.log"
    # 格式:[(订单号,手数,开始成交时间,成交结束时间,下单手数)]
@@ -474,6 +499,7 @@
    return fdatas
@cache_log
def load_kpl_limit_up_records(current_time_str, date=tool.get_now_date_str()):
    """
    获取离给定时间最近的涨停数据
@@ -515,6 +541,7 @@
# 加载华鑫成交的卖单
@cache_log
def load_huaxin_transaction_sell_no(code=None, date=tool.get_now_date_str()):
    path = f"{constant.get_path_prefix()}/logs/huaxin/l2/transaction_sell_order.{date}.log"
    fdatas = {}
@@ -606,7 +633,7 @@
                        pass
    return fdatas
@cache_log
def load_huaxin_active_sell_map(date=tool.get_now_date_str()):
    path = f"{constant.get_path_prefix()}/logs/huaxin/trade/l2_active_sell.{date}.log"
    fdatas = {}
@@ -724,8 +751,8 @@
if __name__ == '__main__':
    fdatas = load_kpl_limit_up_records("10:00:00", "2024-10-21")
    print(fdatas)
    load_huaxin_transaction_sell_no(code = '2024-11-10')
    load_huaxin_transaction_sell_no(code='2024-11-10')
    # print(get_h_cancel_compute_info("603912"))
    # logger_l2_h_cancel.info("test")