Browse Source
Feature/refactor is cryptocurrency check (#4215)
* Refactoring
pull/4200/head^2
Thomas Kaul
3 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
8 additions and
6 deletions
-
apps/api/src/services/cryptocurrency/cryptocurrency.service.ts
-
apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts
|
|
@ -1,3 +1,5 @@ |
|
|
|
import { DEFAULT_CURRENCY } from '@ghostfolio/common/config'; |
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
|
|
|
|
const cryptocurrencies = require('../../assets/cryptocurrencies/cryptocurrencies.json'); |
|
|
@ -9,7 +11,11 @@ export class CryptocurrencyService { |
|
|
|
|
|
|
|
public isCryptocurrency(aSymbol = '') { |
|
|
|
const cryptocurrencySymbol = aSymbol.substring(0, aSymbol.length - 3); |
|
|
|
return this.getCryptocurrencies().includes(cryptocurrencySymbol); |
|
|
|
|
|
|
|
return ( |
|
|
|
aSymbol.endsWith(DEFAULT_CURRENCY) && |
|
|
|
this.getCryptocurrencies().includes(cryptocurrencySymbol) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private getCryptocurrencies() { |
|
|
|
|
|
@ -11,7 +11,6 @@ import { |
|
|
|
IDataProviderHistoricalResponse, |
|
|
|
IDataProviderResponse |
|
|
|
} from '@ghostfolio/api/services/interfaces/interfaces'; |
|
|
|
import { DEFAULT_CURRENCY } from '@ghostfolio/common/config'; |
|
|
|
import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper'; |
|
|
|
import { |
|
|
|
DataProviderInfo, |
|
|
@ -66,10 +65,7 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
}; |
|
|
|
|
|
|
|
try { |
|
|
|
if ( |
|
|
|
symbol.endsWith(DEFAULT_CURRENCY) && |
|
|
|
this.cryptocurrencyService.isCryptocurrency(symbol) |
|
|
|
) { |
|
|
|
if (this.cryptocurrencyService.isCryptocurrency(symbol)) { |
|
|
|
const [quote] = await fetch( |
|
|
|
`${this.URL}/quote/${symbol}?apikey=${this.apiKey}`, |
|
|
|
{ |
|
|
|