Browse Source

Small fix

pull/679/head
Reto Kaul 3 years ago
parent
commit
8a346f0522
  1. 11
      apps/api/src/app/portfolio/portfolio-calculator-new.ts

11
apps/api/src/app/portfolio/portfolio-calculator-new.ts

@ -398,7 +398,9 @@ export class PortfolioCalculatorNew {
order.unitPrice
);
const transactionInvestment = order.quantity.mul(order.unitPrice);
const transactionInvestment = order.quantity
.mul(order.unitPrice)
.mul(this.getFactor(order.type));
if (
!initialValue &&
@ -426,7 +428,7 @@ export class PortfolioCalculatorNew {
);
totalInvestment = totalInvestment
.plus(transactionInvestment.mul(this.getFactor(order.type)))
.plus(transactionInvestment)
.plus(grossPerformanceFromSell);
lastAveragePrice = totalUnits.eq(0)
@ -481,9 +483,7 @@ export class PortfolioCalculatorNew {
grossPerformance = newGrossPerformance;
lastTransactionInvestment = transactionInvestment.mul(
this.getFactor(order.type)
);
lastTransactionInvestment = transactionInvestment;
lastValueOfInvestmentBeforeTransaction =
valueOfInvestmentBeforeTransaction;
@ -492,6 +492,7 @@ export class PortfolioCalculatorNew {
feesAtStartDate = fees;
grossPerformanceAtStartDate = grossPerformance;
}
}
timeWeightedGrossPerformancePercentage =
timeWeightedGrossPerformancePercentage.sub(1);

Loading…
Cancel
Save