27 lines
760 B
Python
27 lines
760 B
Python
"""板块分析 API"""
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app.engine.recommender import get_latest_sectors
|
|
|
|
router = APIRouter(prefix="/api/sectors", tags=["sectors"])
|
|
|
|
|
|
@router.get("/hot")
|
|
async def get_hot_sectors(limit: int = 10):
|
|
"""获取热门板块排名(只读缓存,不触发扫描)"""
|
|
sectors = await get_latest_sectors()
|
|
return [
|
|
{
|
|
"sector_code": s.sector_code,
|
|
"sector_name": s.sector_name,
|
|
"pct_change": s.pct_change,
|
|
"capital_inflow": s.capital_inflow,
|
|
"limit_up_count": s.limit_up_count,
|
|
"days_continuous": s.days_continuous,
|
|
"heat_score": s.heat_score,
|
|
"stage": s.stage,
|
|
}
|
|
for s in sectors[:limit]
|
|
]
|