From 76ff7f7324891db0344de7fe0be12b1120e55b19 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 24 Aug 2024 13:58:18 +0200 Subject: [PATCH] Remove unused values * netPerformancePercentageWithCurrencyEffect * netPerformanceWithCurrencyEffect --- .../calculator/portfolio-calculator.ts | 6 ------ ...aln-buy-and-sell-in-two-activities.spec.ts | 6 ------ ...folio-calculator-baln-buy-and-sell.spec.ts | 4 ---- .../twr/portfolio-calculator-baln-buy.spec.ts | 4 ---- ...ator-btcusd-buy-and-sell-partially.spec.ts | 6 ------ .../twr/portfolio-calculator-fee.spec.ts | 2 -- .../portfolio-calculator-googl-buy.spec.ts | 4 ---- .../twr/portfolio-calculator-item.spec.ts | 2 -- ...ulator-novn-buy-and-sell-partially.spec.ts | 4 ---- ...folio-calculator-novn-buy-and-sell.spec.ts | 4 ---- .../calculator/twr/portfolio-calculator.ts | 2 +- .../src/app/portfolio/portfolio.service.ts | 19 +++++++++++-------- .../src/lib/models/timeline-position.ts | 8 -------- 13 files changed, 12 insertions(+), 59 deletions(-) diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts index b5f598b6c..729547df2 100644 --- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts @@ -394,15 +394,9 @@ export abstract class PortfolioCalculator { netPerformancePercentage: !hasErrors ? (netPerformancePercentage ?? null) : null, - netPerformancePercentageWithCurrencyEffect: !hasErrors - ? (netPerformancePercentageWithCurrencyEffectMap['max'] ?? null) - : null, netPerformancePercentageWithCurrencyEffectMap: !hasErrors ? (netPerformancePercentageWithCurrencyEffectMap ?? null) : null, - netPerformanceWithCurrencyEffect: !hasErrors - ? (netPerformanceWithCurrencyEffect ?? null) - : null, netPerformanceWithCurrencyEffectMap: !hasErrors ? (netPerformanceWithCurrencyEffectMap ?? null) : null, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts index 9f3f33ec0..1ac86faf0 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts @@ -156,15 +156,9 @@ describe('PortfolioCalculator', () => { grossPerformanceWithCurrencyEffect: new Big('-12.6'), investment: new Big('0'), investmentWithCurrencyEffect: new Big('0'), - netPerformance: new Big('-15.8'), - netPerformancePercentage: new Big('-0.05528341497550734703'), - netPerformancePercentageWithCurrencyEffect: new Big( - '-0.0552834149755073478' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('-0.0552834149755073478') }, - netPerformanceWithCurrencyEffect: new Big('-15.8'), netPerformanceWithCurrencyEffectMap: { max: new Big('-15.8') }, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts index 0c1ed1716..54cea8dae 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts @@ -143,13 +143,9 @@ describe('PortfolioCalculator', () => { investmentWithCurrencyEffect: new Big('0'), netPerformance: new Big('-15.8'), netPerformancePercentage: new Big('-0.0552834149755073478'), - netPerformancePercentageWithCurrencyEffect: new Big( - '-0.0552834149755073478' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('-0.0552834149755073478') }, - netPerformanceWithCurrencyEffect: new Big('-15.8'), netPerformanceWithCurrencyEffectMap: { max: new Big('-15.8') }, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy.spec.ts index 4548bc995..e638073eb 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy.spec.ts @@ -128,13 +128,9 @@ describe('PortfolioCalculator', () => { investmentWithCurrencyEffect: new Big('273.2'), netPerformance: new Big('23.05'), netPerformancePercentage: new Big('0.08437042459736456808'), - netPerformancePercentageWithCurrencyEffect: new Big( - '0.08437042459736456808' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('0.08437042459736456808') }, - netPerformanceWithCurrencyEffect: new Big('23.05'), netPerformanceWithCurrencyEffectMap: { '1d': new Big('10.00'), // 2 * (148.9 - 143.9) -> no fees in this time period '1y': new Big('23.05'), // 2 * (148.9 - 136.6) - 1.55 diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts index d3ec0a9cc..e53f83082 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts @@ -162,15 +162,9 @@ describe('PortfolioCalculator', () => { marketPriceInBaseCurrency: 13298.425356, netPerformance: new Big('27172.74').mul(0.97373), netPerformancePercentage: new Big('42.41983590271396609433'), - netPerformancePercentageWithCurrencyEffect: new Big( - '41.64017412624815597854' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('41.73453461766058626637') }, - netPerformanceWithCurrencyEffect: new Big( - '26516.208701400000064086' - ), netPerformanceWithCurrencyEffectMap: { max: new Big('26516.208701400000064086') }, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-fee.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-fee.spec.ts index 7afb9e1c6..4f4c05b13 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-fee.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-fee.spec.ts @@ -121,9 +121,7 @@ describe('PortfolioCalculator', () => { marketPriceInBaseCurrency: 0, netPerformance: null, netPerformancePercentage: null, - netPerformancePercentageWithCurrencyEffect: null, netPerformancePercentageWithCurrencyEffectMap: null, - netPerformanceWithCurrencyEffect: null, netPerformanceWithCurrencyEffectMap: null, quantity: new Big('0'), symbol: '2c463fb3-af07-486e-adb0-8301b3d72141', diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-googl-buy.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-googl-buy.spec.ts index fc757b82b..c7cf7e2b3 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-googl-buy.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-googl-buy.spec.ts @@ -141,13 +141,9 @@ describe('PortfolioCalculator', () => { investmentWithCurrencyEffect: new Big('82.329056'), netPerformance: new Big('26.33').mul(0.8854), netPerformancePercentage: new Big('0.29544434470377019749'), - netPerformancePercentageWithCurrencyEffect: new Big( - '0.24112962014285697628' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('0.24112962014285697628') }, - netPerformanceWithCurrencyEffect: new Big('19.851974'), netPerformanceWithCurrencyEffectMap: { max: new Big('19.851974') }, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-item.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-item.spec.ts index bfae94ad8..a0e62af57 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-item.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-item.spec.ts @@ -121,9 +121,7 @@ describe('PortfolioCalculator', () => { marketPriceInBaseCurrency: 500000, netPerformance: null, netPerformancePercentage: null, - netPerformancePercentageWithCurrencyEffect: null, netPerformancePercentageWithCurrencyEffectMap: null, - netPerformanceWithCurrencyEffect: null, netPerformanceWithCurrencyEffectMap: null, quantity: new Big('0'), symbol: 'dac95060-d4f2-4653-a253-2c45e6fb5cde', diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell-partially.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell-partially.spec.ts index e142255c4..967f8cd1f 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell-partially.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell-partially.spec.ts @@ -143,13 +143,9 @@ describe('PortfolioCalculator', () => { investmentWithCurrencyEffect: new Big('75.80'), netPerformance: new Big('17.68'), netPerformancePercentage: new Big('0.12184460284330327256'), - netPerformancePercentageWithCurrencyEffect: new Big( - '0.12348284960422163588' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('0.12348284960422163588') }, - netPerformanceWithCurrencyEffect: new Big('17.68'), netPerformanceWithCurrencyEffectMap: { max: new Big('17.68') }, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts index 930ef6da7..068246eb6 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts @@ -192,13 +192,9 @@ describe('PortfolioCalculator', () => { investmentWithCurrencyEffect: new Big('0'), netPerformance: new Big('19.86'), netPerformancePercentage: new Big('0.13100263852242744063'), - netPerformancePercentageWithCurrencyEffect: new Big( - '0.13100263852242744063' - ), netPerformancePercentageWithCurrencyEffectMap: { max: new Big('0.13100263852242744063') }, - netPerformanceWithCurrencyEffect: new Big('19.86'), netPerformanceWithCurrencyEffectMap: { max: new Big('19.86') }, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts index 562173d6b..db458fb3c 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts @@ -79,7 +79,7 @@ export class TWRPortfolioCalculator extends PortfolioCalculator { netPerformanceWithCurrencyEffect = netPerformanceWithCurrencyEffect.plus( - currentPosition.netPerformanceWithCurrencyEffect + currentPosition.netPerformancePercentageWithCurrencyEffectMap['max'] ); } else if (!currentPosition.quantity.eq(0)) { hasErrors = true; diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index a26441d0b..8c42d4951 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -423,9 +423,7 @@ export class PortfolioService { marketPrice, netPerformance, netPerformancePercentage, - netPerformancePercentageWithCurrencyEffect, // TODO: Remove? netPerformancePercentageWithCurrencyEffectMap, - netPerformanceWithCurrencyEffect, // TODO: Remove? netPerformanceWithCurrencyEffectMap, quantity, symbol, @@ -803,9 +801,11 @@ export class PortfolioService { netPerformance: position.netPerformance?.toNumber(), netPerformancePercent: position.netPerformancePercentage?.toNumber(), netPerformancePercentWithCurrencyEffect: - position.netPerformancePercentageWithCurrencyEffect?.toNumber(), + position.netPerformancePercentageWithCurrencyEffectMap?.[ + 'max' + ]?.toNumber(), netPerformanceWithCurrencyEffect: - position.netPerformanceWithCurrencyEffect?.toNumber(), + position.netPerformanceWithCurrencyEffectMap?.['max']?.toNumber(), quantity: quantity.toNumber(), value: this.exchangeRateDataService.toCurrency( quantity.mul(marketPrice ?? 0).toNumber(), @@ -986,8 +986,8 @@ export class PortfolioService { investmentWithCurrencyEffect, netPerformance, netPerformancePercentage, - netPerformancePercentageWithCurrencyEffect, - netPerformanceWithCurrencyEffect, + netPerformancePercentageWithCurrencyEffectMap, + netPerformanceWithCurrencyEffectMap, quantity, symbol, timeWeightedInvestment, @@ -1020,9 +1020,12 @@ export class PortfolioService { netPerformancePercentage: netPerformancePercentage?.toNumber() ?? null, netPerformancePercentageWithCurrencyEffect: - netPerformancePercentageWithCurrencyEffect?.toNumber() ?? null, + netPerformancePercentageWithCurrencyEffectMap?.[ + dateRange + ]?.toNumber() ?? null, netPerformanceWithCurrencyEffect: - netPerformanceWithCurrencyEffect?.toNumber() ?? null, + netPerformanceWithCurrencyEffectMap?.[dateRange]?.toNumber() ?? + null, quantity: quantity.toNumber(), timeWeightedInvestment: timeWeightedInvestment?.toNumber(), timeWeightedInvestmentWithCurrencyEffect: diff --git a/libs/common/src/lib/models/timeline-position.ts b/libs/common/src/lib/models/timeline-position.ts index 2345a49fc..f683c0951 100644 --- a/libs/common/src/lib/models/timeline-position.ts +++ b/libs/common/src/lib/models/timeline-position.ts @@ -69,17 +69,9 @@ export class TimelinePosition { @Type(() => Big) netPerformancePercentage: Big; - @Transform(transformToBig, { toClassOnly: true }) - @Type(() => Big) - netPerformancePercentageWithCurrencyEffect: Big; - @Transform(transformToMapOfBig, { toClassOnly: true }) netPerformancePercentageWithCurrencyEffectMap: { [key: DateRange]: Big }; - @Transform(transformToBig, { toClassOnly: true }) - @Type(() => Big) - netPerformanceWithCurrencyEffect: Big; - @Transform(transformToMapOfBig, { toClassOnly: true }) netPerformanceWithCurrencyEffectMap: { [key: DateRange]: Big };