Browse Source

Filter out sectors with zero weight

pull/6895/head
Thomas Kaul 1 week ago
parent
commit
91928b7919
  1. 20
      apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

20
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 = ( response.sectors = (assetProfile.topHoldings?.sectorWeightings ?? [])
assetProfile.topHoldings?.sectorWeightings ?? [] .flatMap((sectorWeighting) => {
).flatMap((sectorWeighting) => { return Object.entries(sectorWeighting).map(([sector, weight]) => {
return Object.entries(sectorWeighting).map(([sector, weight]) => { return {
return { name: this.parseSector(sector),
name: this.parseSector(sector), weight: weight as number
weight: weight as number };
}; });
})
.filter(({ weight }) => {
return weight > 0;
}); });
});
} else if ( } else if (
assetSubClass === 'STOCK' && assetSubClass === 'STOCK' &&
assetProfile.summaryProfile?.country assetProfile.summaryProfile?.country

Loading…
Cancel
Save