diff --git a/manual_trading_hub/hub.py b/manual_trading_hub/hub.py index f260f01..42cd70f 100644 --- a/manual_trading_hub/hub.py +++ b/manual_trading_hub/hub.py @@ -408,6 +408,48 @@ async def api_close_all(body: CloseAllBody | None = Body(default=None)): return {"results": list(results)} +def _trade_removed_response(): + """旧版前端或缓存页面仍会请求 /api/trade/*,勿解析表单,直接返回说明。""" + return JSONResponse( + { + "ok": False, + "result": { + "ok": False, + "messages": [ + "中控已移除下单区。请在监控卡片点击「实例」," + "进入对应 crypto_monitor_* 网页添加关键位或下单。" + ], + }, + "deprecated": True, + }, + status_code=410, + ) + + +@app.get("/api/ping") +def api_ping(): + return { + "ok": True, + "service": "manual-trading-hub", + "trade_ui": False, + "features": ["monitor", "settings", "auth"], + } + + +@app.post("/api/trade/order/{exchange_id}") +@app.post("/api/trade/key/{exchange_id}") +@app.post("/api/trade/trend/preview/{exchange_id}") +@app.post("/api/trade/trend/execute/{exchange_id}") +async def api_trade_removed(exchange_id: str): + return _trade_removed_response() + + +@app.get("/api/trade/meta/{exchange_id}") +@app.get("/api/trade/trend/preview/{exchange_id}/{preview_id}") +async def api_trade_removed_get(exchange_id: str, preview_id: str = ""): + return _trade_removed_response() + + def main(): import uvicorn diff --git a/manual_trading_hub/scripts/fix_hub_deps.sh b/manual_trading_hub/scripts/fix_hub_deps.sh new file mode 100644 index 0000000..bbc5e4c --- /dev/null +++ b/manual_trading_hub/scripts/fix_hub_deps.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# 修复中控缺 python-multipart 等问题 +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" +if [[ ! -d .venv ]]; then + python3 -m venv .venv +fi +# shellcheck source=/dev/null +source .venv/bin/activate +pip install -U pip +pip install -r requirements.txt +echo "OK: $(python -c 'import multipart; print("python-multipart", multipart.__version__)' 2>/dev/null || pip show python-multipart | head -1)" +echo "Hub ping (需 hub 已启动): curl -s http://127.0.0.1:5100/api/ping"