Browse Source

implements feature

pull/5012/head
tobikugel 1 week ago
parent
commit
c91e20e32e
  1. 2
      apps/api/src/app/portfolio/portfolio.service.ts
  2. 9
      apps/api/src/app/user/user.service.ts
  3. 37
      apps/api/src/models/rules/account-cluster-risk/current-investment.ts
  4. 10
      apps/client/src/app/pages/i18n/i18n-page.html

2
apps/api/src/app/portfolio/portfolio.service.ts

@ -1260,6 +1260,8 @@ export class PortfolioService {
[
new AccountClusterRiskCurrentInvestment(
this.exchangeRateDataService,
this.i18nService,
userSettings.language,
accounts
),
new AccountClusterRiskSingleAccount(

9
apps/api/src/app/user/user.service.ts

@ -259,9 +259,12 @@ export class UserService {
(user.Settings.settings as UserSettings).xRayRules = {
AccountClusterRiskCurrentInvestment:
new AccountClusterRiskCurrentInvestment(undefined, {}).getSettings(
user.Settings.settings
),
new AccountClusterRiskCurrentInvestment(
undefined,
undefined,
undefined,
{}
).getSettings(user.Settings.settings),
AccountClusterRiskSingleAccount: new AccountClusterRiskSingleAccount(
undefined,
undefined,

37
apps/api/src/models/rules/account-cluster-risk/current-investment.ts

@ -1,6 +1,7 @@
import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface';
import { Rule } from '@ghostfolio/api/models/rule';
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service';
import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service';
import {
PortfolioDetails,
PortfolioPosition,
@ -12,9 +13,12 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
public constructor(
protected exchangeRateDataService: ExchangeRateDataService,
private i18nService: I18nService,
languageCode: string,
accounts: PortfolioDetails['accounts']
) {
super(exchangeRateDataService, {
languageCode,
key: AccountClusterRiskCurrentInvestment.name
});
@ -56,21 +60,29 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
if (maxInvestmentRatio > ruleSettings.thresholdMax) {
return {
evaluation: `Over ${
ruleSettings.thresholdMax * 100
}% of your current investment is at ${maxItem.name} (${(
maxInvestmentRatio * 100
).toPrecision(3)}%)`,
evaluation: this.i18nService.getTranslation({
id: 'rule.accountClusterRiskCurrentInvestment.false',
languageCode: this.getLanguageCode(),
placeholders: {
maxInvestmentRatio: (maxInvestmentRatio * 100).toPrecision(3),
maxItemName: maxItem.name,
thresholdMax: ruleSettings.thresholdMax * 100
}
}),
value: false
};
}
return {
evaluation: `The major part of your current investment is at ${
maxItem.name
} (${(maxInvestmentRatio * 100).toPrecision(3)}%) and does not exceed ${
ruleSettings.thresholdMax * 100
}%`,
evaluation: this.i18nService.getTranslation({
id: 'rule.accountClusterRiskCurrentInvestment.true',
languageCode: this.getLanguageCode(),
placeholders: {
maxInvestmentRatio: (maxInvestmentRatio * 100).toPrecision(3),
maxItemName: maxItem.name,
thresholdMax: ruleSettings.thresholdMax * 100
}
}),
value: true
};
}
@ -88,7 +100,10 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
}
public getName() {
return 'Investment';
return this.i18nService.getTranslation({
id: 'rule.accountClusterRiskCurrentInvestment',
languageCode: this.getLanguageCode()
});
}
public getSettings({ baseCurrency, xRayRules }: UserSettings): Settings {

10
apps/client/src/app/pages/i18n/i18n-page.html

@ -11,6 +11,16 @@
performance, portfolio, software, stock, trading, wealth, web3
</li>
<li i18n="@@myAccount">My Account</li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment">Investment</li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment.false">
Over $&#123;thresholdMax&#125;% of your current investment is at
$&#123;maxItemName&#125; ($&#123;maxInvestmentRatio&#125;%)
</li>
<li i18n="@@rule.accountClusterRiskCurrentInvestment.true">
The major part of your current investment is at $&#123;maxItemName&#125;
($&#123;maxInvestmentRatio&#125;%) and does not exceed
$&#123;thresholdMax&#125;%
</li>
<li i18n="@@rule.accountClusterRiskSingleAccount">Single Account</li>
<li i18n="@@rule.accountClusterRiskSingleAccount.false">
Your net worth is managed by a single account

Loading…
Cancel
Save