|
@ -14,7 +14,7 @@ import { |
|
|
User |
|
|
User |
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import { ToggleOption } from '@ghostfolio/common/types'; |
|
|
import { Market, ToggleOption } from '@ghostfolio/common/types'; |
|
|
import { Account, AssetClass, DataSource } from '@prisma/client'; |
|
|
import { Account, AssetClass, DataSource } from '@prisma/client'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject, Subscription } from 'rxjs'; |
|
|
import { Subject, Subscription } from 'rxjs'; |
|
@ -43,7 +43,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { |
|
|
public hasImpersonationId: boolean; |
|
|
public hasImpersonationId: boolean; |
|
|
public hasPermissionToCreateOrder: boolean; |
|
|
public hasPermissionToCreateOrder: boolean; |
|
|
public markets: { |
|
|
public markets: { |
|
|
[market: string]: { name: string; value: number }; |
|
|
[key in Market]: { name: string; value: number }; |
|
|
}; |
|
|
}; |
|
|
public period = 'current'; |
|
|
public period = 'current'; |
|
|
public periodOptions: ToggleOption[] = [ |
|
|
public periodOptions: ToggleOption[] = [ |
|
@ -164,16 +164,16 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
this.markets = { |
|
|
this.markets = { |
|
|
DEVELOPED_MARKETS: { |
|
|
developedMarkets: { |
|
|
name: 'DEVELOPED_MARKETS', |
|
|
name: 'developedMarkets', |
|
|
value: 0 |
|
|
value: 0 |
|
|
}, |
|
|
}, |
|
|
EMERGING_MARKETS: { |
|
|
emergingMarkets: { |
|
|
name: 'EMERGING_MARKETS', |
|
|
name: 'emergingMarkets', |
|
|
value: 0 |
|
|
value: 0 |
|
|
}, |
|
|
}, |
|
|
OTHER_MARKETS: { |
|
|
otherMarkets: { |
|
|
name: 'OTHER_MARKETS', |
|
|
name: 'otherMarkets', |
|
|
value: 0 |
|
|
value: 0 |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
@ -236,14 +236,14 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { |
|
|
// Prepare analysis data by continents, countries and sectors except for cash
|
|
|
// Prepare analysis data by continents, countries and sectors except for cash
|
|
|
|
|
|
|
|
|
if (position.countries.length > 0) { |
|
|
if (position.countries.length > 0) { |
|
|
this.markets['DEVELOPED_MARKETS'].value += |
|
|
this.markets['developedMarkets'].value += |
|
|
position.markets['DEVELOPED_MARKETS'] * |
|
|
position.markets['developedMarkets'] * |
|
|
(aPeriod === 'original' ? position.investment : position.value); |
|
|
(aPeriod === 'original' ? position.investment : position.value); |
|
|
this.markets['EMERGING_MARKETS'].value += |
|
|
this.markets['emergingMarkets'].value += |
|
|
position.markets['EMERGING_MARKETS'] * |
|
|
position.markets['emergingMarkets'] * |
|
|
(aPeriod === 'original' ? position.investment : position.value); |
|
|
(aPeriod === 'original' ? position.investment : position.value); |
|
|
this.markets['OTHER_MARKETS'].value += |
|
|
this.markets['otherMarkets'].value += |
|
|
position.markets['OTHER_MARKETS'] * |
|
|
position.markets['otherMarkets'] * |
|
|
(aPeriod === 'original' ? position.investment : position.value); |
|
|
(aPeriod === 'original' ? position.investment : position.value); |
|
|
|
|
|
|
|
|
for (const country of position.countries) { |
|
|
for (const country of position.countries) { |
|
@ -323,16 +323,16 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const marketsTotal = |
|
|
const marketsTotal = |
|
|
this.markets['DEVELOPED_MARKETS'].value + |
|
|
this.markets.developedMarkets.value + |
|
|
this.markets['EMERGING_MARKETS'].value + |
|
|
this.markets.emergingMarkets.value + |
|
|
this.markets['OTHER_MARKETS'].value; |
|
|
this.markets.otherMarkets.value; |
|
|
|
|
|
|
|
|
this.markets['DEVELOPED_MARKETS'].value = |
|
|
this.markets.developedMarkets.value = |
|
|
this.markets['DEVELOPED_MARKETS'].value / marketsTotal; |
|
|
this.markets.developedMarkets.value / marketsTotal; |
|
|
this.markets['EMERGING_MARKETS'].value = |
|
|
this.markets.emergingMarkets.value = |
|
|
this.markets['EMERGING_MARKETS'].value / marketsTotal; |
|
|
this.markets.emergingMarkets.value / marketsTotal; |
|
|
this.markets['OTHER_MARKETS'].value = |
|
|
this.markets.otherMarkets.value = |
|
|
this.markets['OTHER_MARKETS'].value / marketsTotal; |
|
|
this.markets.otherMarkets.value / marketsTotal; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onChangePeriod(aValue: string) { |
|
|
public onChangePeriod(aValue: string) { |
|
|