MCPcopy Create free account
hub / github.com/FinStep-AI/ContestTrade / validate_required_services

Function validate_required_services

cli/utils.py:78–124  ·  view source on GitHub ↗

根据配置文件中的tushare_key自动决定验证策略

()

Source from the content-addressed store, hash-verified

76 return False
77
78def validate_required_services():
79 """根据配置文件中的tushare_key自动决定验证策略"""
80 # Import config when needed
81 from contest_trade.config.config import cfg
82
83 console.print("\n" + "="*50)
84 console.print("🔧 [bold blue]正在验证必要系统配置...[/bold blue]")
85 console.print("="*50)
86 all_valid = True
87
88 # 检查tushare_key是否为空
89 tushare_key = getattr(cfg, 'tushare_key', '')
90 has_tushare_key = tushare_key and tushare_key.strip() and tushare_key != "YOUR_TUSHARE_KEY"
91
92 if has_tushare_key:
93 console.print("🔍 [cyan]检测到Tushare密钥,将验证Tushare连接...[/cyan]")
94 # 验证Tushare
95 if not validate_tushare_connection():
96 all_valid = False
97 else:
98 console.print("ℹ️ [yellow]未检测到Tushare密钥,跳过Tushare验证[/yellow]")
99
100 # 验证akshare是否安装
101 try:
102 import akshare
103 console.print("✅ [green]akshare已安装[/green]")
104 except ImportError:
105 console.print("❌ [red]akshare未安装,请重新执行pip install akshare[/red]")
106 all_valid = False
107
108 # 始终验证LLM
109 if not validate_llm_connection():
110 all_valid = False
111
112 console.print("="*50)
113
114 if all_valid:
115 if has_tushare_key:
116 console.print("🎉 [bold green]所有必要系统配置验证通过(包含Tushare),系统准备就绪![/bold green]")
117 else:
118 console.print("🎉 [bold green]所有必要系统配置验证通过(不含Tushare),系统准备就绪![/bold green]")
119 console.print("="*50 + "\n")
120 return True
121 else:
122 console.print("⚠️ [bold red]必要系统配置验证失败,请检查配置文件[/bold red]")
123 console.print("="*50 + "\n")
124 return False
125
126def format_agent_name(agent_type: str, agent_id: int, agent_name: str) -> str:
127 """格式化Agent名称"""

Callers 1

runFunction · 0.85

Calls 2

validate_llm_connectionFunction · 0.85

Tested by

no test coverage detected