Browse Source

Improve transaction investment

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

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

@ -1027,8 +1027,11 @@ export class PortfolioCalculator {
valueAtStartDate = valueOfInvestmentBeforeTransaction;
}
const transactionInvestment = order.quantity
.mul(order.unitPrice)
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