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") }; } public GetPortfoliosResponse GetPortfolios() { // 模拟获取投资组合列表 return new GetPortfoliosResponse { items = new List { new PortfolioListItem { id = "hfea-001", name = "美股全天候杠杆", tags = "HFEA · 季度调仓", status = "监控中", statusType = "green", iconChar = "H", iconBgClass = "bg-green-100", iconTextClass = "text-green-700", value = 156240, currency = "USD", returnRate = 42.82, returnType = "positive" }, new PortfolioListItem { id = "ma-002", name = "纳指双均线趋势", tags = "趋势跟踪 · 日线", status = "等待信号", statusType = "gray", iconChar = "T", iconBgClass = "bg-blue-100", iconTextClass = "text-blue-700", value = 412500, currency = "USD", returnRate = -1.79, returnType = "negative" }, new PortfolioListItem { id = "hk-003", name = "港股价值投资", tags = "价值投资 · 蓝筹", status = "持有中", statusType = "green", iconChar = "H", iconBgClass = "bg-green-100", iconTextClass = "text-green-700", value = 896000, currency = "HKD", returnRate = 12.56, returnType = "positive" } } }; } public TotalAssetsResponse GetTotalAssets() { // 模拟获取总资产情况 return new TotalAssetsResponse { totalValue = 1284592.4, currency = "CNY", todayProfit = 12482, todayProfitCurrency = "CNY", totalReturnRate = 24.82 }; } }