diff --git a/README.md b/README.md index 6f89c83..cbe658e 100644 --- a/README.md +++ b/README.md @@ -260,7 +260,7 @@ Live-исполнение ведет журнал order intent до отправ - `GET /api/health` — healthcheck. - `GET /api/status` — статус бота, account snapshot, позиции. -- `GET /api/dashboard/snapshot` — компактный защищённый snapshot для веб-панели. +- `GET /api/dashboard/snapshot` — компактный защищённый snapshot для веб-панели; внешний UI использует эквивалентный `/web-api/dashboard/snapshot`, чтобы не смешивать Basic-auth браузера с токеном мобильного API. - `GET /api/markets` — пары, ticker, свечи, инструменты. - `GET /api/training/market-observations?symbol=BTCUSDT&after_id=0&limit=5000` — защищённая training-token выгрузка L1-наблюдений. - `GET /api/training/market-observations/manifest` — training-token manifest для инкрементальной синхронизации forward L1-данных. diff --git a/crypto_spot_bot/dashboard.py b/crypto_spot_bot/dashboard.py index b80fb7b..2317d40 100644 --- a/crypto_spot_bot/dashboard.py +++ b/crypto_spot_bot/dashboard.py @@ -339,6 +339,7 @@ def create_app(settings: Settings | None = None) -> FastAPI: "backtest": _runtime_json(settings, "torch_threshold_calibration.json"), } + @app.get("/web-api/dashboard/snapshot", include_in_schema=False) @app.get("/api/dashboard/snapshot") async def dashboard_snapshot(_: None = Depends(authorizer.require)) -> dict[str, Any]: market_data = market.snapshot() @@ -376,6 +377,7 @@ def create_app(settings: Settings | None = None) -> FastAPI: "config": _safe_config(settings), } + @app.post("/web-api/config/fast-trading", include_in_schema=False) @app.post("/api/config/fast-trading") async def set_fast_trading( payload: dict[str, Any], @@ -387,11 +389,13 @@ def create_app(settings: Settings | None = None) -> FastAPI: response["env_persisted"] = env_persisted return response + @app.post("/web-api/control/start", include_in_schema=False) @app.post("/api/control/start") async def start(_: None = Depends(authorizer.require)) -> dict[str, Any]: await bot.start() return bot.status().as_dict() + @app.post("/web-api/control/stop", include_in_schema=False) @app.post("/api/control/stop") async def stop(_: None = Depends(authorizer.require)) -> dict[str, Any]: await bot.stop() diff --git a/crypto_spot_bot/web/dashboard.js b/crypto_spot_bot/web/dashboard.js index 16d112f..e990789 100644 --- a/crypto_spot_bot/web/dashboard.js +++ b/crypto_spot_bot/web/dashboard.js @@ -110,7 +110,7 @@ async function loadSnapshot(manual = false, fromAuth = false) { $("#refreshButton").classList.add("is-spinning"); if (manual) setText("syncLabel", "Обновление…"); try { - const snapshot = await api("/api/dashboard/snapshot"); + const snapshot = await api("/web-api/dashboard/snapshot"); state.snapshot = snapshot; render(snapshot); setOffline(false); @@ -411,7 +411,7 @@ async function requestControl(action) { if (!confirmed) return; setControlsBusy(true); try { - await api(`/api/control/${action}`, { method: "POST" }); + await api(`/web-api/control/${action}`, { method: "POST" }); toast(start ? "Торговый цикл запущен." : "Торговый цикл остановлен."); await loadSnapshot(true); } catch (error) { @@ -436,7 +436,7 @@ async function onFastTradingChange(event) { if (!confirmed) { toggle.checked = previous; return; } toggle.disabled = true; try { - const result = await api("/api/config/fast-trading", { method: "POST", body: JSON.stringify({ enabled }) }); + const result = await api("/web-api/config/fast-trading", { method: "POST", body: JSON.stringify({ enabled }) }); toast(`Быстрая торговля ${enabled ? "включена" : "выключена"}${result.env_persisted === false ? " только в runtime" : ""}.`); await loadSnapshot(true); } catch (error) { diff --git a/crypto_spot_bot/web/index.html b/crypto_spot_bot/web/index.html index 32c81ae..d8068ee 100644 --- a/crypto_spot_bot/web/index.html +++ b/crypto_spot_bot/web/index.html @@ -19,23 +19,23 @@