| 
						
						
							
								
							
						
						
					 | 
					@ -45,6 +45,7 @@ import type { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  AccountWithValue, | 
					 | 
					 | 
					  AccountWithValue, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  DateRange, | 
					 | 
					 | 
					  DateRange, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  GroupBy, | 
					 | 
					 | 
					  GroupBy, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  Market, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  RequestWithUser, | 
					 | 
					 | 
					  RequestWithUser, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  UserWithSettings | 
					 | 
					 | 
					  UserWithSettings | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} from '@ghostfolio/common/types'; | 
					 | 
					 | 
					} from '@ghostfolio/common/types'; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -581,6 +582,17 @@ export class PortfolioService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      }; | 
					 | 
					 | 
					      }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    let markets: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      [key in Market]: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        name: string; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        value: number; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (withMarkets) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets = this.getAggregatedMarkets(holdings); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    let summary: PortfolioSummary; | 
					 | 
					 | 
					    let summary: PortfolioSummary; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if (withSummary) { | 
					 | 
					 | 
					    if (withSummary) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -602,6 +614,7 @@ export class PortfolioService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      accounts, | 
					 | 
					 | 
					      accounts, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      hasErrors, | 
					 | 
					 | 
					      hasErrors, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      holdings, | 
					 | 
					 | 
					      holdings, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      platforms, | 
					 | 
					 | 
					      platforms, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      summary | 
					 | 
					 | 
					      summary | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    }; | 
					 | 
					 | 
					    }; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -1148,74 +1161,49 @@ export class PortfolioService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public async getReport(impersonationId: string): Promise<PortfolioReport> { | 
					 | 
					 | 
					  public async getReport(impersonationId: string): Promise<PortfolioReport> { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const userId = await this.getUserId(impersonationId, this.request.user.id); | 
					 | 
					 | 
					    const userId = await this.getUserId(impersonationId, this.request.user.id); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const user = await this.userService.user({ id: userId }); | 
					 | 
					 | 
					    const userSettings = <UserSettings>this.request.user.Settings.settings; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					    const userCurrency = this.getUserCurrency(user); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const { activities } = | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      await this.orderService.getOrdersForPortfolioCalculator({ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        userCurrency, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        userId | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      }); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const portfolioCalculator = this.calculatorFactory.createCalculator({ | 
					 | 
					 | 
					    const { accounts, holdings, summary } = await this.getDetails({ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      activities, | 
					 | 
					 | 
					      impersonationId, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					      userId, | 
					 | 
					 | 
					      userId, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      calculationType: PerformanceCalculationType.TWR, | 
					 | 
					 | 
					      withMarkets: true, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      currency: this.request.user.Settings.settings.baseCurrency | 
					 | 
					 | 
					      withSummary: true | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					    }); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    let { totalFeesWithCurrencyEffect, positions, totalInvestment } = | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      await portfolioCalculator.getSnapshot(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    positions = positions.filter((item) => !item.quantity.eq(0)); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const portfolioItemsNow: { [symbol: string]: TimelinePosition } = {}; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    for (const position of positions) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      portfolioItemsNow[position.symbol] = position; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const { accounts } = await this.getValueOfAccountsAndPlatforms({ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      activities, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      portfolioItemsNow, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      userCurrency, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      userId | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    }); | 
					 | 
					 | 
					    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const userSettings = <UserSettings>this.request.user.Settings.settings; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return { | 
					 | 
					 | 
					    return { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      rules: { | 
					 | 
					 | 
					      rules: { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        accountClusterRisk: isEmpty(activities) | 
					 | 
					 | 
					        accountClusterRisk: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					          ? undefined | 
					 | 
					 | 
					          summary.ordersCount > 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					          : await this.rulesService.evaluate( | 
					 | 
					 | 
					            ? await this.rulesService.evaluate( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              [ | 
					 | 
					 | 
					                [ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                new AccountClusterRiskCurrentInvestment( | 
					 | 
					 | 
					                  new AccountClusterRiskCurrentInvestment( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  this.exchangeRateDataService, | 
					 | 
					 | 
					                    this.exchangeRateDataService, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  accounts | 
					 | 
					 | 
					                    accounts | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                ), | 
					 | 
					 | 
					                  ), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                new AccountClusterRiskSingleAccount( | 
					 | 
					 | 
					                  new AccountClusterRiskSingleAccount( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  this.exchangeRateDataService, | 
					 | 
					 | 
					                    this.exchangeRateDataService, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  accounts | 
					 | 
					 | 
					                    accounts | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                ) | 
					 | 
					 | 
					                  ) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              ], | 
					 | 
					 | 
					                ], | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              userSettings | 
					 | 
					 | 
					                userSettings | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            ), | 
					 | 
					 | 
					              ) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        currencyClusterRisk: isEmpty(activities) | 
					 | 
					 | 
					            : undefined, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					          ? undefined | 
					 | 
					 | 
					        currencyClusterRisk: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					          : await this.rulesService.evaluate( | 
					 | 
					 | 
					          summary.ordersCount > 0 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              [ | 
					 | 
					 | 
					            ? await this.rulesService.evaluate( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                new CurrencyClusterRiskBaseCurrencyCurrentInvestment( | 
					 | 
					 | 
					                [ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  this.exchangeRateDataService, | 
					 | 
					 | 
					                  new CurrencyClusterRiskBaseCurrencyCurrentInvestment( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  positions | 
					 | 
					 | 
					                    this.exchangeRateDataService, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                ), | 
					 | 
					 | 
					                    Object.values(holdings) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                new CurrencyClusterRiskCurrentInvestment( | 
					 | 
					 | 
					                  ), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  this.exchangeRateDataService, | 
					 | 
					 | 
					                  new CurrencyClusterRiskCurrentInvestment( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                  positions | 
					 | 
					 | 
					                    this.exchangeRateDataService, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                ) | 
					 | 
					 | 
					                    Object.values(holdings) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              ], | 
					 | 
					 | 
					                  ) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              userSettings | 
					 | 
					 | 
					                ], | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            ), | 
					 | 
					 | 
					                userSettings | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            : undefined, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        emergencyFund: await this.rulesService.evaluate( | 
					 | 
					 | 
					        emergencyFund: await this.rulesService.evaluate( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          [ | 
					 | 
					 | 
					          [ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            new EmergencyFundSetup( | 
					 | 
					 | 
					            new EmergencyFundSetup( | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -1229,8 +1217,8 @@ export class PortfolioService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          [ | 
					 | 
					 | 
					          [ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            new FeeRatioInitialInvestment( | 
					 | 
					 | 
					            new FeeRatioInitialInvestment( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              this.exchangeRateDataService, | 
					 | 
					 | 
					              this.exchangeRateDataService, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					              totalInvestment.toNumber(), | 
					 | 
					 | 
					              summary.committedFunds, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					              totalFeesWithCurrencyEffect.toNumber() | 
					 | 
					 | 
					              summary.fees | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            ) | 
					 | 
					 | 
					            ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          ], | 
					 | 
					 | 
					          ], | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          userSettings | 
					 | 
					 | 
					          userSettings | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -1257,6 +1245,62 @@ export class PortfolioService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    await this.orderService.assignTags({ dataSource, symbol, tags, userId }); | 
					 | 
					 | 
					    await this.orderService.assignTags({ dataSource, symbol, tags, userId }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  private getAggregatedMarkets(holdings: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    [symbol: string]: PortfolioPosition; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  }): { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    [key in Market]: { name: string; value: number }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  } { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    const markets = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      [UNKNOWN_KEY]: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        name: UNKNOWN_KEY, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        value: 0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      developedMarkets: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        name: 'developedMarkets', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        value: 0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      emergingMarkets: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        name: 'emergingMarkets', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        value: 0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      otherMarkets: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        name: 'otherMarkets', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        value: 0 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    for (const [symbol, position] of Object.entries(holdings)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const value = position.valueInBaseCurrency; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (position.assetClass !== AssetClass.LIQUIDITY) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (position.countries.length > 0) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          markets.developedMarkets.value += | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            position.markets.developedMarkets * value; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          markets.emergingMarkets.value += | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            position.markets.emergingMarkets * value; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          markets.otherMarkets.value += position.markets.otherMarkets * value; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          markets[UNKNOWN_KEY].value += value; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    const marketsTotal = | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets.developedMarkets.value + | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets.emergingMarkets.value + | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets.otherMarkets.value + | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets[UNKNOWN_KEY].value; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    markets.developedMarkets.value = | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets.developedMarkets.value / marketsTotal; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    markets.emergingMarkets.value = | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      markets.emergingMarkets.value / marketsTotal; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    markets.otherMarkets.value = markets.otherMarkets.value / marketsTotal; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    markets[UNKNOWN_KEY].value = markets[UNKNOWN_KEY].value / marketsTotal; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    return markets; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  private async getCashPositions({ | 
					 | 
					 | 
					  private async getCashPositions({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    cashDetails, | 
					 | 
					 | 
					    cashDetails, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    userCurrency, | 
					 | 
					 | 
					    userCurrency, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |