using AssetManager.Models.DTOs; namespace AssetManager.Services; public class PortfolioService : IPortfolioService { public CreatePortfolioResponse CreatePortfolio(CreatePortfolioRequest request) { // 模拟创建投资组合 return new CreatePortfolioResponse { id = "port-" + Guid.NewGuid().ToString().Substring(0, 8), totalValue = request.stocks.Sum(s => s.price * s.amount), returnRate = 0, currency = request.currency, createdAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; } public PortfolioDetailResponse GetPortfolioById(string id) { // 模拟获取投资组合详情 return new PortfolioDetailResponse { id = id, name = "我的投资组合", currency = "CNY", strategy = new StrategyInfo { id = "hfea", name = "HFEA 风险平价策略", description = "高风险高收益策略" }, portfolioValue = 125000, totalReturn = 12500, todayProfit = 2500, todayProfitCurrency = "CNY", positions = new List { new PositionItem { id = "pos-001", stockCode = "UPRO", stockName = "标普500三倍杠杆ETF", amount = 100, averagePrice = 50, currentPrice = 55, totalValue = 5500, profit = 500, profitRate = 10, currency = "USD" } }, transactions = new List { new TransactionItem { id = "trans-001", portfolioId = id, date = "2026-02-24", time = "14:30:00", type = "buy", title = "购买 UPRO", amount = 5000, currency = "USD", status = "completed", remark = "初始建仓" } } }; } public GetTransactionsResponse GetTransactions(string portfolioId, int limit, int offset) { // 模拟获取交易记录 return new GetTransactionsResponse { items = new List { new TransactionItem { id = "trans-001", portfolioId = portfolioId, date = "2026-02-24", time = "14:30:00", type = "buy", title = "购买 UPRO", amount = 5000, currency = "USD", status = "completed", remark = "初始建仓" } }, total = 1, page = offset / limit + 1, pageSize = limit }; } public CreateTransactionResponse CreateTransaction(CreateTransactionRequest request) { // 模拟执行交易 return new CreateTransactionResponse { id = "trans-" + Guid.NewGuid().ToString().Substring(0, 8), totalAmount = request.price * request.amount, status = "processing", createdAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; } }