"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { apiGet } from "@/lib/api"; import type { Stock, FactorMeta } from "@/lib/types"; import { PageHeader, Card, Metric, Banner, Loading } from "@/components/ui"; import { Icon as Ic } from "@/components/icons"; interface LoadState { stocks: number | null; factors: number | null; loading: boolean; error: string; } const LINKS = [ { href: "/factors", title: "因子研究", desc: "查看行情因子目录,勾选运行 IC / RankIC 单因子测试", icon: "flask" as const, tone: "quick-card--violet", }, { href: "/factors/compose", title: "因子组合", desc: "多因子 z-score 叠加打分,回测 Top N 等权选股组合", icon: "layers" as const, tone: "quick-card--pos", }, { href: "/backtest", title: "选股回测", desc: "单因子完整回测:净值 / 回撤 / 月度收益 / 持仓", icon: "gauge" as const, tone: "quick-card--warn", }, { href: "/selection", title: "股票筛选", desc: "因子评分 TopN 或条件选股,支持当前/历史时点,结果可解释", icon: "target" as const, tone: "quick-card--violet", }, { href: "/signals", title: "交易信号", desc: "按评分排名 + 趋势规则输出 BUY / WATCH / SELL 及理由", icon: "scale" as const, tone: "quick-card--pos", }, { href: "/stocks", title: "股票池", desc: "浏览本地股票基础信息(Tushare 同步,全市场 5556 只)", icon: "candles" as const, tone: "", }, ]; export default function DashboardPage() { const [st, setSt] = useState({ stocks: null, factors: null, loading: true, error: "", }); useEffect(() => { let alive = true; Promise.all([apiGet("/stocks?limit=500"), apiGet("/factors")]) .then(([stocks, factors]) => { if (!alive) return; setSt({ stocks: stocks.length, factors: factors.length, loading: false, error: "", }); }) .catch((e: Error) => { if (!alive) return; setSt({ stocks: null, factors: null, loading: false, error: e.message }); }); return () => { alive = false; }; }, []); return ( <> {st.error ? ( 后端不可达:{st.error}。请确认 FastAPI 服务已启动(scripts/dev.sh start)。 ) : null} {st.loading ? (
) : (
)}
{LINKS.map((l) => (

{l.title}

{l.desc}

进入
))}
  • 因子/回测请求经 异步 Job 后台执行并自动归档为实验(Experiment),可在「实验」页查看与复跑。
  • 数据底座为MySQL + Parquet:行情经 sync daily --resume 增量同步; 新浪数据仅在「两边一致」校验通过后兜底入库(source=sina)。
  • 研究默认禁止未来函数:财务按公告日可见、因子按已披露数据计算;回测含手续费 / 印花税 / 涨跌停等近似约束(如实标注)。
); }