Browse Source
			
			
			Feature/add key to x ray rule (#3248)
			
				* Add key
* Update changelog
			
			
				pull/3252/head
			
			
		 
		
			
				
					
						 Thomas Kaul
					
					2 years ago
						Thomas Kaul
					
					2 years ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: B5690EEEBB952194
						
					
				
			
		
		
		
	
		
			
				 9 changed files with 
25 additions and 
2 deletions
			 
			
		 
		
			
				- 
					
					
					 
					CHANGELOG.md
				
- 
					
					
					 
					apps/api/src/app/portfolio/rules.service.ts
				
- 
					
					
					 
					apps/api/src/models/rule.ts
				
- 
					
					
					 
					apps/api/src/models/rules/account-cluster-risk/current-investment.ts
				
- 
					
					
					 
					apps/api/src/models/rules/account-cluster-risk/single-account.ts
				
- 
					
					
					 
					apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts
				
- 
					
					
					 
					apps/api/src/models/rules/currency-cluster-risk/current-investment.ts
				
- 
					
					
					 
					apps/api/src/models/rules/emergency-fund/emergency-fund-setup.ts
				
- 
					
					
					 
					apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | 
			
		
	
		
			
				
					|  |  |  | - Added support to override the url of an asset profile in the asset profile details dialog of the admin control | 
			
		
	
		
			
				
					|  |  |  | - Added the asset profile icon to the asset profile details dialog of the admin control | 
			
		
	
		
			
				
					|  |  |  | - Added the platform icon to the create or update platform dialog of the admin control | 
			
		
	
		
			
				
					|  |  |  | - Extended the rules in the _X-ray_ section by a `key` | 
			
		
	
		
			
				
					|  |  |  | - Extended the content of the _Self-Hosting_ section by the data providers on the Frequently Asked Questions (FAQ) page | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | ### Changed | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -17,8 +17,16 @@ export class RulesService { | 
			
		
	
		
			
				
					|  |  |  |         return rule.getSettings(aUserSettings)?.isActive; | 
			
		
	
		
			
				
					|  |  |  |       }) | 
			
		
	
		
			
				
					|  |  |  |       .map((rule) => { | 
			
		
	
		
			
				
					|  |  |  |         const evaluationResult = rule.evaluate(rule.getSettings(aUserSettings)); | 
			
		
	
		
			
				
					|  |  |  |         return { ...evaluationResult, name: rule.getName() }; | 
			
		
	
		
			
				
					|  |  |  |         const { evaluation, value } = rule.evaluate( | 
			
		
	
		
			
				
					|  |  |  |           rule.getSettings(aUserSettings) | 
			
		
	
		
			
				
					|  |  |  |         ); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return { | 
			
		
	
		
			
				
					|  |  |  |           evaluation, | 
			
		
	
		
			
				
					|  |  |  |           value, | 
			
		
	
		
			
				
					|  |  |  |           key: rule.getKey(), | 
			
		
	
		
			
				
					|  |  |  |           name: rule.getName() | 
			
		
	
		
			
				
					|  |  |  |         }; | 
			
		
	
		
			
				
					|  |  |  |       }); | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -7,19 +7,27 @@ import { EvaluationResult } from './interfaces/evaluation-result.interface'; | 
			
		
	
		
			
				
					|  |  |  | import { RuleInterface } from './interfaces/rule.interface'; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | export abstract class Rule<T extends RuleSettings> implements RuleInterface<T> { | 
			
		
	
		
			
				
					|  |  |  |   private key: string; | 
			
		
	
		
			
				
					|  |  |  |   private name: string; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   public constructor( | 
			
		
	
		
			
				
					|  |  |  |     protected exchangeRateDataService: ExchangeRateDataService, | 
			
		
	
		
			
				
					|  |  |  |     { | 
			
		
	
		
			
				
					|  |  |  |       key, | 
			
		
	
		
			
				
					|  |  |  |       name | 
			
		
	
		
			
				
					|  |  |  |     }: { | 
			
		
	
		
			
				
					|  |  |  |       key: string; | 
			
		
	
		
			
				
					|  |  |  |       name: string; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     this.key = key; | 
			
		
	
		
			
				
					|  |  |  |     this.name = name; | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   public getKey() { | 
			
		
	
		
			
				
					|  |  |  |     return this.key; | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   public getName() { | 
			
		
	
		
			
				
					|  |  |  |     return this.name; | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -15,6 +15,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> { | 
			
		
	
		
			
				
					|  |  |  |     accounts: PortfolioDetails['accounts'] | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     super(exchangeRateDataService, { | 
			
		
	
		
			
				
					|  |  |  |       key: AccountClusterRiskCurrentInvestment.name, | 
			
		
	
		
			
				
					|  |  |  |       name: 'Investment' | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -11,6 +11,7 @@ export class AccountClusterRiskSingleAccount extends Rule<RuleSettings> { | 
			
		
	
		
			
				
					|  |  |  |     accounts: PortfolioDetails['accounts'] | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     super(exchangeRateDataService, { | 
			
		
	
		
			
				
					|  |  |  |       key: AccountClusterRiskSingleAccount.name, | 
			
		
	
		
			
				
					|  |  |  |       name: 'Single Account' | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -11,6 +11,7 @@ export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule<Setti | 
			
		
	
		
			
				
					|  |  |  |     positions: TimelinePosition[] | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     super(exchangeRateDataService, { | 
			
		
	
		
			
				
					|  |  |  |       key: CurrencyClusterRiskBaseCurrencyCurrentInvestment.name, | 
			
		
	
		
			
				
					|  |  |  |       name: 'Investment: Base Currency' | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -11,6 +11,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> { | 
			
		
	
		
			
				
					|  |  |  |     positions: TimelinePosition[] | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     super(exchangeRateDataService, { | 
			
		
	
		
			
				
					|  |  |  |       key: CurrencyClusterRiskCurrentInvestment.name, | 
			
		
	
		
			
				
					|  |  |  |       name: 'Investment' | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -11,6 +11,7 @@ export class EmergencyFundSetup extends Rule<Settings> { | 
			
		
	
		
			
				
					|  |  |  |     emergencyFund: number | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     super(exchangeRateDataService, { | 
			
		
	
		
			
				
					|  |  |  |       key: EmergencyFundSetup.name, | 
			
		
	
		
			
				
					|  |  |  |       name: 'Emergency Fund: Set up' | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -13,6 +13,7 @@ export class FeeRatioInitialInvestment extends Rule<Settings> { | 
			
		
	
		
			
				
					|  |  |  |     fees: number | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |     super(exchangeRateDataService, { | 
			
		
	
		
			
				
					|  |  |  |       key: FeeRatioInitialInvestment.name, | 
			
		
	
		
			
				
					|  |  |  |       name: 'Fee Ratio' | 
			
		
	
		
			
				
					|  |  |  |     }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | 
 |