diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 041edf4b3..ba911f628 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -1189,19 +1189,6 @@ export class PortfolioService { ).toNumber(); const rules: PortfolioReportResponse['rules'] = { - RegionalMarketClusterRiskNorthAmerica: - summary.ordersCount > 0 - ? await this.rulesService.evaluate( - [ - new RegionalMarketClusterRiskNorthAmerica( - this.exchangeRateDataService, - marketsAdvancedTotalInBaseCurrency, - marketsAdvanced['northAmerica'] - ) - ], - userSettings - ) - : undefined, accountClusterRisk: summary.ordersCount > 0 ? await this.rulesService.evaluate( @@ -1268,6 +1255,19 @@ export class PortfolioService { userSettings ) : undefined, + regionalMarketClusterRisk: + summary.ordersCount > 0 + ? await this.rulesService.evaluate( + [ + new RegionalMarketClusterRiskNorthAmerica( + this.exchangeRateDataService, + marketsAdvancedTotalInBaseCurrency, + marketsAdvanced.northAmerica.valueInBaseCurrency + ) + ], + userSettings + ) + : undefined, emergencyFund: await this.rulesService.evaluate( [ new EmergencyFundSetup( diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index b5c71179f..3609ec0c5 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -13,6 +13,7 @@ import { EconomicMarketClusterRiskDevelopedMarkets } from '@ghostfolio/api/model import { EconomicMarketClusterRiskEmergingMarkets } from '@ghostfolio/api/models/rules/economic-market-cluster-risk/emerging-markets'; import { EmergencyFundSetup } from '@ghostfolio/api/models/rules/emergency-fund/emergency-fund-setup'; import { FeeRatioInitialInvestment } from '@ghostfolio/api/models/rules/fees/fee-ratio-initial-investment'; +import { RegionalMarketClusterRiskNorthAmerica } from '@ghostfolio/api/models/rules/regional-market-cluster-risk/north-america'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service'; import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; @@ -260,6 +261,11 @@ export class UserService { undefined, undefined ).getSettings(user.Settings.settings), + RegionalMarketClusterRisk: new RegionalMarketClusterRiskNorthAmerica( + undefined, + undefined, + undefined + ).getSettings(user.Settings.settings), EmergencyFundSetup: new EmergencyFundSetup( undefined, undefined diff --git a/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts b/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts index d3e47d3af..00064ee1a 100644 --- a/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts +++ b/apps/api/src/models/rules/regional-market-cluster-risk/north-america.ts @@ -2,7 +2,6 @@ import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.in import { Rule } from '@ghostfolio/api/models/rule'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; import { UserSettings } from '@ghostfolio/common/interfaces'; -import { MarketAdvanced } from '@ghostfolio/common/types'; export class RegionalMarketClusterRiskNorthAmerica extends Rule { private currentValueInBaseCurrency: number; @@ -11,19 +10,14 @@ export class RegionalMarketClusterRiskNorthAmerica extends Rule { public constructor( protected exchangeRateDataService: ExchangeRateDataService, currentValueInBaseCurrency: number, - marketsAdvanced: { - id: MarketAdvanced; - valueInBaseCurrency?: number; - valueInPercentage: number; - } + valueInBaseCurrency ) { super(exchangeRateDataService, { key: RegionalMarketClusterRiskNorthAmerica.name, name: 'Regional Markets' }); this.currentValueInBaseCurrency = currentValueInBaseCurrency; - this.regionalMarketNorthAmericaValueInBaseCurrency = - marketsAdvanced.valueInBaseCurrency; + this.regionalMarketNorthAmericaValueInBaseCurrency = valueInBaseCurrency; } public evaluate(ruleSettings: Settings) { @@ -40,7 +34,7 @@ export class RegionalMarketClusterRiskNorthAmerica extends Rule { }; } else if (northAmericaMarketValueRatio < ruleSettings.thresholdMin) { return { - evaluation: `The north america market contribution of your current investment (${(northAmericaMarketValueRatio * 100).toPrecision(3)}%) is below ${( + evaluation: `The north america market contribution of your current investment (${(northAmericaMarketValueRatio * 100).toPrecision(3)}%) is below ${( ruleSettings.thresholdMin * 100 ).toPrecision(3)}%`, value: false @@ -48,7 +42,7 @@ export class RegionalMarketClusterRiskNorthAmerica extends Rule { } return { - evaluation: `The north america market contribution of your current investment (${(northAmericaMarketValueRatio * 100).toPrecision(3)}%) is within the range of ${( + evaluation: `The north america market contribution of your current investment (${(northAmericaMarketValueRatio * 100).toPrecision(3)}%) is within the range of ${( ruleSettings.thresholdMin * 100 ).toPrecision( 3 diff --git a/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.html b/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.html index ceba5f52c..6ec5722b7 100644 --- a/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.html +++ b/apps/client/src/app/pages/portfolio/x-ray/x-ray-page.component.html @@ -144,6 +144,30 @@ (rulesUpdated)="onRulesUpdated($event)" /> +
+

+ Regional Market Cluster Risks + @if (user?.subscription?.type === 'Basic') { + + } +

+ +