diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts index 696fe7c5f..233c4bd30 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts @@ -91,6 +91,10 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { public topHoldingsMap: { [name: string]: { name: string; value: number }; }; + public tagHoldings: Holding[]; + public tagHoldingsMap: { + [name: string]: { name: string; value: number }; + }; public totalValueInEtf = 0; public UNKNOWN_KEY = UNKNOWN_KEY; public user: User; @@ -282,6 +286,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { } }; this.topHoldingsMap = {}; + this.tagHoldingsMap = {}; } private initializeAllocationsData() { @@ -417,6 +422,22 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { } } + if (position.tags.length > 0) { + for (const tag of position.tags) { + const { name } = tag; + + if (this.tagHoldingsMap[name]?.value) { + this.tagHoldingsMap[name].value += + position.valueInBaseCurrency ?? 0; + } else { + this.tagHoldingsMap[name] = { + name, + value: position.valueInBaseCurrency ?? 0 + }; + } + } + } + if (position.sectors.length > 0) { for (const sector of position.sectors) { const { name, weight } = sector; @@ -480,6 +501,29 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { }; } + this.tagHoldings = Object.values(this.tagHoldingsMap) + .map(({ name, value }) => { + if (this.hasImpersonationId || this.user.settings.isRestrictedView) { + return { + name, + allocationInPercentage: value, + valueInBaseCurrency: null + }; + } + + return { + name, + allocationInPercentage: + this.portfolioDetails.summary.currentValueInBaseCurrency > 0 + ? value / this.portfolioDetails.summary.currentValueInBaseCurrency + : 0, + valueInBaseCurrency: value + }; + }) + .sort((a, b) => { + return b.allocationInPercentage - a.allocationInPercentage; + }); + this.topHoldings = Object.values(this.topHoldingsMap) .map(({ name, value }) => { if (this.hasImpersonationId || this.user.settings.isRestrictedView) { diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html index f2dff76f3..49f53a02c 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html @@ -327,6 +327,24 @@ 'd-none': !user?.settings?.isExperimentalFeatures }" > + + + + By Tag Holding + @if (user?.subscription?.type === 'Basic') { + + } + + + + + +