/** * 组合/持仓/交易类型定义(与后端 DTO 对齐) */ // 货币类型 export type CurrencyCode = 'CNY' | 'USD' | 'HKD' | 'EUR' | 'GBP' | 'JPY' | 'SGD' | 'AUD'; // 资产类型 export type AssetType = 'Stock' | 'Crypto' | 'Fund' | 'ETF'; // ===== 创建组合 ===== export interface StockItem { name?: string; code?: string; price: number; amount: number; date?: string; currency?: string; assetType: AssetType; } export interface CreatePortfolioRequest { name?: string; strategyId?: string; currency?: string; stocks?: StockItem[]; } export interface CreatePortfolioResponse { id?: string; totalValue: number; returnRate: number; currency?: string; createdAt?: string; } // ===== 更新组合 ===== export interface UpdatePortfolioRequest { name?: string; strategyId?: string; status?: string; } // ===== 组合列表 ===== export interface PortfolioListItem { id?: string; name?: string; tags?: string; status?: string; statusType?: string; iconChar?: string; iconBgClass?: string; iconTextClass?: string; value: number; currency?: string; returnRate: number; returnType?: string; todayProfit: number; todayProfitCurrency?: string; } export interface GetPortfoliosResponse { items?: PortfolioListItem[]; } // ===== 组合详情 ===== export interface StrategyInfo { id?: string; name?: string; description?: string; } export interface PositionItem { id?: string; stockCode?: string; stockName?: string; symbol?: string; amount: number; averagePrice: number; currentPrice: number; totalValue: number; profit: number; profitRate: number; changeAmount: number; ratio: number; deviationRatio: number; currency?: string; } export interface PortfolioDetailResponse { id?: string; name?: string; currency?: string; status?: string; strategy?: StrategyInfo; portfolioValue: number; totalReturn: number; todayProfit: number; historicalChange: number; dailyVolatility: number; todayProfitCurrency?: string; logicModel?: string; logicModelStatus?: string; logicModelDescription?: string; totalItems: number; totalRatio: number; positions?: PositionItem[]; } // ===== 交易相关 ===== export interface TransactionItem { id?: string; portfolioId?: string; date?: string; time?: string; type?: string; title?: string; stockCode?: string; amount: number; currency?: string; status?: string; remark?: string; } export interface GetTransactionsRequest { portfolioId?: string; limit: number; offset: number; } export interface GetTransactionsResponse { items?: TransactionItem[]; total: number; page: number; pageSize: number; } export interface CreateTransactionRequest { portfolioId?: string; type?: string; stockCode?: string; amount: number; price: number; currency?: string; remark?: string; assetType: AssetType; transactionTime?: string; transactionDate?: string; } export interface CreateTransactionResponse { id?: string; totalAmount: number; status?: string; createdAt?: string; } // ===== 总资产 ===== export interface TotalAssetsResponse { totalValue: number; currency?: string; todayProfit: number; todayProfitCurrency?: string; totalReturnRate: number; } // ===== 净值历史 ===== export interface NavHistoryRequest { startDate?: string; endDate?: string; interval?: string; } export interface NavHistoryItem { date?: string; nav: number; totalValue: number; totalCost: number; dailyReturn: number; cumulativeReturn: number; } export interface NavStatistics { maxReturn: number; minReturn: number; maxDrawdown: number; sharpeRatio: number; volatility: number; totalReturn: number; tradingDays: number; } export interface NavHistoryResponse { portfolioId?: string; currency?: string; navHistory?: NavHistoryItem[]; statistics?: NavStatistics; } export interface BackfillNavRequest { portfolioId?: string; force: boolean; } export interface BackfillNavResponse { portfolioId?: string; recordsCreated: number; startDate?: string; endDate?: string; message?: string; }