Browse Source

Add missing guard

pull/6279/head
Thomas Kaul 6 days ago
parent
commit
0ff00d8396
  1. 28
      apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

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

@ -206,26 +206,26 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
);
if (['ETF', 'MUTUALFUND'].includes(assetSubClass)) {
response.sectors = [];
for (const sectorWeighting of assetProfile.topHoldings
?.sectorWeightings ?? []) {
for (const [sector, weight] of Object.entries(sectorWeighting)) {
response.sectors.push({
name: this.parseSector(sector),
weight: weight as number
});
}
}
response.holdings = assetProfile.topHoldings.holdings.map(
response.holdings =
assetProfile.topHoldings?.holdings?.map(
({ holdingName, holdingPercent }) => {
return {
name: this.formatName({ longName: holdingName }),
weight: holdingPercent
};
}
);
) ?? [];
response.sectors = (
assetProfile.topHoldings?.sectorWeightings ?? []
).flatMap((sectorWeighting) => {
return Object.entries(sectorWeighting).map(([sector, weight]) => {
return {
name: this.parseSector(sector),
weight: weight as number
};
});
});
} else if (
assetSubClass === 'STOCK' &&
assetProfile.summaryProfile?.country

Loading…
Cancel
Save