5.5 KiB
5.5 KiB
ET-PFM-001: Arquitectura del Dashboard de Portfolio
Épica: OQI-008 - Portfolio Manager Versión: 1.0 Fecha: 2025-12-05 Estado: Planificado
Arquitectura General
┌─────────────────────────────────────────────────────────────────────────┐
│ PORTFOLIO DASHBOARD │
├─────────────────────────────────────────────────────────────────────────┤
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Summary Card │ │ Positions List │ │ Performance │ │
│ │ Component │ │ Component │ │ Chart Component │ │
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
│ └────────────────────┴───────────────────┘ │
│ │ │
│ ┌─────────────────────────────┴─────────────────────────────────────┐ │
│ │ Portfolio Store (Zustand) │ │
│ │ - positions, summary, performance, alerts │ │
│ └─────────────────────────────┬─────────────────────────────────────┘ │
└────────────────────────────────┼────────────────────────────────────────┘
│ API + WebSocket
┌────────────────────────────────┼────────────────────────────────────────┐
│ BACKEND │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ PortfolioService│ │ PositionService │ │ MetricsService │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ │ │
│ ┌─────────────────────────────┴─────────────────────────────────────┐ │
│ │ PostgreSQL + Redis │ │
│ └───────────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────────┘
API Endpoints
| Method | Endpoint | Descripción |
|---|---|---|
| GET | /api/portfolio |
Resumen del portfolio |
| GET | /api/portfolio/positions |
Lista de posiciones |
| GET | /api/portfolio/performance |
Datos de rendimiento |
| GET | /api/portfolio/history |
Historial de valor |
| WS | /portfolio |
Updates en tiempo real |
Modelos de Datos
Portfolio Summary
interface PortfolioSummary {
totalValue: number;
totalCost: number;
totalPnL: number;
totalPnLPercent: number;
dayPnL: number;
dayPnLPercent: number;
cash: number;
investedValue: number;
positionsCount: number;
}
Position
interface Position {
id: string;
symbol: string;
name: string;
quantity: number;
avgCost: number;
currentPrice: number;
marketValue: number;
costBasis: number;
pnl: number;
pnlPercent: number;
dayChange: number;
dayChangePercent: number;
weight: number; // % del portfolio
assetType: 'stock' | 'crypto' | 'etf' | 'bond';
}
WebSocket Events
| Event | Payload | Descripción |
|---|---|---|
portfolio:update |
PortfolioSummary |
Actualización de resumen |
position:update |
Position |
Actualización de posición |
price:update |
{symbol, price} |
Precio actualizado |
Referencias
Especificación técnica - Sistema NEXUS