From 9f545e3e2b918b9fe667406132c51ffe41ef6604 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 20 Dec 2021 21:24:58 +0100 Subject: [PATCH] Feature/add cryptocurrency solana (#563) * Add support for Solana and clean up symbol conversion (SOL1USD) * Update changelog --- CHANGELOG.md | 4 ++++ .../services/cryptocurrency/custom-cryptocurrencies.json | 1 + .../yahoo-finance/yahoo-finance.service.spec.ts | 5 ----- .../data-provider/yahoo-finance/yahoo-finance.service.ts | 9 ++------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec1875f6..82c20733c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added support for cryptocurrency _Solana_ (`SOL-USD`) + ### Fixed - Converted errors to warnings in portfolio calculator diff --git a/apps/api/src/services/cryptocurrency/custom-cryptocurrencies.json b/apps/api/src/services/cryptocurrency/custom-cryptocurrencies.json index 2e1d2e824..80774fb77 100644 --- a/apps/api/src/services/cryptocurrency/custom-cryptocurrencies.json +++ b/apps/api/src/services/cryptocurrency/custom-cryptocurrencies.json @@ -4,5 +4,6 @@ "AVAX": "Avalanche", "MATIC": "Polygon", "SHIB": "Shiba Inu", + "SOL": "Solana", "UNI3": "Uniswap" } diff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.spec.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.spec.ts index c07be06bf..648eb6037 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.spec.ts +++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.spec.ts @@ -14,8 +14,6 @@ jest.mock( return true; case 'DOGEUSD': return true; - case 'SOLUSD': - return true; default: return false; } @@ -55,9 +53,6 @@ describe('YahooFinanceService', () => { expect( await yahooFinanceService.convertToYahooFinanceSymbol('DOGEUSD') ).toEqual('DOGE-USD'); - expect( - await yahooFinanceService.convertToYahooFinanceSymbol('SOL1USD') - ).toEqual('SOL1-USD'); expect( await yahooFinanceService.convertToYahooFinanceSymbol('USDCHF') ).toEqual('USDCHF=X'); 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 8d375a10e..0717a699e 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 @@ -49,7 +49,6 @@ export class YahooFinanceService implements DataProviderInterface { * Currency: USDCHF -> USDCHF=X * Cryptocurrency: BTCUSD -> BTC-USD * DOGEUSD -> DOGE-USD - * SOL1USD -> SOL1-USD */ public convertToYahooFinanceSymbol(aSymbol: string) { if (aSymbol.includes(baseCurrency) && aSymbol.length >= 6) { @@ -57,9 +56,7 @@ export class YahooFinanceService implements DataProviderInterface { return `${aSymbol}=X`; } else if ( this.cryptocurrencyService.isCryptocurrency( - aSymbol - .replace(new RegExp(`-${baseCurrency}$`), baseCurrency) - .replace('1', '') + aSymbol.replace(new RegExp(`-${baseCurrency}$`), baseCurrency) ) ) { // Add a dash before the last three characters @@ -246,9 +243,7 @@ export class YahooFinanceService implements DataProviderInterface { return ( (quoteType === 'CRYPTOCURRENCY' && this.cryptocurrencyService.isCryptocurrency( - symbol - .replace(new RegExp(`-${baseCurrency}$`), baseCurrency) - .replace('1', '') + symbol.replace(new RegExp(`-${baseCurrency}$`), baseCurrency) )) || quoteType === 'EQUITY' || quoteType === 'ETF'