Browse Source

Improve allocation by symbol

pull/326/head
Thomas 4 years ago
parent
commit
cdfa87fe9e
  1. 3
      apps/client/src/app/components/portfolio-proportion-chart/portfolio-proportion-chart.component.ts
  2. 16
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
  3. 3
      apps/client/src/app/pages/portfolio/allocations/allocations-page.html

3
apps/client/src/app/components/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

@ -167,7 +167,8 @@ export class PortfolioProportionChartComponent
// Reuse color // Reuse color
item.color = this.colorMap[symbol]; item.color = this.colorMap[symbol];
} else { } else {
const color = this.getColorPalette()[index]; const color =
this.getColorPalette()[index % this.getColorPalette().length];
// Store color for reuse // Store color for reuse
this.colorMap[symbol] = color; this.colorMap[symbol] = color;

16
apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

@ -49,6 +49,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
public user: User; public user: User;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
/** /**
* @constructor * @constructor
*/ */
@ -148,12 +149,6 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
}; };
this.positionsArray.push(position); this.positionsArray.push(position);
if (this.symbols[symbol] === undefined) {
this.symbols[symbol] = { name: symbol, value: position.value };
} else {
this.symbols[symbol].value += position.value;
}
if (position.assetClass !== AssetClass.CASH) { if (position.assetClass !== AssetClass.CASH) {
// Prepare analysis data by continents, countries and sectors except for cash // Prepare analysis data by continents, countries and sectors except for cash
@ -223,6 +218,15 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
: this.portfolioDetails.holdings[symbol].value; : this.portfolioDetails.holdings[symbol].value;
} }
} }
if (position.assetSubClass !== AssetClass.CASH) {
// Prepare analysis data by symbols except for cash
this.symbols[symbol] = {
name: symbol,
value: aPeriod === 'original' ? position.investment : position.value
};
}
} }
} }

3
apps/client/src/app/pages/portfolio/allocations/allocations-page.html

@ -19,10 +19,9 @@
<mat-card-content> <mat-card-content>
<gf-portfolio-proportion-chart <gf-portfolio-proportion-chart
[baseCurrency]="user?.settings?.baseCurrency" [baseCurrency]="user?.settings?.baseCurrency"
[isInPercent]="hasImpersonationId" [isInPercent]="false"
[keys]="['name']" [keys]="['name']"
[locale]="user?.settings?.locale" [locale]="user?.settings?.locale"
[maxItems]="10"
[positions]="symbols" [positions]="symbols"
></gf-portfolio-proportion-chart> ></gf-portfolio-proportion-chart>
</mat-card-content> </mat-card-content>

Loading…
Cancel
Save