|
@ -7,6 +7,7 @@ import { MAX_TOP_HOLDINGS, UNKNOWN_KEY } from '@ghostfolio/common/config'; |
|
|
import { prettifySymbol } from '@ghostfolio/common/helper'; |
|
|
import { prettifySymbol } from '@ghostfolio/common/helper'; |
|
|
import { |
|
|
import { |
|
|
AssetProfileIdentifier, |
|
|
AssetProfileIdentifier, |
|
|
|
|
|
Holding, |
|
|
HoldingWithParents, |
|
|
HoldingWithParents, |
|
|
PortfolioDetails, |
|
|
PortfolioDetails, |
|
|
PortfolioPosition, |
|
|
PortfolioPosition, |
|
@ -91,6 +92,10 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { |
|
|
public topHoldingsMap: { |
|
|
public topHoldingsMap: { |
|
|
[name: string]: { name: string; value: number }; |
|
|
[name: string]: { name: string; value: number }; |
|
|
}; |
|
|
}; |
|
|
|
|
|
public tagHoldings: Holding[]; |
|
|
|
|
|
public tagHoldingsMap: { |
|
|
|
|
|
[name: string]: { name: string; value: number }; |
|
|
|
|
|
}; |
|
|
public totalValueInEtf = 0; |
|
|
public totalValueInEtf = 0; |
|
|
public UNKNOWN_KEY = UNKNOWN_KEY; |
|
|
public UNKNOWN_KEY = UNKNOWN_KEY; |
|
|
public user: User; |
|
|
public user: User; |
|
@ -282,6 +287,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
this.topHoldingsMap = {}; |
|
|
this.topHoldingsMap = {}; |
|
|
|
|
|
this.tagHoldingsMap = {}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private initializeAllocationsData() { |
|
|
private initializeAllocationsData() { |
|
@ -417,6 +423,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) { |
|
|
if (position.sectors.length > 0) { |
|
|
for (const sector of position.sectors) { |
|
|
for (const sector of position.sectors) { |
|
|
const { name, weight } = sector; |
|
|
const { name, weight } = sector; |
|
@ -480,6 +502,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) |
|
|
this.topHoldings = Object.values(this.topHoldingsMap) |
|
|
.map(({ name, value }) => { |
|
|
.map(({ name, value }) => { |
|
|
if (this.hasImpersonationId || this.user.settings.isRestrictedView) { |
|
|
if (this.hasImpersonationId || this.user.settings.isRestrictedView) { |
|
|