|
@ -139,10 +139,10 @@ export class CoinGeckoService implements DataProviderInterface { |
|
|
}: { |
|
|
}: { |
|
|
symbols: string[]; |
|
|
symbols: string[]; |
|
|
}): Promise<{ [symbol: string]: IDataProviderResponse }> { |
|
|
}): Promise<{ [symbol: string]: IDataProviderResponse }> { |
|
|
const quotes: { [symbol: string]: IDataProviderResponse } = {}; |
|
|
const response: { [symbol: string]: IDataProviderResponse } = {}; |
|
|
|
|
|
|
|
|
if (symbols.length <= 0) { |
|
|
if (symbols.length <= 0) { |
|
|
return quotes; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
@ -152,7 +152,7 @@ export class CoinGeckoService implements DataProviderInterface { |
|
|
abortController.abort(); |
|
|
abortController.abort(); |
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
|
|
|
|
|
|
const response = await got( |
|
|
const quotes = await got( |
|
|
`${this.URL}/simple/price?ids=${symbols.join( |
|
|
`${this.URL}/simple/price?ids=${symbols.join( |
|
|
',' |
|
|
',' |
|
|
)}&vs_currencies=${DEFAULT_CURRENCY.toLowerCase()}`,
|
|
|
)}&vs_currencies=${DEFAULT_CURRENCY.toLowerCase()}`,
|
|
@ -162,24 +162,20 @@ export class CoinGeckoService implements DataProviderInterface { |
|
|
} |
|
|
} |
|
|
).json<any>(); |
|
|
).json<any>(); |
|
|
|
|
|
|
|
|
for (const symbol in response) { |
|
|
for (const symbol in quotes) { |
|
|
if (Object.prototype.hasOwnProperty.call(response, symbol)) { |
|
|
response[symbol] = { |
|
|
const quote: IDataProviderResponse = { |
|
|
currency: DEFAULT_CURRENCY, |
|
|
currency: DEFAULT_CURRENCY, |
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
dataSource: DataSource.COINGECKO, |
|
|
dataSource: DataSource.COINGECKO, |
|
|
marketPrice: quotes[symbol][DEFAULT_CURRENCY.toLowerCase()], |
|
|
marketPrice: response[symbol][DEFAULT_CURRENCY.toLowerCase()], |
|
|
marketState: 'open' |
|
|
marketState: 'open' |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
quotes[symbol] = quote; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
Logger.error(error, 'CoinGeckoService'); |
|
|
Logger.error(error, 'CoinGeckoService'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return quotes; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public getTestSymbol() { |
|
|
public getTestSymbol() { |
|
|