"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
Merge PR #1865: keep full trade history alongside lightweight previews
Haozhe Wu223eb8345b4c
diff --cc frontend/src/lib/runReports.tsindex 000000000,ff00cbfe3..2723833eemode 000000,100644..100644--- a/frontend/src/lib/runReports.ts+++ b/frontend/src/lib/runReports.ts@@@ -1,0 -1,34 +1,10 @@@+ import type { RunData } from "@/lib/api";+-function hasItems(value: unknown): boolean {- return Array.isArray(value) && value.length > 0;-}--function hasObjectKeys(value: unknown): boolean {- return !!value && typeof value === "object" && Object.keys(value).length > 0;-}-+ // trade_log is capped at the first 500 rows server-side, which drops the most+ // recent trades of a long run; the full trades.csv rows come alongside it.+ export function runTrades(+ run: Pick<RunData, "artifacts_trades_csv" | "trade_log">,+ ): Array<Record<string, string>> {+ return run.artifacts_trades_csv?.length ? run.artifacts_trades_csv : run.trade_log || [];+ }+-export function isReportWorthyRun(run: Pick<- RunData,- "metrics" | "run_card" | "equity_curve" | "trade_log" | "price_series" | "trade_markers" | "validation" | "artifacts"-> | null | undefined): boolean {- if (!run) return false;- if (hasObjectKeys(run.metrics)) return true;- if (hasObjectKeys(run.run_card)) return true;- if (hasItems(run.equity_curve)) return true;- if (hasItems(run.trade_log)) return true;- if (hasItems(run.trade_markers)) return true;- if (hasObjectKeys(run.validation)) return true;- if (run.price_series && Object.values(run.price_series).some(hasItems)) return true;- return (run.artifacts || []).some((artifact) =>- /(?:metrics|equity|trades|positions|ohlcv|validation|strategy)\.(?:csv|json|pine|py)$/i.test(artifact.name),- );-}diff --cc frontend/src/pages/RunDetail.tsxindex 125a6bccb,e42c524c2..d5a1a3b37--- a/frontend/src/pages/RunDetail.tsx+++ b/frontend/src/pages/RunDetail.tsx@@@ -1004,7 -1018,11 +1018,12 @@@ function TradesTab({ run }: { run: RunDconst [sideFilter, setSideFilter] = useState<"" | "BUY" | "SELL">("");const [symbolFilter, setSymbolFilter] = useState("");const [visibleCount, setVisibleCount] = useState(TRADES_PAGE_SIZE);+ const [sortDesc, setSortDesc] = useState(true);+ const source = runTrades(run);- const ascending = useMemo(() => [...source].sort(compareTradeTime), [source]);- // Reversing the stable ascending order keeps same-time fills in engine order.- const trades = useMemo(() => (sortDesc ? [...ascending].reverse() : ascending), [ascending, sortDesc]);++ // Stable sorting preserves engine order for fills sharing a timestamp.++ const trades = useMemo(() => [...source].sort(++ (a, b) => sortDesc ? compareTradeTime(b, a) : compareTradeTime(a, b),++ ), [source, sortDesc]);if (trades.length === 0) return <div className="p-8 text-muted-foreground text-sm">{i18n.t("runDetail.noTrades")}</div>;const symbols = [...new Set(trades.map((tr) => tr.code).filter(Boolean))];