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
Failed to extract signature
1 changed files with
16 additions and
1 deletions
-
apps/api/src/services/data-provider/moex/moex.service.ts
|
@ -183,6 +183,20 @@ function getYahooSymbolFromMoex(symbol: string): string { |
|
|
return `${symbol}.ME`; |
|
|
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( |
|
|
async function getSecuritySpecification( |
|
|
symbol: string, |
|
|
symbol: string, |
|
@ -366,7 +380,8 @@ export class MoexService implements DataProviderInterface { |
|
|
weight: 1 |
|
|
weight: 1 |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
: null |
|
|
: null, |
|
|
|
|
|
url: await getAssetUrlFromYahoo(this.yahooFinanceService, symbol) |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|