Feature/improve exception handling of current investments in various rules (#3156)
* Improve exception handling * Update changelog
This commit is contained in:
parent
82c78cad6b
commit
38c2baf943
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Improved the usability of the platform management in the admin control panel
|
- Improved the usability of the platform management in the admin control panel
|
||||||
- Improved the usability of the tag management in the admin control panel
|
- Improved the usability of the tag management in the admin control panel
|
||||||
|
- Improved the exception handling of various rules in the _X-ray_ section
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let maxItem;
|
let maxItem: (typeof accounts)[0];
|
||||||
let totalInvestment = 0;
|
let totalInvestment = 0;
|
||||||
|
|
||||||
for (const account of Object.values(accounts)) {
|
for (const account of Object.values(accounts)) {
|
||||||
@ -52,7 +52,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxInvestmentRatio = maxItem.investment / totalInvestment;
|
const maxInvestmentRatio = maxItem?.investment / totalInvestment || 0;
|
||||||
|
|
||||||
if (maxInvestmentRatio > ruleSettings.threshold) {
|
if (maxInvestmentRatio > ruleSettings.threshold) {
|
||||||
return {
|
return {
|
||||||
|
@ -43,7 +43,7 @@ export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule<Setti
|
|||||||
|
|
||||||
const baseCurrencyValueRatio = baseCurrencyItem?.value / totalValue || 0;
|
const baseCurrencyValueRatio = baseCurrencyItem?.value / totalValue || 0;
|
||||||
|
|
||||||
if (maxItem.groupKey !== ruleSettings.baseCurrency) {
|
if (maxItem?.groupKey !== ruleSettings.baseCurrency) {
|
||||||
return {
|
return {
|
||||||
evaluation: `The major part of your current investment is not in your base currency (${(
|
evaluation: `The major part of your current investment is not in your base currency (${(
|
||||||
baseCurrencyValueRatio * 100
|
baseCurrencyValueRatio * 100
|
||||||
|
@ -37,7 +37,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const maxValueRatio = maxItem.value / totalValue;
|
const maxValueRatio = maxItem?.value / totalValue || 0;
|
||||||
|
|
||||||
if (maxValueRatio > ruleSettings.threshold) {
|
if (maxValueRatio > ruleSettings.threshold) {
|
||||||
return {
|
return {
|
||||||
@ -52,7 +52,7 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule<Settings> {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
evaluation: `The major part of your current investment is in ${
|
evaluation: `The major part of your current investment is in ${
|
||||||
maxItem.groupKey
|
maxItem?.groupKey ?? ruleSettings.baseCurrency
|
||||||
} (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${
|
} (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${
|
||||||
ruleSettings.threshold * 100
|
ruleSettings.threshold * 100
|
||||||
}%`,
|
}%`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user