Feat/correlation heatmap#64
Conversation
table.box attribute doesn't exist in this rich version. table uses default ASCII border instead.
Backend: - agent/backtest/correlation.py: correlation engine (Pearson/Spearman, multi-market loader support, auto market inference from ticker) - agent/api_server.py: +GET /correlation endpoint - agent/tests/test_correlation.py: 9 tests (infer_market + core matrix) Frontend: - frontend/src/pages/Correlation.tsx: new /correlation page - frontend/src/components/charts/CorrelationMatrix.tsx: ECharts heatmap - frontend/src/lib/echarts.ts: register HeatmapChart + VisualMapComponent - frontend/src/router.tsx: +/correlation route - frontend/src/components/layout/Layout.tsx: +nav entry - frontend/src/lib/i18n.tsx: +i18n keys # Conflicts: # frontend/src/components/layout/Layout.tsx # frontend/src/router.tsx
warren618
left a comment
There was a problem hiding this comment.
Thanks for the contribution. The correlation dashboard direction is useful, but this PR is not ready to merge yet. Please address these blockers:
- Frontend CI is failing:
frontend/src/router.tsxhas an extra);after theCorrelationlazy import, causingTS1128: Declaration or statement expected. CorrelationMatrixlabel formatting is incorrect for ECharts heatmap data. The label formatter currently treatsparams.valueas a number, but heatmap values are arrays like[xIndex, yIndex, value]; this will break label rendering. Please read the third tuple element.infer_market()misclassifies HK tickers with leading zeroes such as0700.HK/0005.HKas A-share because the A-share numeric prefix checks run before the.HKsuffix check. HK suffix handling should happen first, and tests should cover leading-zero HK tickers.- The
windowargument in_rolling_correlation_matrix()is effectively ignored. The API returnswindow: days, but the matrix is computed over the full overlapping fetched history instead of the selected trailing window. Please apply the intended trailing window and add a regression test.
After fixing, please rerun the frontend build and the correlation tests. Once CI is green and the above correctness issues are covered, this can be reviewed again.
warren618
left a comment
There was a problem hiding this comment.
Review blockers have been addressed: router build is fixed, heatmap label formatting reads the tuple value, HK leading-zero inference is covered, rolling window is applied and tested, and CI is green.
|
Merged, thanks for the contribution. The follow-up commit addressed the review blockers around router build, heatmap label formatting, HK leading-zero market inference, and rolling-window behavior; CI was green before merge. |
Summary
/correlation) displaying a heatmap of pairwise Pearson/Spearman correlations across multiple assetsGET /correlationendpoint with a reusablecompute_correlation_matrix()engine that auto-infers market (crypto, a-share, us_equity, hk_equity) from ticker symbolsWhy
Vibe-Trading supports multi-asset strategies (crypto, A-shares, US/HK equities) but has no way to visually inspect correlation relationships between assets before building a strategy. This feature closes that gap by giving users a first-pass correlation dashboard — a standard starting point for any quant workflow.
Changes
agent/backtest/correlation.py— Core engine:compute_correlation_matrix(codes, days, method),infer_market(),CROSS_MARKET_LOADERregistry spanning all 4 supported marketsagent/api_server.py—GET /correlationendpoint acceptingcodes,days(7–365),method(pearson|spearman)agent/tests/test_correlation.py— 9 tests: market inference (7 cases) + matrix symmetry + diagonal-is-onefrontend/src/pages/Correlation.tsx— New page: ticker input, method selector, loading/error states, ECharts heatmap, exportfrontend/src/components/charts/CorrelationMatrix.tsx— Reusable heatmap component with dark-mode themingfrontend/src/lib/echarts.ts— RegisteredHeatmapChart+VisualMapComponentfrontend/src/lib/i18n.tsx— Added 6 i18n keys (correlation,correlationDesc,assetCodes,lookbackDays,corrMethod,noCorrelationData)frontend/src/router.tsx— Route{ path: "/correlation", element: wrap(Correlation) }frontend/src/components/layout/Layout.tsx— Nav entry for/correlationTest Plan
pytest --ignore=agent/tests/e2e_backtest --tb=short -q)agent/tests/test_correlation.py, 9 passing)/correlation, enterBTC-USDT,ETH-USDT, click Load → heatmap rendersChecklist
src/agent/,src/session/,src/providers/) without prior discussion