Browse Source

Filter out sectors with zero weight

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

8
apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

@ -218,15 +218,17 @@ 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' &&

Loading…
Cancel
Save