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

Function validate_tushare_connection

cli/utils.py:34–55  ·  view source on GitHub ↗

验证Tushare连接

()

Source from the content-addressed store, hash-verified

32 return f"{now.strftime('%Y-%m-%d %H:%M:%S')}"
33
34def validate_tushare_connection():
35 """验证Tushare连接"""
36 try:
37 # Import config when needed
38 from contest_trade.config.config import cfg
39
40 console.print("🔍 [cyan]正在验证Tushare配置...[/cyan]")
41 ts.set_token(cfg.tushare_key)
42 pro = ts.pro_api(cfg.tushare_key, timeout=3)
43 end_date = datetime.now().strftime('%Y%m%d')
44 start_date = (datetime.now() - timedelta(days=3)).strftime('%Y%m%d')
45 trade_cal = pro.trade_cal(exchange='SSE', start_date=start_date, end_date=end_date, timeout=1)
46 print(trade_cal)
47 if trade_cal is not None and len(trade_cal) > 0:
48 console.print(f"✅ [green]Tushare连接成功[/green]")
49 return True
50 else:
51 console.print("❌ [red]Tushare连接失败 - 未获取到数据[/red]")
52 return False
53 except Exception as e:
54 console.print(f"❌ [red]Tushare连接失败: {str(e)}[/red]")
55 return False
56
57def validate_llm_connection():
58 """验证LLM连接"""

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected