From f9e04022f41d68a1409985485b2a5244dc461937 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 18 Oct 2022 21:06:28 +0200 Subject: [PATCH] Remove TWR calculation (#1377) --- .../src/app/portfolio/portfolio-calculator.ts | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index 7ca87994c..90fb31df1 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -900,12 +900,12 @@ export class PortfolioCalculator { let investmentAtStartDate: Big; const investmentValues: { [date: string]: Big } = {}; let lastAveragePrice = new Big(0); - let lastTransactionInvestment = new Big(0); - let lastValueOfInvestmentBeforeTransaction = new Big(0); + // let lastTransactionInvestment = new Big(0); + // let lastValueOfInvestmentBeforeTransaction = new Big(0); let maxTotalInvestment = new Big(0); const netPerformanceValues: { [date: string]: Big } = {}; - let timeWeightedGrossPerformancePercentage = new Big(1); - let timeWeightedNetPerformancePercentage = new Big(1); + // let timeWeightedGrossPerformancePercentage = new Big(1); + // let timeWeightedNetPerformancePercentage = new Big(1); let totalInvestment = new Big(0); let totalInvestmentWithGrossPerformanceFromSell = new Big(0); let totalUnits = new Big(0); @@ -1082,54 +1082,54 @@ export class PortfolioCalculator { .minus(totalInvestmentWithGrossPerformanceFromSell) .plus(grossPerformanceFromSells); - if ( - i > indexOfStartOrder && - !lastValueOfInvestmentBeforeTransaction - .plus(lastTransactionInvestment) - .eq(0) - ) { - const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction - .minus( - lastValueOfInvestmentBeforeTransaction.plus( - lastTransactionInvestment - ) - ) - .div( - lastValueOfInvestmentBeforeTransaction.plus( - lastTransactionInvestment - ) - ); - - timeWeightedGrossPerformancePercentage = - timeWeightedGrossPerformancePercentage.mul( - new Big(1).plus(grossHoldingPeriodReturn) - ); - - const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction - .minus(fees.minus(feesAtStartDate)) - .minus( - lastValueOfInvestmentBeforeTransaction.plus( - lastTransactionInvestment - ) - ) - .div( - lastValueOfInvestmentBeforeTransaction.plus( - lastTransactionInvestment - ) - ); - - timeWeightedNetPerformancePercentage = - timeWeightedNetPerformancePercentage.mul( - new Big(1).plus(netHoldingPeriodReturn) - ); - } + // if ( + // i > indexOfStartOrder && + // !lastValueOfInvestmentBeforeTransaction + // .plus(lastTransactionInvestment) + // .eq(0) + // ) { + // const grossHoldingPeriodReturn = valueOfInvestmentBeforeTransaction + // .minus( + // lastValueOfInvestmentBeforeTransaction.plus( + // lastTransactionInvestment + // ) + // ) + // .div( + // lastValueOfInvestmentBeforeTransaction.plus( + // lastTransactionInvestment + // ) + // ); + + // timeWeightedGrossPerformancePercentage = + // timeWeightedGrossPerformancePercentage.mul( + // new Big(1).plus(grossHoldingPeriodReturn) + // ); + + // const netHoldingPeriodReturn = valueOfInvestmentBeforeTransaction + // .minus(fees.minus(feesAtStartDate)) + // .minus( + // lastValueOfInvestmentBeforeTransaction.plus( + // lastTransactionInvestment + // ) + // ) + // .div( + // lastValueOfInvestmentBeforeTransaction.plus( + // lastTransactionInvestment + // ) + // ); + + // timeWeightedNetPerformancePercentage = + // timeWeightedNetPerformancePercentage.mul( + // new Big(1).plus(netHoldingPeriodReturn) + // ); + // } grossPerformance = newGrossPerformance; - lastTransactionInvestment = transactionInvestment; + // lastTransactionInvestment = transactionInvestment; - lastValueOfInvestmentBeforeTransaction = - valueOfInvestmentBeforeTransaction; + // lastValueOfInvestmentBeforeTransaction = + // valueOfInvestmentBeforeTransaction; if (order.itemType === 'start') { feesAtStartDate = fees; @@ -1149,11 +1149,11 @@ export class PortfolioCalculator { } } - timeWeightedGrossPerformancePercentage = - timeWeightedGrossPerformancePercentage.minus(1); + // timeWeightedGrossPerformancePercentage = + // timeWeightedGrossPerformancePercentage.minus(1); - timeWeightedNetPerformancePercentage = - timeWeightedNetPerformancePercentage.minus(1); + // timeWeightedNetPerformancePercentage = + // timeWeightedNetPerformancePercentage.minus(1); const totalGrossPerformance = grossPerformance.minus( grossPerformanceAtStartDate