mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
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 { PortfolioDetails, UserSettings } from '@ghostfolio/common/interfaces';
|
|
|
|
export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> {
|
|
private accounts: PortfolioDetails['accounts'];
|
|
|
|
public constructor(
|
|
protected exchangeRateDataService: ExchangeRateDataService,
|
|
accounts: PortfolioDetails['accounts']
|
|
) {
|
|
super(exchangeRateDataService, {
|
|
name: 'Single Account'
|
|
});
|
|
|
|
this.accounts = accounts;
|
|
}
|
|
|
|
public evaluate() {
|
|
const accounts: string[] = Object.keys(this.accounts);
|
|
|
|
if (accounts.length === 1) {
|
|
return {
|
|
evaluation: `Your net worth is managed by a single account`,
|
|
value: false
|
|
};
|
|
}
|
|
|
|
return {
|
|
evaluation: `Your net worth is managed by ${accounts.length} accounts`,
|
|
value: true
|
|
};
|
|
}
|
|
|
|
public getSettings(aUserSettings: UserSettings): RuleSettings {
|
|
return {
|
|
isActive: true
|
|
};
|
|
}
|
|
}
|
|
|