1. GetHistoricalPriceAsync 返回 decimal? 而非 decimal - 价格获取失败时返回 null 而非 0 2. BackfillNavHistoryInternalAsync 检查价格有效性 - 任何持仓价格获取失败时跳过该日期 - 不写入 totalValue=0 的错误数据 3. MarketDataService 添加 GetWithRetryAsync 方法 - 处理 429 Too Many Requests 限流 - 最多重试 3 次,指数退避
- GetNavHistoryAsync现在会自动检查是否有历史数据 - 无历史数据时自动调用BackfillNavHistoryInternalAsync - 拆分内部回填方法,避免重复验证权限
后端实现: - 新增PortfolioNavHistory实体,记录每日净值、成本、收益率 - 实现IPortfolioNavService接口,支持净值计算和历史回填 - 支持基于交易记录完整计算历史净值(买入卖出都会更新) - 计算统计指标:最大回撤、夏普比率、波动率 新增API: - GET /api/v1/portfolio/{id}/nav-history - 获取净值曲线 - POST /api/v1/portfolio/{id}/nav-history/backfill - 回填历史净值 - POST /api/v1/portfolio/{id}/nav-history/calculate - 计算当日净值 数据库: - 新增portfolio_nav_history表迁移脚本 - 支持组合级别的净值历史记录