From db1cb4e68171b4b1be5aebdb452e4a393f04e194 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 21 May 2026 19:53:17 +0300 Subject: [PATCH] Task/filter out sectors with zero weight in Yahoo Finance data enhancer (#6895) * Filter out sectors with zero weight * Update changelog --- CHANGELOG.md | 1 + .../yahoo-finance/yahoo-finance.service.ts | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbbaaf902..1995cebd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the pagination in the activities table of the account detail dialog - Improved the pagination in the activities table of the holding detail dialog - Randomized the placeholder in the assistant +- Filtered out sectors with zero weight for ETF and mutual fund assets in the _Yahoo Finance_ data enhancer - Enabled the _Bull Dashboard_ in the admin control panel without requiring an environment variable (experimental) - Relaxed the URL validation in the asset profile DTOs to accept both `HTTP` and `HTTPS` protocols - Relaxed the URL validation in the platform DTOs to accept both `HTTP` and `HTTPS` protocols diff --git a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts index 72136dc04..30ad81c09 100644 --- a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts @@ -218,16 +218,18 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface { }; }) ?? []; - response.sectors = ( - assetProfile.topHoldings?.sectorWeightings ?? [] - ).flatMap((sectorWeighting) => { - return Object.entries(sectorWeighting).map(([sector, weight]) => { - return { - name: this.parseSector(sector), - weight: weight as number - }; + response.sectors = (assetProfile.topHoldings?.sectorWeightings ?? []) + .flatMap((sectorWeighting) => { + return Object.entries(sectorWeighting).map(([sector, weight]) => { + return { + name: this.parseSector(sector), + weight: weight as number + }; + }); + }) + .filter(({ weight }) => { + return weight > 0; }); - }); } else if ( assetSubClass === 'STOCK' && assetProfile.summaryProfile?.country