A comprehensive Portfolio Analytics Dashboard for the Stellar Dev Dashboard that provides users with professional-grade portfolio insights, visualizations, and performance metrics.
PortfolioAnalytics Dashboard
โ
โโโ ๐ Header Section
โ โโโ Title: "Portfolio Analytics"
โ โโโ Last Update Timestamp
โ โโโ Auto-Refresh Toggle Button
โ โโโ Manual Refresh Button
โ
โโโ ๐ Key Metrics Grid (4-6 cards)
โ โโโ Total Portfolio Value (USD)
โ โโโ 24h Change (% and $)
โ โโโ Diversification Score (0-100)
โ โโโ Risk Level (Low/Medium/High)
โ โโโ Volatility (%) [Desktop]
โ โโโ Sharpe Ratio [Desktop]
โ
โโโ ๐ Charts Section (2-column grid)
โ โโโ Asset Allocation Pie Chart
โ โ โโโ Color-coded segments
โ โ โโโ Percentage labels
โ โ โโโ Interactive tooltips
โ โ โโโ Legend with asset codes
โ โ
โ โโโ Portfolio Value Over Time (Area Chart)
โ โโโ Time range selector (7D/30D/90D/1Y)
โ โโโ Gradient fill
โ โโโ Smooth line interpolation
โ โโโ Date X-axis
โ โโโ USD Y-axis
โ โโโ Hover tooltips
โ
โโโ ๐ Asset Performance Bar Chart
โ โโโ Horizontal layout
โ โโโ 24h change per asset
โ โโโ Color-coded (green/red)
โ โโโ Percentage values
โ
โโโ ๐ Detailed Holdings Table
โ โโโ Columns:
โ โ โโโ Asset (with color dot)
โ โ โโโ Balance
โ โ โโโ Price (USD)
โ โ โโโ Value (USD)
โ โ โโโ Allocation (%)
โ โ โโโ 24h Change (with icon)
โ โโโ Sortable
โ โโโ Hover effects
โ โโโ Mobile responsive
โ
โโโ โ ๏ธ Risk Assessment Panel
โ โโโ Risk Metrics Cards
โ โ โโโ Risk Level
โ โ โโโ Risk Score (0-100)
โ โ โโโ Concentration Risks Count
โ โโโ Risk Factors List
โ โ โโโ Factor description
โ โ โโโ Impact level
โ โ โโโ Visual indicators
โ โโโ Concentrated Assets List
โ โโโ Asset code
โ โโโ Allocation percentage
โ โโโ Risk level badge
โ
โโโ ๐ Performance Metrics Grid [Desktop]
โ โโโ Average Daily Return
โ โโโ Highest Value Asset
โ โโโ Number of Assets
โ
โโโ ๐ Account History Panel
โโโ Description text
โโโ Period Comparison Cards
โโโ Period Start Value & Date
โโโ Current Value & Date
โโโ Period Change (% and $)
Chart Colors (10 colors for assets):
#00d4ff- Cyan (primary)#00ff88- Green#ff6b6b- Red#ffd93d- Yellow#a78bfa- Purple#fb923c- Orange#ec4899- Pink#14b8a6- Teal#f59e0b- Amber#8b5cf6- Violet
Status Colors:
- Green (
#00e676): Positive performance, low risk, good diversification - Red (
#ff1744): Negative performance, high risk - Amber (
#ffb300): Medium risk, moderate diversification - Cyan (
#00e5ff): Primary actions, highlights
- Headings: Syne font, 22px, bold
- Body: System font, 13px
- Numbers: Space Mono (monospace), 13px
- Labels: 11px, uppercase, letter-spacing
- Desktop: 4-column grid for metrics
- Tablet: 3-column grid
- Mobile: 2-column grid
- Spacing: 12-20px gaps
- Border Radius: 8-12px
- Borders: 1px solid with theme colors
Sum of (Asset Balance ร Asset Price) for all assets
Displayed in USD with 2 decimal places
Example: $12,345.67
Percentage: ((Current Value - 24h Ago Value) / 24h Ago Value) ร 100
Absolute: Current Value - 24h Ago Value
Example: +5.23% ($645.12)
Uses Herfindahl-Hirschman Index (HHI)
HHI = ฮฃ(allocation%)ยฒ
Score = ((10000 - HHI) / (10000 - 10000/n)) ร 100
Interpretation:
- 70-100: Well diversified
- 40-69: Moderately diversified
- 0-39: Poorly diversified
Calculated from 3 factors:
- Volatility (0-40 points)
- Diversification (0-30 points)
- Concentration (0-30 points)
Total Score โ Risk Level:
- 0-30: Low
- 31-60: Medium
- 61-100: High
Standard deviation of daily returns
returns[i] = (value[i] - value[i-1]) / value[i-1]
volatility = ฯ(returns) ร 100
Interpretation:
- <5%: Low volatility
- 5-10%: Moderate volatility
- >10%: High volatility
(Portfolio Return - Risk-Free Rate) / Volatility
Default risk-free rate: 4%
Interpretation:
- >1.0: Good risk-adjusted returns
- 0-1.0: Fair returns
- <0: Poor returns
Purpose: Show percentage distribution of portfolio across assets
Features:
- Interactive segments
- Percentage labels on slices
- Hover tooltips with USD values
- Color-coded for easy identification
- Responsive sizing (80px mobile, 100px desktop)
Data Format:
[
{ code: 'XLM', allocation: 45.5, valueUsd: 5465.23 },
{ code: 'USDC', allocation: 30.2, valueUsd: 3624.50 },
{ code: 'BTC', allocation: 24.3, valueUsd: 2916.10 }
]Purpose: Track portfolio value changes over selected time period
Features:
- Multiple time ranges (7D, 30D, 90D, 1Y)
- Gradient fill for visual appeal
- Smooth monotone line
- Grid lines for readability
- Formatted axes (dates and USD)
Data Format:
[
{ timestamp: 1234567890, date: '2024-01-01', value: 10500.50 },
{ timestamp: 1234654290, date: '2024-01-02', value: 10750.25 },
...
]Purpose: Compare 24h performance across all assets
Features:
- Horizontal layout for readability
- Color-coded by performance (green/red)
- Sorted by performance (best to worst)
- Asset codes as labels
- Percentage values
Data Format:
[
{ code: 'XLM', change24h: 5.2, valueUsd: 5465.23 },
{ code: 'USDC', change24h: 0.1, valueUsd: 3624.50 },
{ code: 'BTC', change24h: -2.3, valueUsd: 2916.10 }
]- 4-column metrics grid
- 2-column charts layout
- 6 metric cards visible
- All features enabled
- Larger chart sizes (320px)
- 3-column metrics grid
- 1-column charts layout
- 4 metric cards visible
- All features enabled
- Medium chart sizes (280px)
- 2-column metrics grid
- 1-column charts layout
- 4 metric cards visible
- Reduced font sizes (9px)
- Smaller chart sizes (280px)
- Stacked table columns
- Touch-friendly targets (48ร48px)
User Opens Dashboard
โ
Extract Asset Codes from Balances
โ
Fetch Prices from CoinGecko API
โ
Calculate Portfolio Value (USD)
โ
Fetch Historical Effects from Horizon
โ
Reconstruct Balance History
โ
Calculate Analytics Metrics
โ
Render All Visualizations
โ
Start Auto-Refresh Timer (60s)
โ
Update Prices โ Recalculate โ Re-render
-
Auto-Refresh Toggle
- Click to enable/disable
- Active state: Cyan background
- Inactive state: Grey background
- Icon: Spinning refresh icon when active
-
Manual Refresh Button
- Click to fetch latest prices immediately
- Shows "Refreshing..." during fetch
- Disabled state while loading
- Updates last update timestamp
- Four buttons: 7D, 30D, 90D, 1Y
- Active range: Cyan background
- Inactive ranges: Grey background
- Click to switch time period
- Chart updates immediately
- Hover: Shows tooltip with detailed values
- Mobile: Pinch to zoom, pan to scroll
- Reset: Button appears when zoomed >1.1x
- Hover: Row highlights with background color
- Click: (Could be extended for details view)
- Scroll: Horizontal scroll on mobile
-
No Account Connected
- Shows empty state with info icon
- Message: "Connect an account with balances"
-
No Balances
- Shows empty state
- Message: "No Portfolio Data"
-
Price Fetch Error
- Shows error message
- Allows retry
- Fallbacks to previous data if available
-
Initial Load
- Full-page spinner
- Message: "Loading portfolio data..."
-
Price Refresh
- Button shows "Refreshing..."
- Button disabled during fetch
- No page disruption
-
Historical Data
- Chart area shows spinner
- Other sections remain visible
- Automatic price refresh every 60 seconds
- Manual refresh button for immediate updates
- Last update timestamp display
- Non-intrusive updates (no page reload)
- Concentration risk detection (>25% allocation)
- Multi-factor risk scoring
- Visual risk indicators (color-coded)
- Actionable risk factors
- Touch-friendly charts with gestures
- Responsive grid layouts
- Adaptive font sizes
- Safe area insets for notched devices
- ARIA labels on all interactive elements
- Keyboard navigation support
- Screen reader friendly
- High contrast colors
- Touch targets โฅ48ร48px
The component is architected to support future enhancements:
-
Export Features
- Download charts as images
- Export data as CSV/JSON
- Generate PDF reports
-
Advanced Analytics
- Correlation matrix
- Beta vs benchmarks
- Monte Carlo simulations
- Drawdown analysis
-
Alerts
- Price alerts
- Risk threshold warnings
- Rebalancing notifications
-
Customization
- Drag-and-drop layout
- Custom chart configurations
- Personalized metrics
src/components/dashboard/PortfolioAnalytics.tsx (650+ lines)
src/App.tsx- Route registrationsrc/components/layout/Sidebar.tsx- Navigation link
src/lib/portfolioAnalytics.js- Analytics calculationssrc/lib/priceFeed.js- Price fetchingsrc/lib/stellar.ts- Horizon API integrationsrc/lib/store.ts- State management
src/components/dashboard/Card.tsx- Card and StatCardsrc/components/charts/MobileChartContainer.tsx- Touch gesturessrc/hooks/useResponsive.ts- Breakpoint detection
This document provides a complete overview of the Portfolio Analytics feature implementation.
For technical details, see PORTFOLIO_ANALYTICS_IMPLEMENTATION.md
For PR information, see PR_SUMMARY.md