Files
sanguo_vnpy_v2/run_web.py
T
claude_dev 70d72f35bb chore(vendor): vendor vnpy_qmt 0.3.3 源码自行维护
vnpy_qmt 是唯一券商交易 gateway(关键路径),社区包断更有风险。
按 vnpy_v4.4.0 同一套约定 vendor 源码、sys.path 引用、不 pip install。
- vnpy_qmt_v0.3.3/vnpy_qmt/ (5文件587行) + LICENSE(Apache-2.0) + README
- run_web.py 加 if-exists 路径块,import 方式不变 (from vnpy_qmt import QmtGateway)
Mac 验证: py_compile 全过 + import 解析到 vendor 副本(仅卡 xtquant Win-only,符合预期)
VPS 生产切换(Part B: rsync+pip uninstall+重启+实证) 待确认
2026-07-15 21:15:53 +08:00

38 lines
1.2 KiB
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
"""
Sanguo VeighNa Web API 启动脚本
"""
import sys
import os
# 添加项目根目录到 Python 路径
project_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, project_dir)
# 添加 vnpy_v4.4.0 到 Python 路径
vnpy_dir = os.path.join(project_dir, "vnpy_v4.4.0")
if os.path.exists(vnpy_dir):
sys.path.insert(0, vnpy_dir)
print(f"Added vnpy_v4.4.0 to Python path: {vnpy_dir}")
# 添加 vnpy_qmt_v0.3.3vendor 源码,自行维护)到 Python 路径
qmt_dir = os.path.join(project_dir, "vnpy_qmt_v0.3.3")
if os.path.exists(qmt_dir):
sys.path.insert(0, qmt_dir)
print(f"Added vnpy_qmt_v0.3.3 to Python path: {qmt_dir}")
if __name__ == "__main__":
import uvicorn
# Phase 3b 起:研究/回测 API sanguo_api(工厂模式,读 config/backtest.yaml
# 单进程(uvicorn.run 默认 workers=1)——orchestrator 任务状态在内存,必须单进程。
# 端口 8000 不变(vnpy.mysanguo.top 外网绑定依赖)。
uvicorn.run(
"sanguo_api.main:create_app",
factory=True,
host="0.0.0.0",
port=8000,
reload=False, # 生产模式
log_level="info"
)