Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/filter out sectors with zero weight in Yahoo Finance data enhancer (#6895)

Thomas Kauldb1cb4e68171
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bbbaaf9028..1995cebd99 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 72136dc046..30ad81c094 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