Browse Source

Harmonize algebraic sign

pull/776/head
Thomas 4 years ago
parent
commit
789af47a78
  1. 34
      apps/api/src/app/portfolio/portfolio.service-new.ts

34
apps/api/src/app/portfolio/portfolio.service-new.ts

@ -810,23 +810,33 @@ export class PortfolioServiceNew {
const hasErrors = currentPositions.hasErrors; const hasErrors = currentPositions.hasErrors;
const currentValue = currentPositions.currentValue.toNumber(); const currentValue = currentPositions.currentValue.toNumber();
const currentGrossPerformance = const currentGrossPerformance = currentPositions.grossPerformance;
currentPositions.grossPerformance.toNumber(); let currentGrossPerformancePercent =
const currentGrossPerformancePercent = currentPositions.grossPerformancePercentage;
currentPositions.grossPerformancePercentage.toNumber(); const currentNetPerformance = currentPositions.netPerformance;
const currentNetPerformance = currentPositions.netPerformance.toNumber(); let currentNetPerformancePercent =
const currentNetPerformancePercent = currentPositions.netPerformancePercentage;
currentPositions.netPerformancePercentage.toNumber();
if (currentGrossPerformance.mul(currentGrossPerformancePercent).lt(0)) {
// If algebraic sign is different, harmonize it
currentGrossPerformancePercent = currentGrossPerformancePercent.mul(-1);
}
if (currentNetPerformance.mul(currentNetPerformancePercent).lt(0)) {
// If algebraic sign is different, harmonize it
currentNetPerformancePercent = currentNetPerformancePercent.mul(-1);
}
return { return {
errors: currentPositions.errors, errors: currentPositions.errors,
hasErrors: currentPositions.hasErrors || hasErrors, hasErrors: currentPositions.hasErrors || hasErrors,
performance: { performance: {
currentGrossPerformance, currentValue,
currentGrossPerformancePercent, currentGrossPerformance: currentGrossPerformance.toNumber(),
currentNetPerformance, currentGrossPerformancePercent:
currentNetPerformancePercent, currentGrossPerformancePercent.toNumber(),
currentValue currentNetPerformance: currentNetPerformance.toNumber(),
currentNetPerformancePercent: currentNetPerformancePercent.toNumber()
} }
}; };
} }

Loading…
Cancel
Save