From c2e367130601f54aff6a0d8c050bed322a5f42ce Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:45:41 +0200 Subject: [PATCH] Fix cryptocurrency symbols with less than 3 characters --- .../yahoo-finance/yahoo-finance.service.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts index bc408ca4d..64d318ac8 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts @@ -58,8 +58,15 @@ export class YahooFinanceService implements DataProviderInterface { * DOGEUSD -> DOGE-USD */ public convertToYahooFinanceSymbol(aSymbol: string) { - if (aSymbol.includes(this.baseCurrency) && aSymbol.length >= 6) { - if (isCurrency(aSymbol.substring(0, aSymbol.length - 3))) { + if ( + aSymbol.includes(this.baseCurrency) && + aSymbol.length > this.baseCurrency.length + ) { + if ( + isCurrency( + aSymbol.substring(0, aSymbol.length - this.baseCurrency.length) + ) + ) { return `${aSymbol}=X`; } else if ( this.cryptocurrencyService.isCryptocurrency(