51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""市场概览 API"""
|
|
|
|
from datetime import datetime
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app.engine.recommender import get_latest_recommendations
|
|
from app.config import is_trading_hours, should_prefer_realtime_today, today_trade_date
|
|
|
|
router = APIRouter(prefix="/api/market", tags=["market"])
|
|
|
|
|
|
@router.get("/temperature")
|
|
async def get_temperature():
|
|
"""获取市场温度快照。页面访问只读数据库,不触发外部行情。"""
|
|
result = await get_latest_recommendations()
|
|
mt = result.get("market_temp")
|
|
if mt:
|
|
return {
|
|
"trade_date": mt.trade_date,
|
|
"temperature": mt.temperature,
|
|
"up_count": mt.up_count,
|
|
"down_count": mt.down_count,
|
|
"limit_up_count": mt.limit_up_count,
|
|
"limit_down_count": mt.limit_down_count,
|
|
"max_streak": mt.max_streak,
|
|
"broken_rate": mt.broken_rate,
|
|
"index_above_ma20": getattr(mt, "index_above_ma20", False),
|
|
"is_trading": is_trading_hours(),
|
|
"data_mode": "daily_snapshot",
|
|
"limit_counts_reliable": False,
|
|
}
|
|
return {
|
|
"trade_date": "",
|
|
"temperature": 0,
|
|
"up_count": 0,
|
|
"down_count": 0,
|
|
"limit_up_count": 0,
|
|
"limit_down_count": 0,
|
|
"max_streak": 0,
|
|
"broken_rate": 0,
|
|
"index_above_ma20": False,
|
|
"is_trading": is_trading_hours(),
|
|
}
|
|
|
|
|
|
@router.get("/overview")
|
|
async def get_overview():
|
|
"""市场概况快照。"""
|
|
return []
|