stock-ai-agent/backend/run_crypto.sh
2026-02-05 22:23:41 +08:00

86 lines
2.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

#!/bin/bash
# 加密货币智能体启动脚本
echo "================================"
echo "加密货币交易信号智能体"
echo "================================"
echo ""
cd /Users/aaron/source_code/Stock_Agent/backend
# 激活虚拟环境
if [ ! -d "venv" ]; then
echo "❌ 虚拟环境不存在,请先运行 ../install.sh"
exit 1
fi
source venv/bin/activate
# 检查依赖
echo "1. 检查依赖..."
python3 -c "import binance; print(' ✓ python-binance')" 2>/dev/null || {
echo " 安装 python-binance..."
pip install python-binance -q
}
python3 -c "import httpx; print(' ✓ httpx')" 2>/dev/null || {
echo " 安装 httpx..."
pip install httpx -q
}
# 测试导入
echo ""
echo "2. 测试模块导入..."
python3 << 'EOF'
try:
from app.services.binance_service import binance_service
print(" ✓ Binance 服务")
from app.services.feishu_service import get_feishu_service
print(" ✓ 飞书服务")
from app.crypto_agent.crypto_agent import crypto_agent
print(" ✓ 加密货币智能体")
print("\n所有模块导入成功")
except Exception as e:
print(f"\n❌ 导入失败: {e}")
import traceback
traceback.print_exc()
exit(1)
EOF
if [ $? -ne 0 ]; then
echo ""
echo "模块导入失败,请检查错误信息"
exit 1
fi
# 检查配置
echo ""
echo "3. 检查配置..."
python3 << 'EOF'
from app.config import get_settings
settings = get_settings()
print(f" 监控交易对: {settings.crypto_symbols}")
print(f" 分析间隔: {settings.crypto_analysis_interval}秒")
print(f" 飞书 Webhook: {'✓ 已配置' if settings.feishu_webhook_url else '❌ 未配置'}")
print(f" LLM 服务: {'✓ 已配置' if settings.zhipuai_api_key or settings.deepseek_api_key else '⚠️ 未配置'}")
if not settings.feishu_webhook_url:
print("\n⚠ 警告: 飞书 Webhook 未配置,将无法发送通知")
EOF
echo ""
echo "================================"
echo "启动智能体..."
echo "================================"
echo ""
echo "按 Ctrl+C 停止"
echo ""
# 启动智能体
python3 run_crypto_agent.py