initial-import: 2026-04-11 21:18:55
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# {{username}} - Web Trader
|
||||
location ~* ^{{nginx_path}}(.*)$ {
|
||||
proxy_pass http://127.0.0.1:{{web_port}}/$1$is_args$args;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# WebSocket支持
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
用户: {{username}}
|
||||
交易进程启动脚本 - 启动RPC服务端
|
||||
"""
|
||||
|
||||
from vnpy.trader.event_engine import EventEngine
|
||||
from vnpy.trader.main_engine import MainEngine
|
||||
from vnpy.rpc import RpcServer
|
||||
# 导入需要的gateway
|
||||
# from vnpy_ctp import CtpGateway
|
||||
# from vnpy_ib import IbGateway
|
||||
# 导入需要的app
|
||||
# from vnpy_ctastrategy import CtaStrategyApp
|
||||
|
||||
def main():
|
||||
# 创建核心引擎
|
||||
event_engine = EventEngine()
|
||||
main_engine = MainEngine(event_engine)
|
||||
|
||||
# 添加gateway
|
||||
# main_engine.add_gateway(CtpGateway)
|
||||
# main_engine.add_gateway(IbGateway)
|
||||
|
||||
# 添加应用模块
|
||||
# main_engine.add_app(CtaStrategyApp)
|
||||
# main_engine.add_app(PortfolioStrategyApp)
|
||||
|
||||
# 启动RPC服务
|
||||
rpc_request_port = {{rpc_request_port}}
|
||||
rpc_subscribe_port = {{rpc_subscribe_port}}
|
||||
|
||||
rpc_server = RpcServer(
|
||||
main_engine,
|
||||
("0.0.0.0", rpc_request_port),
|
||||
("0.0.0.0", rpc_subscribe_port)
|
||||
)
|
||||
rpc_server.start()
|
||||
|
||||
print(f"[{username}] RPC服务已启动")
|
||||
print(f"- 请求地址: tcp://0.0.0.0:{rpc_request_port}")
|
||||
print(f"- 订阅地址: tcp://0.0.0.0:{rpc_subscribe_port}")
|
||||
print("按回车键退出...")
|
||||
input()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
用户: {{username}}
|
||||
Web进程启动脚本 - 启动FastAPI Web服务
|
||||
"""
|
||||
|
||||
from vnpy_webtrader import run_web_trader
|
||||
|
||||
def main():
|
||||
# RPC连接地址(连接本地交易进程
|
||||
rpc_request_port = {{rpc_request_port}}
|
||||
rpc_subscribe_port = {{rpc_subscribe_port}}
|
||||
web_port = {{web_port}}
|
||||
|
||||
rpc_request_address = f"tcp://127.0.0.1:{rpc_request_port}"
|
||||
rpc_subscribe_address = f"tcp://127.0.0.1:{rpc_subscribe_port}"
|
||||
|
||||
print(f"[{username}] Web服务启动")
|
||||
print(f"- RPC请求: {rpc_request_address}")
|
||||
print(f"- RPC订阅: {rpc_subscribe_address}")
|
||||
print(f"- Web端口: {web_port}")
|
||||
|
||||
run_web_trader(
|
||||
rpc_request_address,
|
||||
rpc_subscribe_address,
|
||||
host="127.0.0.1",
|
||||
port=web_port,
|
||||
cors_allow_all=True
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=sanguo_vnpy 交易进程 - {{username}}
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{username}}
|
||||
WorkingDirectory={{base_dir}}/users/{{username}}
|
||||
ExecStart=/usr/bin/python3 {{base_dir}}/users/{{username}}/start_trade.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=sanguo_vnpy Web进程 - {{username}}
|
||||
After=network.target sanguo-trade-{{username}}.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{username}}
|
||||
WorkingDirectory={{base_dir}}/users/{{username}}
|
||||
ExecStart=/usr/bin/python3 {{base_dir}}/users/{{username}}/start_web.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user