feat: K线增加分钟/小时周期切换,拆分独立KLineCard组件
- 后端:腾讯 mkline 新增 /api/stock/history-minute(m1/m5/m15/m30/m60) - 新组件 kline-card.tsx:自包含周期/折线蜡烛/指标开关与K线数据加载, 切周期只重拉K线,不刷新页面其他模块 - 详情页瘦身为独立模块:K线图 / 今开最高最低昨收 / 每日行情明细互不耦合 - 时间统一按 UTC 解析传 Unix 秒,修复日线 invalid date/N/A 与分钟线时区问题 - 资金流向失败降级为非致命,不再导致整页报错 - vite 构建拆分 recharts/lightweight-charts/router 独立 chunk
This commit is contained in:
@@ -84,6 +84,23 @@ async def stock_history(
|
||||
raise HTTPException(status_code=404, detail="未获取到K线数据")
|
||||
|
||||
|
||||
@router.get("/history-minute", summary="分钟/小时级K线")
|
||||
async def stock_history_minute(
|
||||
code: str = Query(..., description="6位股票代码"),
|
||||
period: str = Query("60", description="周期:m1/m5/m15/m30/m60(60=小时线)"),
|
||||
count: int = Query(320, description="K线数量"),
|
||||
):
|
||||
if not re.match(r"^\d{6}$", code):
|
||||
raise HTTPException(status_code=400, detail="股票代码格式错误,需为6位数字")
|
||||
if period not in ("m1", "m5", "m15", "m30", "m60"):
|
||||
raise HTTPException(status_code=400, detail="period 仅支持 m1/m5/m15/m30/m60")
|
||||
|
||||
klines = await tencent.fetch_history_minute(code, period, count)
|
||||
if not klines:
|
||||
raise HTTPException(status_code=404, detail="未获取到分钟K线数据")
|
||||
return {"data": klines, "count": len(klines), "source": "tencent-minute"}
|
||||
|
||||
|
||||
@router.get("/profile", response_model=dict, summary="公司概况")
|
||||
async def company_profile(code: str = Query(..., description="6位股票代码")):
|
||||
"""获取东方财富F10公司概况数据"""
|
||||
|
||||
Reference in New Issue
Block a user