9cd81a3ea7
Split vn.py into qihuo-ctp worker with IPC client bridge, keep CTP connected during breaks with cached account fallback, speed up strategy page loads, and allow off-session breakout roll submissions. Co-authored-by: Cursor <cursoragent@cursor.com>
73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
"""Deploy position display fix: stop ALTER lock + live rows from CTP."""
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
root = Path(__file__).resolve().parents[1]
|
|
files = [
|
|
"ctp_ipc_client.py",
|
|
"ctp_worker.py",
|
|
"ecosystem.config.cjs",
|
|
"market_sessions.py",
|
|
"trading_context.py",
|
|
"dashboard_lib.py",
|
|
"sl_tp_guard.py",
|
|
"install_trading.py",
|
|
"vnpy_bridge.py",
|
|
"static/js/trade.js",
|
|
"templates/strategy.html",
|
|
"templates/strategy_records.html",
|
|
"static/js/strategy.js",
|
|
"strategy/strategy_roll_lib.py",
|
|
"scripts/run_schema_migrate.py",
|
|
]
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("192.168.8.21", username="root", password="woaini88", timeout=15)
|
|
sftp = c.open_sftp()
|
|
for rel in files:
|
|
sftp.put(str(root / rel), f"/opt/qihuo/{rel}")
|
|
print("uploaded", rel)
|
|
sftp.close()
|
|
|
|
cmds = [
|
|
"cd /opt/qihuo && source venv/bin/activate && python3 scripts/run_schema_migrate.py",
|
|
"cd /opt/qihuo && source venv/bin/activate && python3 -m py_compile ctp_ipc_client.py ctp_worker.py vnpy_bridge.py sl_tp_guard.py install_trading.py",
|
|
"cd /opt/qihuo && (pm2 describe qihuo-ctp >/dev/null && pm2 restart qihuo-ctp --update-env || pm2 start ecosystem.config.cjs --only qihuo-ctp)",
|
|
"cd /opt/qihuo && (pm2 describe qihuo >/dev/null && pm2 restart qihuo --update-env || pm2 start ecosystem.config.cjs --only qihuo)",
|
|
"pm2 save",
|
|
]
|
|
for cmd in cmds:
|
|
print(">>>", cmd)
|
|
_, o, e = c.exec_command(cmd, timeout=120)
|
|
out = o.read().decode("utf-8", "replace")
|
|
err = e.read().decode("utf-8", "replace")
|
|
if out.strip():
|
|
print(out)
|
|
if err.strip():
|
|
print(err)
|
|
|
|
time.sleep(25)
|
|
_, o, _ = c.exec_command(
|
|
"curl -s -o /dev/null -w 'login:%{http_code}\\n' --max-time 10 http://127.0.0.1:6600/login",
|
|
timeout=30,
|
|
)
|
|
print(o.read().decode())
|
|
|
|
# verify live vs account_snapshot
|
|
poll = root / "scripts" / "_poll_loop.py"
|
|
if poll.exists():
|
|
import subprocess
|
|
|
|
r = subprocess.run([sys.executable, str(poll)], capture_output=True, text=True, timeout=120)
|
|
print(r.stdout)
|
|
if r.stderr.strip():
|
|
print(r.stderr)
|
|
|
|
c.close()
|
|
print("done")
|