Browse Source
Bugfix/fix currency inconsistency with usx (#1094)
* Support USX
* Update changelog
pull/1095/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
16 additions and
9 deletions
-
CHANGELOG.md
-
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts
-
apps/api/src/services/exchange-rate-data.service.ts
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. |
|
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
|
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
|
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
|
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
|
|
|
|
|
|
|
|
|
|
|
## Unreleased |
|
|
|
|
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
|
|
|
|
- Fixed an issue with the currency inconsistency in the _Yahoo Finance_ service (convert from `USX` to `USD`) |
|
|
|
|
|
|
|
|
## 1.172.0 - 23.07.2022 |
|
|
## 1.172.0 - 23.07.2022 |
|
|
|
|
|
|
|
|
### Added |
|
|
### Added |
|
|
|
@ -266,6 +266,16 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (yahooFinanceSymbols.includes('USDUSX=X')) { |
|
|
|
|
|
// Convert USD to USX (cent)
|
|
|
|
|
|
response['USDUSX'] = { |
|
|
|
|
|
currency: 'USX', |
|
|
|
|
|
dataSource: this.getName(), |
|
|
|
|
|
marketPrice: new Big(1).mul(100).toNumber(), |
|
|
|
|
|
marketState: 'open' |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return response; |
|
|
return response; |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
Logger.error(error, 'YahooFinanceService'); |
|
|
Logger.error(error, 'YahooFinanceService'); |
|
|
|
@ -122,15 +122,6 @@ export class ExchangeRateDataService { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const hasNaN = Object.values(this.exchangeRates).some((exchangeRate) => { |
|
|
|
|
|
return isNaN(exchangeRate); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (hasNaN) { |
|
|
|
|
|
// Reinitialize if data is not loaded correctly
|
|
|
|
|
|
this.initialize(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let factor = 1; |
|
|
let factor = 1; |
|
|
|
|
|
|
|
|
if (aFromCurrency !== aToCurrency) { |
|
|
if (aFromCurrency !== aToCurrency) { |
|
|