From da1470d4b361de19985f2479156568d9118490f4 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 19 Feb 2025 10:32:58 +0100 Subject: [PATCH 1/3] Added summary row to overview --- .../holdings-table.component.html | 36 +++++++++++++++++++ .../holdings-table.component.ts | 13 +++++++ 2 files changed, 49 insertions(+) diff --git a/libs/ui/src/lib/holdings-table/holdings-table.component.html b/libs/ui/src/lib/holdings-table/holdings-table.component.html index 0fb8b9b0a..b7145970e 100644 --- a/libs/ui/src/lib/holdings-table/holdings-table.component.html +++ b/libs/ui/src/lib/holdings-table/holdings-table.component.html @@ -16,6 +16,7 @@ [tooltip]="element.name" /> + @@ -42,6 +43,7 @@ {{ element.symbol }} + Total @@ -66,6 +68,7 @@ /> + + + + + + + + +
+ +
+
@@ -194,6 +216,15 @@ /> + +
+ +
+
@@ -213,6 +244,11 @@ }) " > + diff --git a/libs/ui/src/lib/holdings-table/holdings-table.component.ts b/libs/ui/src/lib/holdings-table/holdings-table.component.ts index 7aa40e9f9..6c3a63029 100644 --- a/libs/ui/src/lib/holdings-table/holdings-table.component.ts +++ b/libs/ui/src/lib/holdings-table/holdings-table.component.ts @@ -70,6 +70,10 @@ export class GfHoldingsTableComponent implements OnChanges, OnDestroy { public isLoading = true; public routeQueryParams: Subscription; + protected totalValue = 0; + protected totalChange = 0; + protected totalChangePercentage = 0; + private unsubscribeSubject = new Subject(); public ngOnChanges() { @@ -93,6 +97,15 @@ export class GfHoldingsTableComponent implements OnChanges, OnDestroy { this.dataSource = new MatTableDataSource(this.holdings); this.dataSource.paginator = this.paginator; this.dataSource.sort = this.sort; + this.totalValue = this.dataSource.data.reduce( + (sum, current) => sum + current.valueInBaseCurrency, + 0 + ); + this.totalChange = this.dataSource.data.reduce( + (sum, current) => sum + current.netPerformancePercentWithCurrencyEffect, + 0 + ); + this.totalChangePercentage = (this.totalChange / this.totalValue) * 100; if (this.holdings) { this.isLoading = false; From b72316817e43ea0da6676f1dea52b61f73100a61 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 19 Feb 2025 10:53:03 +0100 Subject: [PATCH 2/3] Extend Datarange options --- libs/common/src/lib/calculation-helper.ts | 10 ++++++++++ libs/ui/src/lib/assistant/assistant.component.ts | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libs/common/src/lib/calculation-helper.ts b/libs/common/src/lib/calculation-helper.ts index 4292f2383..fd3e69050 100644 --- a/libs/common/src/lib/calculation-helper.ts +++ b/libs/common/src/lib/calculation-helper.ts @@ -7,6 +7,7 @@ import { startOfWeek, startOfYear, subDays, + subMonths, subYears } from 'date-fns'; import { isNumber } from 'lodash'; @@ -55,12 +56,21 @@ export function getIntervalFromDateRange( subDays(startOfWeek(resetHours(new Date()), { weekStartsOn: 1 }), 1) ]); break; + case '1w': + startDate = max([startDate, subDays(resetHours(new Date()), 7)]); + break; case 'ytd': startDate = max([ startDate, subDays(startOfYear(resetHours(new Date())), 1) ]); break; + case '1m': + startDate = max([startDate, subMonths(resetHours(new Date()), 1)]); + break; + case '3m': + startDate = max([startDate, subMonths(resetHours(new Date()), 3)]); + break; case '1y': startDate = max([startDate, subYears(resetHours(new Date()), 1)]); break; diff --git a/libs/ui/src/lib/assistant/assistant.component.ts b/libs/ui/src/lib/assistant/assistant.component.ts index e6fdf93d7..1d94ce876 100644 --- a/libs/ui/src/lib/assistant/assistant.component.ts +++ b/libs/ui/src/lib/assistant/assistant.component.ts @@ -222,10 +222,23 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { label: $localize`Week to date` + ' (' + $localize`WTD` + ')', value: 'wtd' }, + { + label: '1 ' + $localize`Week` + ' (' + $localize`1W` + ')', + value: '1w' + }, { label: $localize`Month to date` + ' (' + $localize`MTD` + ')', value: 'mtd' }, + { + label: '1 ' + $localize`Month` + ' (' + $localize`1M` + ')', + value: '1m' + }, + + { + label: '3 ' + $localize`Month` + ' (' + $localize`3M` + ')', + value: '3m' + }, { label: $localize`Year to date` + ' (' + $localize`YTD` + ')', value: 'ytd' From 032b9f7a63d161dcabeb2c385c405d077ab4c401 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 19 Feb 2025 10:59:55 +0100 Subject: [PATCH 3/3] Remove timeweighted performance from frontend --- .../benchmark-comparator.component.ts | 16 +---------- .../analysis/analysis-page.component.ts | 17 +---------- .../portfolio/analysis/analysis-page.html | 28 +------------------ 3 files changed, 3 insertions(+), 58 deletions(-) diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts index 69b61b981..afcb561f6 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts @@ -55,7 +55,6 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { @Input() isLoading: boolean; @Input() locale = getLocale(); @Input() performanceDataItems: LineChartItem[]; - @Input() timeWeightedPerformanceDataItems: LineChartItem[]; @Input() user: User; @Output() benchmarkChanged = new EventEmitter(); @@ -86,10 +85,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { permissions.accessAdminControl ); - if ( - this.performanceDataItems || - this.timeWeightedPerformanceDataItems?.length > 0 - ) { + if (this.performanceDataItems) { this.initialize(); } } @@ -120,16 +116,6 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { }), label: $localize`Portfolio` }, - { - backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, - borderColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, - borderWidth: 2, - borderDash: [5, 5], - data: this.timeWeightedPerformanceDataItems.map(({ date, value }) => { - return { x: parseDate(date).getTime(), y: value }; - }), - label: $localize`Portfolio (time-weighted)` - }, { backgroundColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`, borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`, diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index 4aee9965a..4b9e3ccd6 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -69,7 +69,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { []; public portfolioEvolutionDataLabel = $localize`Investment`; public streaks: PortfolioInvestments['streaks']; - public timeWeightedPerformance: string = 'N'; public top3: PortfolioPosition[]; public unitCurrentStreak: string; public unitLongestStreak: string; @@ -165,12 +164,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { }); } - public onTimeWeightedPerformanceChanged(timeWeightedPerformance: string) { - this.timeWeightedPerformance = timeWeightedPerformance; - - this.update(); - } - public onChangeGroupBy(aMode: GroupBy) { this.mode = aMode; this.fetchDividendsAndInvestments(); @@ -263,9 +256,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { this.dataService .fetchPortfolioPerformance({ filters: this.userService.getFilters(), - range: this.user?.settings?.dateRange, - timeWeightedPerformance: - this.timeWeightedPerformance === 'N' ? false : true + range: this.user?.settings?.dateRange }) .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(({ chart, firstOrderDate, performance }) => { @@ -304,12 +295,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { date, value: netPerformanceInPercentageWithCurrencyEffect }); - if ((this.timeWeightedPerformance ?? 'N') !== 'N') { - this.performanceDataItemsTimeWeightedInPercentage.push({ - date, - value: chart[index].timeWeightedPerformance - }); - } } this.isLoadingInvestmentChart = false; diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html index 491551c13..051334a7f 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html @@ -42,36 +42,10 @@ [colorScheme]="user?.settings?.colorScheme" [isLoading]="isLoadingBenchmarkComparator || isLoadingInvestmentChart" [locale]="user?.settings?.locale" - [performanceDataItems]=" - timeWeightedPerformance === 'O' - ? [] - : performanceDataItemsInPercentage - " - [timeWeightedPerformanceDataItems]=" - timeWeightedPerformance === 'N' - ? [] - : performanceDataItemsTimeWeightedInPercentage - " + [performanceDataItems]="performanceDataItemsInPercentage" [user]="user" (benchmarkChanged)="onChangeBenchmark($event)" > -
-
-
- Include time-weighted performance - -
-
-