Browse Source

gather sectordata for mutal funds from YahooFinanc

pull/1295/head
m11tch 3 years ago
parent
commit
0d4636aa0c
  1. 15
      apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts

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

@ -90,7 +90,7 @@ export class YahooFinanceService implements DataProviderInterface {
try {
const symbol = this.convertToYahooFinanceSymbol(aSymbol);
const assetProfile = await yahooFinance.quoteSummary(symbol, {
modules: ['price', 'summaryProfile']
modules: ['price', 'summaryProfile', 'topHoldings']
});
const { assetClass, assetSubClass } = this.parseAssetClass(
@ -132,6 +132,19 @@ export class YahooFinanceService implements DataProviderInterface {
}
}
if (assetSubClass == 'MUTUALFUND') {
response.sectors = [];
for (const [id, value] of Object.entries<any>(
assetProfile.topHoldings?.sectorWeightings
)) {
for (const [name, weight] of Object.entries<any>(value))
response.sectors.push({
name: name,
weight: weight
});
}
}
const url = assetProfile.summaryProfile?.website;
if (url) {
response.url = url;

Loading…
Cancel
Save