mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Add new static portfolio analysis rule: Emergency fund setup * Update changelogpull/2396/head^2
Thomas Kaul
1 year ago
committed by
GitHub
18 changed files with 467 additions and 51 deletions
@ -0,0 +1,46 @@ |
|||||
|
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 { UserSettings } from '@ghostfolio/common/interfaces'; |
||||
|
|
||||
|
export class EmergencyFundSetup extends Rule<Settings> { |
||||
|
private emergencyFund: number; |
||||
|
|
||||
|
public constructor( |
||||
|
protected exchangeRateDataService: ExchangeRateDataService, |
||||
|
emergencyFund: number |
||||
|
) { |
||||
|
super(exchangeRateDataService, { |
||||
|
name: 'Emergency Fund: Set up' |
||||
|
}); |
||||
|
|
||||
|
this.emergencyFund = emergencyFund; |
||||
|
} |
||||
|
|
||||
|
public evaluate(ruleSettings: Settings) { |
||||
|
if (this.emergencyFund > ruleSettings.threshold) { |
||||
|
return { |
||||
|
evaluation: 'An emergency fund has been set up', |
||||
|
value: true |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
evaluation: 'No emergency fund has been set up', |
||||
|
value: false |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
public getSettings(aUserSettings: UserSettings): Settings { |
||||
|
return { |
||||
|
baseCurrency: aUserSettings.baseCurrency, |
||||
|
isActive: true, |
||||
|
threshold: 0 |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
interface Settings extends RuleSettings { |
||||
|
baseCurrency: string; |
||||
|
threshold: number; |
||||
|
} |
Loading…
Reference in new issue