Browse Source

Improve transaction investment

pull/1378/head
Thomas 3 years ago
parent
commit
1a2243cfb7
  1. 9
      apps/api/src/app/portfolio/portfolio-calculator.ts

9
apps/api/src/app/portfolio/portfolio-calculator.ts

@ -1027,9 +1027,12 @@ export class PortfolioCalculator {
valueAtStartDate = valueOfInvestmentBeforeTransaction;
}
const transactionInvestment = order.quantity
.mul(order.unitPrice)
.mul(this.getFactor(order.type));
const transactionInvestment =
order.type === 'BUY'
? order.quantity.mul(order.unitPrice).mul(this.getFactor(order.type))
: order.quantity
.mul(totalInvestment.div(totalUnits))
.mul(this.getFactor(order.type));
totalInvestment = totalInvestment.plus(transactionInvestment);

Loading…
Cancel
Save