|
@ -468,16 +468,23 @@ export class PortfolioService { |
|
|
let currentValue = new Big(0); |
|
|
let currentValue = new Big(0); |
|
|
let grossPerformance = new Big(0); |
|
|
let grossPerformance = new Big(0); |
|
|
let grossPerformancePercentage = new Big(1); |
|
|
let grossPerformancePercentage = new Big(1); |
|
|
|
|
|
let hasErrors = false; |
|
|
for (const currentPosition of currentPositions.positions) { |
|
|
for (const currentPosition of currentPositions.positions) { |
|
|
currentValue = currentValue.add( |
|
|
currentValue = currentValue.add( |
|
|
new Big(currentPosition.marketPrice).mul(currentPosition.quantity) |
|
|
new Big(currentPosition.marketPrice).mul(currentPosition.quantity) |
|
|
); |
|
|
); |
|
|
grossPerformance = grossPerformance.plus( |
|
|
if (currentPosition.grossPerformance) { |
|
|
currentPosition.grossPerformance |
|
|
hasErrors = true; |
|
|
); |
|
|
grossPerformance = grossPerformance.plus( |
|
|
grossPerformancePercentage = grossPerformancePercentage.mul( |
|
|
currentPosition.grossPerformance |
|
|
currentPosition.grossPerformancePercentage.plus(1) |
|
|
); |
|
|
); |
|
|
} |
|
|
|
|
|
if (currentPosition.grossPerformancePercentage) { |
|
|
|
|
|
hasErrors = true; |
|
|
|
|
|
grossPerformancePercentage = grossPerformancePercentage.mul( |
|
|
|
|
|
currentPosition.grossPerformancePercentage.plus(1) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const currentGrossPerformance = grossPerformance.toNumber(); |
|
|
const currentGrossPerformance = grossPerformance.toNumber(); |
|
@ -485,7 +492,7 @@ export class PortfolioService { |
|
|
.minus(1) |
|
|
.minus(1) |
|
|
.toNumber(); |
|
|
.toNumber(); |
|
|
return { |
|
|
return { |
|
|
hasErrors: currentPositions.hasErrors, |
|
|
hasErrors: currentPositions.hasErrors || hasErrors, |
|
|
performance: { |
|
|
performance: { |
|
|
currentGrossPerformance, |
|
|
currentGrossPerformance, |
|
|
currentGrossPerformancePercent, |
|
|
currentGrossPerformancePercent, |
|
|