@ -1,5 +1,6 @@
import { Rule } from '@ghostfolio/api/models/rule' ;
import { Rule } from '@ghostfolio/api/models/rule' ;
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service' ;
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' ;
import { UserSettings } from '@ghostfolio/common/interfaces' ;
import { Settings } from './interfaces/rule-settings.interface' ;
import { Settings } from './interfaces/rule-settings.interface' ;
@ -10,10 +11,13 @@ export class RegionalMarketClusterRiskEmergingMarkets extends Rule<Settings> {
public constructor (
public constructor (
protected exchangeRateDataService : ExchangeRateDataService ,
protected exchangeRateDataService : ExchangeRateDataService ,
private i18nService : I18nService ,
languageCode : string ,
currentValueInBaseCurrency : number ,
currentValueInBaseCurrency : number ,
emergingMarketsValueInBaseCurrency : number
emergingMarketsValueInBaseCurrency : number
) {
) {
super ( exchangeRateDataService , {
super ( exchangeRateDataService , {
languageCode ,
key : RegionalMarketClusterRiskEmergingMarkets.name
key : RegionalMarketClusterRiskEmergingMarkets.name
} ) ;
} ) ;
@ -30,26 +34,40 @@ export class RegionalMarketClusterRiskEmergingMarkets extends Rule<Settings> {
if ( emergingMarketsValueRatio > ruleSettings . thresholdMax ) {
if ( emergingMarketsValueRatio > ruleSettings . thresholdMax ) {
return {
return {
evaluation : ` The Emerging Markets contribution of your current investment ( ${ ( emergingMarketsValueRatio * 100 ) . toPrecision ( 3 ) } %) exceeds ${ (
evaluation : this.i18nService.getTranslation ( {
ruleSettings . thresholdMax * 100
id : 'rule.regionalMarketClusterRiskEmergingMarkets.false.max' ,
) . toPrecision ( 3 ) } % ` ,
languageCode : this.getLanguageCode ( ) ,
placeholders : {
thresholdMax : ( ruleSettings . thresholdMax * 100 ) . toPrecision ( 3 ) ,
valueRatio : ( emergingMarketsValueRatio * 100 ) . toPrecision ( 3 )
}
} ) ,
value : false
value : false
} ;
} ;
} else if ( emergingMarketsValueRatio < ruleSettings . thresholdMin ) {
} else if ( emergingMarketsValueRatio < ruleSettings . thresholdMin ) {
return {
return {
evaluation : ` The Emerging Markets contribution of your current investment ( ${ ( emergingMarketsValueRatio * 100 ) . toPrecision ( 3 ) } %) is below ${ (
evaluation : this.i18nService.getTranslation ( {
ruleSettings . thresholdMin * 100
id : 'rule.regionalMarketClusterRiskEmergingMarkets.false.min' ,
) . toPrecision ( 3 ) } % ` ,
languageCode : this.getLanguageCode ( ) ,
placeholders : {
thresholdMin : ( ruleSettings . thresholdMin * 100 ) . toPrecision ( 3 ) ,
valueRatio : ( emergingMarketsValueRatio * 100 ) . toPrecision ( 3 )
}
} ) ,
value : false
value : false
} ;
} ;
}
}
return {
return {
evaluation : ` The Emerging Markets contribution of your current investment ( ${ ( emergingMarketsValueRatio * 100 ) . toPrecision ( 3 ) } %) is within the range of ${ (
evaluation : this.i18nService.getTranslation ( {
ruleSettings . thresholdMin * 100
id : 'rule.regionalMarketClusterRiskEmergingMarkets.true' ,
) . toPrecision (
languageCode : this.getLanguageCode ( ) ,
3
placeholders : {
) } % and $ { ( ruleSettings . thresholdMax * 100 ) . toPrecision ( 3 ) } % ` ,
thresholdMax : ( ruleSettings . thresholdMax * 100 ) . toPrecision ( 3 ) ,
thresholdMin : ( ruleSettings . thresholdMin * 100 ) . toPrecision ( 3 ) ,
valueRatio : ( emergingMarketsValueRatio * 100 ) . toPrecision ( 3 )
}
} ) ,
value : true
value : true
} ;
} ;
}
}
@ -72,7 +90,10 @@ export class RegionalMarketClusterRiskEmergingMarkets extends Rule<Settings> {
}
}
public getName() {
public getName() {
return 'Emerging Markets' ;
return this . i18nService . getTranslation ( {
id : 'rule.regionalMarketClusterRiskEmergingMarkets' ,
languageCode : this.getLanguageCode ( )
} ) ;
}
}
public getSettings ( { baseCurrency , xRayRules } : UserSettings ) : Settings {
public getSettings ( { baseCurrency , xRayRules } : UserSettings ) : Settings {