crypto.ai/cryptoai/main.py
2025-04-29 00:37:52 +08:00

41 lines
1007 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import argparse
from typing import Dict, Any
import schedule
import time
# 添加项目根目录到Python路径
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)
from cryptoai.agents.crypto_agent import CryptoAgent
from cryptoai.agents.gold_agent import GoldAgent
from cryptoai.utils.config_loader import ConfigLoader
def main():
try:
print("程序启动")
# 设置每个4小时运行一次
schedule.every(4).hours.do(CryptoAgent().start_agent)
# 启动定时任务
while True:
schedule.run_pending()
time.sleep(1)
# CryptoAgent().start_agent()
except KeyboardInterrupt:
print("\n程序已退出")
except Exception as e:
print(f"程序运行出错: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()