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