Browse Source

Bugfix/handling of zero buying power in static portfolio analysis rules (#5474)

* Improve handling of 0 buying power

* Update changelog
pull/5471/merge
Thomas Kaul 2 weeks ago
committed by GitHub
parent
commit
15033c0f58
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 1
      apps/api/src/models/rules/asset-class-cluster-risk/equity.ts
  3. 1
      apps/api/src/models/rules/asset-class-cluster-risk/fixed-income.ts
  4. 15
      apps/api/src/models/rules/liquidity/buying-power.ts
  5. 5
      apps/client/src/app/pages/i18n/i18n-page.html

1
CHANGELOG.md

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Improved the handling of `0` buying power in the static portfolio analysis rule: _Liquidity_ (Buying Power)
- Fixed an issue related to the error handling in the data provider status component - Fixed an issue related to the error handling in the data provider status component
## 2.196.0 - 2025-09-04 ## 2.196.0 - 2025-09-04

1
apps/api/src/models/rules/asset-class-cluster-risk/equity.ts

@ -67,6 +67,7 @@ export class AssetClassClusterRiskEquity extends Rule<Settings> {
value: false value: false
}; };
} }
return { return {
evaluation: this.i18nService.getTranslation({ evaluation: this.i18nService.getTranslation({
id: 'rule.assetClassClusterRiskEquity.true', id: 'rule.assetClassClusterRiskEquity.true',

1
apps/api/src/models/rules/asset-class-cluster-risk/fixed-income.ts

@ -67,6 +67,7 @@ export class AssetClassClusterRiskFixedIncome extends Rule<Settings> {
value: false value: false
}; };
} }
return { return {
evaluation: this.i18nService.getTranslation({ evaluation: this.i18nService.getTranslation({
id: 'rule.assetClassClusterRiskFixedIncome.true', id: 'rule.assetClassClusterRiskFixedIncome.true',

15
apps/api/src/models/rules/liquidity/buying-power.ts

@ -22,10 +22,21 @@ export class BuyingPower extends Rule<Settings> {
} }
public evaluate(ruleSettings: Settings) { public evaluate(ruleSettings: Settings) {
if (this.buyingPower < ruleSettings.thresholdMin) { if (this.buyingPower === 0) {
return { return {
evaluation: this.i18nService.getTranslation({ evaluation: this.i18nService.getTranslation({
id: 'rule.liquidityBuyingPower.false', id: 'rule.liquidityBuyingPower.false.zero',
languageCode: this.getLanguageCode(),
placeholders: {
baseCurrency: ruleSettings.baseCurrency
}
}),
value: false
};
} else if (this.buyingPower < ruleSettings.thresholdMin) {
return {
evaluation: this.i18nService.getTranslation({
id: 'rule.liquidityBuyingPower.false.min',
languageCode: this.getLanguageCode(), languageCode: this.getLanguageCode(),
placeholders: { placeholders: {
baseCurrency: ruleSettings.baseCurrency, baseCurrency: ruleSettings.baseCurrency,

5
apps/client/src/app/pages/i18n/i18n-page.html

@ -69,10 +69,13 @@
</li> </li>
<li i18n="@@rule.liquidity.category">Liquidity</li> <li i18n="@@rule.liquidity.category">Liquidity</li>
<li i18n="@@rule.liquidityBuyingPower">Buying Power</li> <li i18n="@@rule.liquidityBuyingPower">Buying Power</li>
<li i18n="@@rule.liquidityBuyingPower.false"> <li i18n="@@rule.liquidityBuyingPower.false.min">
Your buying power is below $&#123;thresholdMin&#125; Your buying power is below $&#123;thresholdMin&#125;
$&#123;baseCurrency&#125; $&#123;baseCurrency&#125;
</li> </li>
<li i18n="@@rule.liquidityBuyingPower.false.zero">
Your buying power is 0 $&#123;baseCurrency&#125;
</li>
<li i18n="@@rule.liquidityBuyingPower.true"> <li i18n="@@rule.liquidityBuyingPower.true">
Your buying power exceeds $&#123;thresholdMin&#125; Your buying power exceeds $&#123;thresholdMin&#125;
$&#123;baseCurrency&#125; $&#123;baseCurrency&#125;

Loading…
Cancel
Save