--- id: "ET-PFM-001" title: "Arquitectura del Dashboard de Portfolio" type: "Technical Specification" status: "Done" priority: "Alta" epic: "OQI-008" project: "trading-platform" version: "1.0.0" created_date: "2025-12-05" updated_date: "2026-01-04" --- # 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 ```typescript interface PortfolioSummary { totalValue: number; totalCost: number; totalPnL: number; totalPnLPercent: number; dayPnL: number; dayPnLPercent: number; cash: number; investedValue: number; positionsCount: number; } ``` ### Position ```typescript 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 - [RF-PFM-001: Dashboard de Portfolio](../requerimientos/RF-PFM-001-dashboard-portfolio.md) --- *Especificación técnica - Sistema NEXUS*