From 28064becf4fe3777749f9de98bbc1e6ac2efa087 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 13 Jan 2024 10:10:47 +0100 Subject: [PATCH] Refactoring --- .../api/src/app/benchmark/benchmark.service.ts | 11 ----------- .../src/app/portfolio/portfolio-calculator.ts | 18 +++++++----------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/apps/api/src/app/benchmark/benchmark.service.ts b/apps/api/src/app/benchmark/benchmark.service.ts index 696e2f511..40fd59d9a 100644 --- a/apps/api/src/app/benchmark/benchmark.service.ts +++ b/apps/api/src/app/benchmark/benchmark.service.ts @@ -247,17 +247,6 @@ export class BenchmarkService { format(startDate, DATE_FORMAT) ]; - if (!exchangeRateAtStartDate) { - Logger.error( - `No exchange rate has been found for ${ - currentSymbolItem.currency - }${userCurrency} at ${format(startDate, DATE_FORMAT)}`, - 'BenchmarkService' - ); - - return { marketData }; - } - const marketPriceAtStartDate = marketDataItems?.find(({ date }) => { return isSameDay(date, startDate); })?.marketPrice; diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index 9d0c99331..7aaaffe83 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -504,10 +504,13 @@ export class PortfolioCalculator { dates.map((date) => { return date.getTime(); }) - ).map((timestamp) => { - return new Date(timestamp); - }); - dates.sort((a, b) => a.getTime() - b.getTime()); + ) + .map((timestamp) => { + return new Date(timestamp); + }) + .sort((a, b) => { + return a.getTime() - b.getTime(); + }); let exchangeRatesByCurrency = await this.exchangeRateDataService.getExchangeRatesByCurrency({ @@ -1328,13 +1331,6 @@ export class PortfolioCalculator { const exchangeRateAtOrderDate = exchangeRates[order.date]; - if (!exchangeRateAtOrderDate) { - Logger.error( - `No exchange rate has been found for ${DEFAULT_CURRENCY}${order.currency} at ${order.date}`, - 'PortfolioCalculator' - ); - } - if (order.itemType === 'start') { // Take the unit price of the order as the market price if there are no // orders of this symbol before the start date