admin
2025-03-25 5acb6f700c6ffaf1c7470664c2f06dc6ecf2efba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
定义整个项目的定时器
"""
# import datetime
import time
 
from log_module.log import logger_common
from strategy import data_cache, index_market_trend_strategy
from strategy import kpl_api
from utils import tool
 
# from strategy import instant_time_market
 
# 获取logger实例
logger = logger_common
 
 
# 构建一个项目整体的定时器对象
# class CheckTimer:
#     def __init__(self):
#         pass
 
# 定时器函数
def check_time():
    while True:
        try:
            # 声明赋值实时时间
            now_time = tool.get_now_time_str()
            # print(f"now_time==={now_time}")
            if now_time > data_cache.AFTER_CLOSING_TIME and data_cache.execution is False:
                # 整理当日涨停信息并写入本地管理好本地数据
                kpl_api.get_arrange_limit_up_info()
                logger.info(f"整理当日涨停信息 已经运行完成")
                # # 获取所有个股的板块概念并写入文件【耗时较长应该放在 核心主线程 和 仓位管理 后面】
                kpl_api.get_all_stocks_plate_dict(data_cache.DataCache().filtered_stocks)
                logger.info(f"获取所有个股的板块概念 已经运行完成")
                # 完成了后将是否执行的开个标记为真
                data_cache.execution = True
            # 本地数据更新时间
            if data_cache.UPDATE_DATA_TIME < now_time and data_cache.index_K_line_write_execution is False:
                # 写入所有指数K线
                index_market_trend_strategy.all_index_k_line_dict_write()
                logger.info(f"写入所有带属性指数K线 已经运行完成")
                # 完成了后将是否执行的开个标记为真
                data_cache.index_K_line_write_execution = True
        except Exception as error:
            logger.error(f"实时检测定时器线程报错: {error}")
        finally:
            time.sleep(1)