Browse Source
Fix get quotes in CoinGecko service (#2595)
* Fix get quotes in CoinGecko service
* Update changelog
---------
Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>
pull/2600/head
Lukas Möller
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
10 additions and
11 deletions
-
CHANGELOG.md
-
apps/api/src/services/data-provider/coingecko/coingecko.service.ts
|
|
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed an issue to get quotes in the _CoinGecko_ service |
|
|
|
- Loosened the validation in the activities import (expects values greater than or equal to 0 for `fee`, `quantity` and `unitPrice`) |
|
|
|
- Handled an issue with a failing database query (`account.findMany()`) related to activities without account |
|
|
|
|
|
|
|
|
|
@ -152,7 +152,7 @@ export class CoinGeckoService implements DataProviderInterface { |
|
|
|
abortController.abort(); |
|
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
|
|
|
|
|
const response = await got( |
|
|
|
const quotes = await got( |
|
|
|
`${this.URL}/simple/price?ids=${symbols.join( |
|
|
|
',' |
|
|
|
)}&vs_currencies=${DEFAULT_CURRENCY.toLowerCase()}`,
|
|
|
@ -162,17 +162,15 @@ export class CoinGeckoService implements DataProviderInterface { |
|
|
|
} |
|
|
|
).json<any>(); |
|
|
|
|
|
|
|
for (const symbol in response) { |
|
|
|
if (Object.prototype.hasOwnProperty.call(response, symbol)) { |
|
|
|
for (const symbol in quotes) { |
|
|
|
response[symbol] = { |
|
|
|
currency: DEFAULT_CURRENCY, |
|
|
|
dataProviderInfo: this.getDataProviderInfo(), |
|
|
|
dataSource: DataSource.COINGECKO, |
|
|
|
marketPrice: response[symbol][DEFAULT_CURRENCY.toLowerCase()], |
|
|
|
marketPrice: quotes[symbol][DEFAULT_CURRENCY.toLowerCase()], |
|
|
|
marketState: 'open' |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
Logger.error(error, 'CoinGeckoService'); |
|
|
|
} |
|
|
|