Browse Source

Fix performance percentage for 1d

pull/2814/head
Thomas Kaul 2 years ago
parent
commit
3931d369a5
  1. 7
      apps/api/src/app/portfolio/portfolio-calculator.ts

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

@ -1246,7 +1246,7 @@ export class PortfolioCalculator {
if (i > indexOfStartOrder) {
// Only consider periods with an investment for the calculation of
// the time weighted investment
if (totalInvestmentBeforeTransaction.gt(0)) {
if (valueOfInvestmentBeforeTransaction.gt(0)) {
// Calculate the number of days since the previous order
const orderDate = new Date(order.date);
const previousOrderDate = new Date(orders[i - 1].date);
@ -1267,7 +1267,10 @@ export class PortfolioCalculator {
totalInvestmentDays += daysSinceLastOrder;
sumOfTimeWeightedInvestments = sumOfTimeWeightedInvestments.add(
totalInvestmentBeforeTransaction.mul(daysSinceLastOrder)
valueAtStartDate
.minus(investmentAtStartDate)
.plus(totalInvestmentBeforeTransaction)
.mul(daysSinceLastOrder)
);
}

Loading…
Cancel
Save