Skip to content

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

Task/ignore nested ETFs when fetching top holdings in Yahoo Finance service (#6319)

Thomas Kaul8a98c0a3f064
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f91e3c77f..3d3c55eb3c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
+### Changed
+
+- Ignored nested ETFs when fetching top holdings for ETF and mutual fund assets from _Yahoo Finance_
+
### Fixed
- Added the missing `valueInBaseCurrency` to the response of the import activities endpoint
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 c83e355038..72136dc046 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
@@ -207,14 +207,16 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
if (['ETF', 'MUTUALFUND'].includes(assetSubClass)) {
response.holdings =
- assetProfile.topHoldings?.holdings?.map(
- ({ holdingName, holdingPercent }) => {
+ assetProfile.topHoldings?.holdings
+ ?.filter(({ holdingName }) => {
+ return !holdingName?.includes('ETF');
+ })
+ ?.map(({ holdingName, holdingPercent }) => {
return {
name: this.formatName({ longName: holdingName }),
weight: holdingPercent
};
- }
- ) ?? [];
+ }) ?? [];
response.sectors = (
assetProfile.topHoldings?.sectorWeightings ?? []