fix(ledger): 补全汇率折算乘数,修复跨币种直接相加导致的盈亏总额失真
This commit is contained in:
@@ -333,8 +333,16 @@ export async function reconstructPortfolioHistory() {
|
||||
|
||||
const metrics = calculateAssetMetrics(assetTxs, cnyPrice);
|
||||
|
||||
totalValueCny = totalValueCny.plus(metrics.marketValue);
|
||||
totalCostCny = totalCostCny.plus(metrics.totalInvested);
|
||||
// 获取资产对人民币的汇率
|
||||
const assetFxRate = new Big(getRate(baseCurrency, 'CNY') || '1');
|
||||
|
||||
// marketValue 已使用 CNY 价格计算,直接取用
|
||||
// totalInvested 基于原始币种价格,需乘以汇率折算为 CNY
|
||||
const posValueCny = new Big(metrics.marketValue);
|
||||
const posCostCny = new Big(metrics.totalInvested).times(assetFxRate);
|
||||
|
||||
totalValueCny = totalValueCny.plus(posValueCny);
|
||||
totalCostCny = totalCostCny.plus(posCostCny);
|
||||
}
|
||||
|
||||
const existing = await db
|
||||
|
||||
Reference in New Issue
Block a user