refactor(ui): 重塑 Dashboard 数据流,剔除违规本金反推逻辑,应用顺向盈亏计算

This commit is contained in:
2026-05-02 21:57:19 +08:00
parent 5a056a238c
commit 8b76ec9a6d
3 changed files with 16 additions and 5 deletions
+3
View File
@@ -468,11 +468,13 @@ export async function getPortfolioSummary(includeCleared: boolean = false) {
let totalCnyValue = new Big('0');
let totalPnlCny = new Big('0');
let totalFloatingPnlCny = new Big('0');
let totalCostCny = new Big('0');
for (const pos of positions) {
totalCnyValue = totalCnyValue.plus(new Big(pos.marketValueCny || '0'));
totalPnlCny = totalPnlCny.plus(new Big(pos.accumulatedPnlCny || '0'));
totalFloatingPnlCny = totalFloatingPnlCny.plus(new Big(pos.floatingPnlCny || '0'));
totalCostCny = totalCostCny.plus(new Big(pos.totalCostCny || '0'));
}
const chartData = positions.map((pos, index) => ({
@@ -531,6 +533,7 @@ export async function getPortfolioSummary(includeCleared: boolean = false) {
return {
positions,
totalCnyValue: totalCnyValue.toString(),
totalCostCny: totalCostCny.toString(),
totalPnlCny: totalPnlCny.toString(),
unrealizedPnlCny: totalFloatingPnlCny.toString(),
chartData,