|
|
@ -1,20 +1,23 @@ |
|
|
|
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 { UserSettings } from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
|
|
export class FeeRatioInitialInvestment extends Rule<Settings> { |
|
|
|
private fees: number; |
|
|
|
private i18nService = new I18nService(); |
|
|
|
private totalInvestment: number; |
|
|
|
|
|
|
|
public constructor( |
|
|
|
protected exchangeRateDataService: ExchangeRateDataService, |
|
|
|
languageCode: string, |
|
|
|
totalInvestment: number, |
|
|
|
fees: number |
|
|
|
) { |
|
|
|
super(exchangeRateDataService, { |
|
|
|
key: FeeRatioInitialInvestment.name, |
|
|
|
name: 'Fee Ratio' |
|
|
|
languageCode, |
|
|
|
key: FeeRatioInitialInvestment.name |
|
|
|
}); |
|
|
|
|
|
|
|
this.fees = fees; |
|
|
@ -28,17 +31,27 @@ export class FeeRatioInitialInvestment extends Rule<Settings> { |
|
|
|
|
|
|
|
if (feeRatio > ruleSettings.thresholdMax) { |
|
|
|
return { |
|
|
|
evaluation: `The fees do exceed ${ |
|
|
|
ruleSettings.thresholdMax * 100 |
|
|
|
}% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`,
|
|
|
|
evaluation: this.i18nService.getTranslation({ |
|
|
|
id: 'rule.feeRatioInitialInvestment.false', |
|
|
|
languageCode: this.getLanguageCode(), |
|
|
|
placeholders: { |
|
|
|
feeRatio: (ruleSettings.thresholdMax * 100).toFixed(2), |
|
|
|
thresholdMax: (feeRatio * 100).toPrecision(3) |
|
|
|
} |
|
|
|
}), |
|
|
|
value: false |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
evaluation: `The fees do not exceed ${ |
|
|
|
ruleSettings.thresholdMax * 100 |
|
|
|
}% of your initial investment (${(feeRatio * 100).toPrecision(3)}%)`,
|
|
|
|
evaluation: this.i18nService.getTranslation({ |
|
|
|
id: 'rule.feeRatioInitialInvestment.true', |
|
|
|
languageCode: this.getLanguageCode(), |
|
|
|
placeholders: { |
|
|
|
feeRatio: (feeRatio * 100).toPrecision(3), |
|
|
|
thresholdMax: (ruleSettings.thresholdMax * 100).toFixed(2) |
|
|
|
} |
|
|
|
}), |
|
|
|
value: true |
|
|
|
}; |
|
|
|
} |
|
|
@ -55,6 +68,13 @@ export class FeeRatioInitialInvestment extends Rule<Settings> { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public getName() { |
|
|
|
return this.i18nService.getTranslation({ |
|
|
|
id: 'rule.feeRatioInitialInvestment', |
|
|
|
languageCode: this.getLanguageCode() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public getSettings({ baseCurrency, xRayRules }: UserSettings): Settings { |
|
|
|
return { |
|
|
|
baseCurrency, |
|
|
|