Browse Source
Feature/add cryptocurrency solana (#563)
* Add support for Solana and clean up symbol conversion (SOL1USD)
* Update changelog
pull/566/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
7 additions and
12 deletions
-
CHANGELOG.md
-
apps/api/src/services/cryptocurrency/custom-cryptocurrencies.json
-
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.spec.ts
-
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts
|
|
@ -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 |
|
|
|
|
|
@ -4,5 +4,6 @@ |
|
|
|
"AVAX": "Avalanche", |
|
|
|
"MATIC": "Polygon", |
|
|
|
"SHIB": "Shiba Inu", |
|
|
|
"SOL": "Solana", |
|
|
|
"UNI3": "Uniswap" |
|
|
|
} |
|
|
|
|
|
@ -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'); |
|
|
|
|
|
@ -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' |
|
|
|