refactor(ui): 重塑 Dashboard 数据流,剔除违规本金反推逻辑,应用顺向盈亏计算
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user