Browse Source

feat: get an url for asset if yahoo has it

Signed-off-by: Anatoly Popov <me@aensidhe.ru>
pull/4641/head
Anatoly Popov 2 months ago
parent
commit
3db52eaf29
Failed to extract signature
  1. 17
      apps/api/src/services/data-provider/moex/moex.service.ts

17
apps/api/src/services/data-provider/moex/moex.service.ts

@ -183,6 +183,20 @@ function getYahooSymbolFromMoex(symbol: string): string {
return `${symbol}.ME`;
}
async function getAssetUrlFromYahoo(
yahooFinanceService: YahooFinanceService,
symbol: string
): Promise<string> {
try {
const profile = await yahooFinanceService.getAssetProfile({
symbol: getYahooSymbolFromMoex(symbol)
});
return profile?.url;
} catch (e) {
Logger.warn(`Can't get url for symbol ${symbol} from YAHOO, error is ${e}`);
return null;
}
}
async function getSecuritySpecification(
symbol: string,
@ -366,7 +380,8 @@ export class MoexService implements DataProviderInterface {
weight: 1
}
]
: null
: null,
url: await getAssetUrlFromYahoo(this.yahooFinanceService, symbol)
};
}

Loading…
Cancel
Save