stock-ai-agent/backend/run_crypto_agent.py
2026-02-20 22:04:53 +08:00

40 lines
956 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
加密货币智能体启动脚本
"""
import asyncio
import sys
import os
# 添加项目路径
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app.crypto_agent.crypto_agent import get_crypto_agent
from app.utils.logger import logger
async def main():
"""主函数"""
logger.info("=" * 50)
logger.info("加密货币交易信号智能体")
logger.info("=" * 50)
try:
crypto_agent = get_crypto_agent()
await crypto_agent.run()
except KeyboardInterrupt:
logger.info("收到停止信号,正在关闭...")
crypto_agent.stop()
except Exception as e:
logger.error(f"运行出错: {e}")
raise
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
# 静默处理 Ctrl+C避免 WebSocket 关闭时的错误刷屏
print("\n程序已退出")
sys.exit(0)