You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
# -*- coding: utf-8 -*-
|
|
"""主程序入口"""
|
|
|
|
import time
|
|
from core.simulator import AlphaSimulator
|
|
from config.settings import settings
|
|
from utils.helpers import retry_on_exception
|
|
|
|
|
|
@retry_on_exception(max_retries=3, delay=5.0)
|
|
def main_loop(simulator: AlphaSimulator) -> None:
|
|
"""主循环"""
|
|
if simulator.needs_token_refresh():
|
|
print("Token需要刷新,重新登录...")
|
|
simulator.login()
|
|
|
|
alpha_list = simulator.load_alpha_list()
|
|
if not alpha_list:
|
|
print("暂无待处理的alpha表达式,10分钟后重新检查...")
|
|
time.sleep(600)
|
|
return
|
|
|
|
print(f"共加载 {len(alpha_list)} 个需要模拟的因子表达式")
|
|
success_count, fail_count = simulator.run_batch_simulation(alpha_list)
|
|
print(f"本轮处理完成: 成功 {success_count} 个, 失败 {fail_count} 个")
|
|
|
|
|
|
def main():
|
|
"""主函数"""
|
|
simulator = AlphaSimulator()
|
|
simulator.initialize()
|
|
|
|
try:
|
|
while True:
|
|
main_loop(simulator)
|
|
print(f"等待{settings.CHECK_INTERVAL // 60}分钟后继续检查...")
|
|
time.sleep(settings.CHECK_INTERVAL)
|
|
except KeyboardInterrupt:
|
|
print("\n程序被用户中断")
|
|
except Exception as e:
|
|
print(f"程序执行异常: {e}")
|
|
raise
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |