diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4a0db12..6d9c4284b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Used the `HasPermission` annotation in endpoints - Upgraded `Nx` from version `17.2.5` to `17.2.7` +### Fixed + +- Improved the handling of derived currencies (`USX`) + ## 2.32.0 - 2023-12-26 ### Added diff --git a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts index f9cd7be71..76e8ce9c6 100644 --- a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts +++ b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts @@ -191,7 +191,9 @@ export class EodHistoricalDataService implements DataProviderInterface { })?.currency; result[this.convertFromEodSymbol(code)] = { - currency: currency ?? DEFAULT_CURRENCY, + currency: + currency ?? + this.convertFromEodSymbol(code)?.replace(DEFAULT_CURRENCY, ''), dataSource: DataSource.EOD_HISTORICAL_DATA, marketPrice: close, marketState: isToday(new Date(timestamp * 1000)) ? 'open' : 'closed' @@ -205,7 +207,7 @@ export class EodHistoricalDataService implements DataProviderInterface { if (response[`${DEFAULT_CURRENCY}GBP`]) { response[`${DEFAULT_CURRENCY}GBp`] = { ...response[`${DEFAULT_CURRENCY}GBP`], - currency: `${DEFAULT_CURRENCY}GBp`, + currency: 'GBp', marketPrice: this.getConvertedValue({ symbol: `${DEFAULT_CURRENCY}GBp`, value: response[`${DEFAULT_CURRENCY}GBP`].marketPrice @@ -216,7 +218,7 @@ export class EodHistoricalDataService implements DataProviderInterface { if (response[`${DEFAULT_CURRENCY}ILS`]) { response[`${DEFAULT_CURRENCY}ILA`] = { ...response[`${DEFAULT_CURRENCY}ILS`], - currency: `${DEFAULT_CURRENCY}ILA`, + currency: 'ILA', marketPrice: this.getConvertedValue({ symbol: `${DEFAULT_CURRENCY}ILA`, value: response[`${DEFAULT_CURRENCY}ILS`].marketPrice @@ -224,6 +226,15 @@ export class EodHistoricalDataService implements DataProviderInterface { }; } + if (response[`${DEFAULT_CURRENCY}USX`]) { + response[`${DEFAULT_CURRENCY}USX`] = { + currency: 'USX', + dataSource: this.getName(), + marketPrice: new Big(1).mul(100).toNumber(), + marketState: 'open' + }; + } + return response; } catch (error) { let message = error;