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 = (
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

Loading…
Cancel
Save