Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/improve exchange rate service for specific date (#1785)
Thomas Kaule37a34ed6cd0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 34cc2daa3b..92014bdd9e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed- Improved the usability of the _FIRE_ calculator+- Improved the exchange rate service for a specific date used in activities with a manual currency- Upgraded `ngx-device-detector` from version `3.0.0` to `5.0.1`## 1.244.0 - 2023-03-09diff --git a/apps/api/src/services/exchange-rate-data.service.ts b/apps/api/src/services/exchange-rate-data.service.tsindex 080772eb93..6f5d215c8a 100644--- a/apps/api/src/services/exchange-rate-data.service.ts+++ b/apps/api/src/services/exchange-rate-data.service.ts@@ -183,8 +183,29 @@ export class ExchangeRateDataService {if (marketData?.marketPrice) {factor = marketData?.marketPrice;} else {- // TODO: Get from data provider service or calculate indirectly via base currency- // and market data+ // Calculate indirectly via base currency+ try {+ const [+ { marketPrice: marketPriceBaseCurrencyFromCurrency },+ { marketPrice: marketPriceBaseCurrencyToCurrency }+ ] = await Promise.all([+ this.marketDataService.get({+ dataSource,+ date: aDate,+ symbol: `${this.baseCurrency}${aFromCurrency}`+ }),+ this.marketDataService.get({+ dataSource,+ date: aDate,+ symbol: `${this.baseCurrency}${aToCurrency}`+ })+ ]);++ // Calculate the opposite direction+ factor =+ (1 / marketPriceBaseCurrencyFromCurrency) *+ marketPriceBaseCurrencyToCurrency;+ } catch {}}}