Skip to content

Commit 4ce72f2

Browse files
committed
feat(frontend): add backtest report library
Signed-off-by: Kenny Zhou <l.w.r.f.42@icloud.com>
1 parent 08cb466 commit 4ce72f2

7 files changed

Lines changed: 468 additions & 2 deletions

File tree

frontend/src/components/layout/Layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useTranslation } from "react-i18next";
22
import { useEffect, useState } from "react";
33
import { Link, Outlet, useLocation, useSearchParams } from "react-router-dom";
4-
import { Activity, BarChart3, Bot, Languages, Moon, Sun, Plus, Trash2, Pencil, MessageSquare, ChevronsLeft, ChevronsRight, Settings, Layers, Loader2 } from "lucide-react";
4+
import { Activity, BarChart3, Bot, FileText, Languages, Moon, Sun, Plus, Trash2, Pencil, MessageSquare, ChevronsLeft, ChevronsRight, Settings, Layers, Loader2 } from "lucide-react";
55
import { cn } from "@/lib/utils";
66
import { useDarkMode } from "@/hooks/useDarkMode";
77
import { api, type SessionItem } from "@/lib/api";
@@ -18,6 +18,7 @@ export function Layout() {
1818
{ to: "/", icon: BarChart3, label: t('layout.home') },
1919
{ to: "/agent", icon: Bot, label: t('layout.agent') },
2020
{ to: "/runtime", icon: Activity, label: t('layout.runtime') },
21+
{ to: "/reports", icon: FileText, label: t('layout.reports') },
2122
{ to: "/alpha-zoo", icon: Layers, label: t('layout.alphaZoo') },
2223
{ to: "/settings", icon: Settings, label: t('layout.settings') },
2324
{ to: "/correlation", icon: BarChart3, label: t('layout.correlation') },

frontend/src/i18n/locales/en.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"home": "Home",
77
"agent": "Agent",
88
"runtime": "Runtime",
9+
"reports": "Reports",
910
"alphaZoo": "Alpha Zoo",
1011
"settings": "Settings",
1112
"correlation": "Correlation Matrix",
@@ -78,6 +79,34 @@
7879
"never": "never",
7980
"ago": "ago"
8081
},
82+
"reports": {
83+
"badge": "Reports",
84+
"title": "Backtest Report Library",
85+
"subtitle": "Browse historical backtest reports, metrics, and run details from one place.",
86+
"refresh": "Refresh",
87+
"searchPlaceholder": "Search run id, prompt, symbol, status...",
88+
"allStatuses": "All statuses",
89+
"startDate": "Start date",
90+
"endDate": "End date",
91+
"sort": "Sort",
92+
"sortNewest": "Newest first",
93+
"sortOldest": "Oldest first",
94+
"sortReturn": "Return high to low",
95+
"sortSharpe": "Sharpe high to low",
96+
"count": "{{shown}} of {{total}} reports",
97+
"unavailable": "Report library unavailable",
98+
"loadError": "Unable to load reports.",
99+
"emptyTitle": "No reports yet",
100+
"emptyBody": "Create a backtest from Agent, then return here to review it.",
101+
"noMatchesTitle": "No matching reports",
102+
"noMatchesBody": "Adjust your search query, status filter, or date range.",
103+
"noPrompt": "No prompt recorded.",
104+
"to": "to",
105+
"return": "Return",
106+
"sharpe": "Sharpe",
107+
"fullReport": "Full Report",
108+
"compare": "Compare"
109+
},
81110
"connection": {
82111
"reconnecting": "Connection lost, reconnecting (attempt {{attempt}})…",
83112
"disconnected": "Connection lost"

frontend/src/i18n/locales/zh-CN.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"home": "首页",
77
"agent": "智能体",
88
"runtime": "运行时",
9+
"reports": "报告",
910
"alphaZoo": "Alpha 动物园",
1011
"settings": "设置",
1112
"correlation": "相关性矩阵",
@@ -78,6 +79,34 @@
7879
"never": "从未",
7980
"ago": ""
8081
},
82+
"reports": {
83+
"badge": "报告",
84+
"title": "回测报告库",
85+
"subtitle": "集中浏览历史回测报告、指标和运行详情。",
86+
"refresh": "刷新",
87+
"searchPlaceholder": "搜索运行 ID、提示词、标的、状态...",
88+
"allStatuses": "全部状态",
89+
"startDate": "开始日期",
90+
"endDate": "结束日期",
91+
"sort": "排序",
92+
"sortNewest": "最新优先",
93+
"sortOldest": "最早优先",
94+
"sortReturn": "收益率从高到低",
95+
"sortSharpe": "夏普从高到低",
96+
"count": "{{shown}} / {{total}} 份报告",
97+
"unavailable": "报告库不可用",
98+
"loadError": "无法加载报告。",
99+
"emptyTitle": "暂无报告",
100+
"emptyBody": "先在智能体中创建一次回测,然后回到这里查看。",
101+
"noMatchesTitle": "没有匹配的报告",
102+
"noMatchesBody": "请调整搜索词、状态筛选或日期范围。",
103+
"noPrompt": "未记录提示词。",
104+
"to": "",
105+
"return": "收益率",
106+
"sharpe": "夏普",
107+
"fullReport": "完整报告",
108+
"compare": "对比"
109+
},
81110
"connection": {
82111
"reconnecting": "连接已断开,正在重连(第 {{attempt}} 次)…",
83112
"disconnected": "连接已断开"

frontend/src/lib/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function appendQueryParam(url: string, key: string, value: string): string {
7373

7474
export const api = {
7575
uploadFile,
76-
listRuns: () => request<RunListItem[]>("/runs"),
76+
listRuns: (limit?: number) => request<RunListItem[]>(`/runs${limit ? `?limit=${encodeURIComponent(String(limit))}` : ""}`),
7777
getRun: (id: string, params: RunDetailParams = {}) => {
7878
const q = new URLSearchParams();
7979
if (params.chart_payload) q.set("chart_payload", params.chart_payload);

0 commit comments

Comments
 (0)