1
This commit is contained in:
parent
e98b1c3c9c
commit
75c7fd4f0c
@ -11,6 +11,8 @@ from app.crypto_agent.crypto_agent import get_crypto_agent
|
|||||||
from app.services.signal_database_service import get_signal_db_service
|
from app.services.signal_database_service import get_signal_db_service
|
||||||
from app.services.paper_trading_service import get_paper_trading_service
|
from app.services.paper_trading_service import get_paper_trading_service
|
||||||
from app.services.bitget_live_trading_service import get_all_bitget_live_services, get_bitget_live_service
|
from app.services.bitget_live_trading_service import get_all_bitget_live_services, get_bitget_live_service
|
||||||
|
from app.services.price_monitor_service import get_price_monitor_service
|
||||||
|
from app.services.runtime_status_service import get_runtime_status
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@ -429,6 +431,11 @@ async def get_console_snapshot():
|
|||||||
if (_parse_signal_timestamp(signal.get("created_at")) or datetime.min) >= recent_cutoff
|
if (_parse_signal_timestamp(signal.get("created_at")) or datetime.min) >= recent_cutoff
|
||||||
)
|
)
|
||||||
|
|
||||||
|
price_monitor = get_price_monitor_service()
|
||||||
|
configured_symbols = [symbol.strip().upper() for symbol in (get_settings().crypto_symbols or "").split(",") if symbol.strip()]
|
||||||
|
for symbol in configured_symbols:
|
||||||
|
price_monitor.subscribe_symbol(symbol)
|
||||||
|
|
||||||
paper_position_items = [
|
paper_position_items = [
|
||||||
_normalize_platform_position("paper", pos)
|
_normalize_platform_position("paper", pos)
|
||||||
for pos in paper_service.get_open_positions()[:12]
|
for pos in paper_service.get_open_positions()[:12]
|
||||||
@ -517,6 +524,16 @@ async def get_console_snapshot():
|
|||||||
"recent_30m_count": recent_signal_count,
|
"recent_30m_count": recent_signal_count,
|
||||||
},
|
},
|
||||||
"platforms": platforms_payload,
|
"platforms": platforms_payload,
|
||||||
|
"monitoring": {
|
||||||
|
"price_monitor": {
|
||||||
|
"running": price_monitor.is_running(),
|
||||||
|
"mode": "websocket" if getattr(price_monitor, "_use_websocket", False) else "polling",
|
||||||
|
"subscribed_symbols": price_monitor.get_subscribed_symbols(),
|
||||||
|
"latest_prices": price_monitor.get_all_prices(),
|
||||||
|
"checked_at": now.isoformat(),
|
||||||
|
},
|
||||||
|
"execution_loop": get_runtime_status("price_monitor_loop"),
|
||||||
|
},
|
||||||
"management": {
|
"management": {
|
||||||
"positions": unified_positions[:18],
|
"positions": unified_positions[:18],
|
||||||
"orders": unified_orders[:24],
|
"orders": unified_orders[:24],
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import asyncio
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse, RedirectResponse
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
from app.utils.logger import logger
|
from app.utils.logger import logger
|
||||||
@ -485,7 +485,7 @@ if os.path.exists(frontend_path):
|
|||||||
@app.get("/")
|
@app.get("/")
|
||||||
async def root():
|
async def root():
|
||||||
"""根路径,返回主应用页面"""
|
"""根路径,返回主应用页面"""
|
||||||
index_path = os.path.join(frontend_path, "trading.html")
|
index_path = os.path.join(frontend_path, "console.html")
|
||||||
if os.path.exists(index_path):
|
if os.path.exists(index_path):
|
||||||
return FileResponse(index_path)
|
return FileResponse(index_path)
|
||||||
return {"message": "页面不存在"}
|
return {"message": "页面不存在"}
|
||||||
@ -493,7 +493,7 @@ async def root():
|
|||||||
@app.get("/app")
|
@app.get("/app")
|
||||||
async def app_page():
|
async def app_page():
|
||||||
"""主应用页面"""
|
"""主应用页面"""
|
||||||
index_path = os.path.join(frontend_path, "trading.html")
|
index_path = os.path.join(frontend_path, "console.html")
|
||||||
if os.path.exists(index_path):
|
if os.path.exists(index_path):
|
||||||
return FileResponse(index_path)
|
return FileResponse(index_path)
|
||||||
return {"message": "页面不存在"}
|
return {"message": "页面不存在"}
|
||||||
@ -505,19 +505,13 @@ async def health_check():
|
|||||||
|
|
||||||
@app.get("/trading")
|
@app.get("/trading")
|
||||||
async def trading_page():
|
async def trading_page():
|
||||||
"""交易页面"""
|
"""交易页面兼容入口,统一跳转到总控台"""
|
||||||
page_path = os.path.join(frontend_path, "trading.html")
|
return RedirectResponse(url="/console", status_code=307)
|
||||||
if os.path.exists(page_path):
|
|
||||||
return FileResponse(page_path)
|
|
||||||
return {"message": "页面不存在"}
|
|
||||||
|
|
||||||
@app.get("/bitget-trading")
|
@app.get("/bitget-trading")
|
||||||
async def bitget_trading_page():
|
async def bitget_trading_page():
|
||||||
"""Bitget 交易页面兼容入口,统一跳转到当前 trading 页面"""
|
"""Bitget 交易页面兼容入口,统一跳转到总控台"""
|
||||||
page_path = os.path.join(frontend_path, "trading.html")
|
return RedirectResponse(url="/console", status_code=307)
|
||||||
if os.path.exists(page_path):
|
|
||||||
return FileResponse(page_path)
|
|
||||||
return {"message": "页面不存在"}
|
|
||||||
|
|
||||||
@app.get("/signals")
|
@app.get("/signals")
|
||||||
async def signals_page():
|
async def signals_page():
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user