mirror of https://github.com/ghostfolio/ghostfolio
Compare commits
7 Commits
a37a94337b
...
1cc4e50143
| Author | SHA1 | Date |
|---|---|---|
|
|
1cc4e50143 | 2 days ago |
|
|
0fee18908f | 2 days ago |
|
|
98fb0b86af | 2 days ago |
|
|
9493f79f8e | 2 days ago |
|
|
f2c81ada90 | 2 days ago |
|
|
3f14e5ad3a | 2 days ago |
|
|
a7434c9ba7 | 2 days ago |
28 changed files with 1780 additions and 2186 deletions
@ -1,104 +0,0 @@ |
|||||
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 { RuleSettings, UserSettings } from '@ghostfolio/common/interfaces'; |
|
||||
|
|
||||
/** |
|
||||
* @deprecated This rule is deprecated in favor of FeeRatioTotalInvestmentVolume |
|
||||
*/ |
|
||||
export class FeeRatioInitialInvestment extends Rule<Settings> { |
|
||||
private fees: number; |
|
||||
private totalInvestment: number; |
|
||||
|
|
||||
public constructor( |
|
||||
protected exchangeRateDataService: ExchangeRateDataService, |
|
||||
private i18nService: I18nService, |
|
||||
languageCode: string, |
|
||||
totalInvestment: number, |
|
||||
fees: number |
|
||||
) { |
|
||||
super(exchangeRateDataService, { |
|
||||
languageCode, |
|
||||
key: FeeRatioInitialInvestment.name |
|
||||
}); |
|
||||
|
|
||||
this.fees = fees; |
|
||||
this.totalInvestment = totalInvestment; |
|
||||
} |
|
||||
|
|
||||
public evaluate(ruleSettings: Settings) { |
|
||||
const feeRatio = this.totalInvestment |
|
||||
? this.fees / this.totalInvestment |
|
||||
: 0; |
|
||||
|
|
||||
if (feeRatio > ruleSettings.thresholdMax) { |
|
||||
return { |
|
||||
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: this.i18nService.getTranslation({ |
|
||||
id: 'rule.feeRatioInitialInvestment.true', |
|
||||
languageCode: this.getLanguageCode(), |
|
||||
placeholders: { |
|
||||
feeRatio: (feeRatio * 100).toPrecision(3), |
|
||||
thresholdMax: (ruleSettings.thresholdMax * 100).toFixed(2) |
|
||||
} |
|
||||
}), |
|
||||
value: true |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
public getCategoryName() { |
|
||||
return this.i18nService.getTranslation({ |
|
||||
id: 'rule.fees.category', |
|
||||
languageCode: this.getLanguageCode() |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
public getConfiguration() { |
|
||||
return { |
|
||||
threshold: { |
|
||||
max: 0.1, |
|
||||
min: 0, |
|
||||
step: 0.0025, |
|
||||
unit: '%' |
|
||||
}, |
|
||||
thresholdMax: true |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
public getName() { |
|
||||
return this.i18nService.getTranslation({ |
|
||||
id: 'rule.feeRatioInitialInvestment', |
|
||||
languageCode: this.getLanguageCode() |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
public getSettings({ |
|
||||
baseCurrency, |
|
||||
locale, |
|
||||
xRayRules |
|
||||
}: UserSettings): Settings { |
|
||||
return { |
|
||||
baseCurrency, |
|
||||
locale, |
|
||||
isActive: xRayRules?.[this.getKey()]?.isActive ?? true, |
|
||||
thresholdMax: xRayRules?.[this.getKey()]?.thresholdMax ?? 0.01 |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
interface Settings extends RuleSettings { |
|
||||
baseCurrency: string; |
|
||||
thresholdMax: number; |
|
||||
} |
|
||||
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
Loading…
Reference in new issue