From 7dd7a7909d754005210c745dc628e4baf5b1e41c Mon Sep 17 00:00:00 2001 From: helgehatt Date: Tue, 12 Mar 2024 21:42:59 +0000 Subject: [PATCH] Replace getValues call with getValueRange --- .../src/app/portfolio/portfolio-calculator.ts | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio-calculator.ts b/apps/api/src/app/portfolio/portfolio-calculator.ts index 91d91309f..b4af5d5f7 100644 --- a/apps/api/src/app/portfolio/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/portfolio-calculator.ts @@ -199,21 +199,9 @@ export class PortfolioCalculator { }) ?? []; const currencies: { [symbol: string]: string } = {}; - const dates: Date[] = []; const dataGatheringItems: IDataGatheringItem[] = []; const firstIndex = transactionPointsBeforeEndDate.length; - let day = start; - - while (isBefore(day, end)) { - dates.push(resetHours(day)); - day = addDays(day, step); - } - - if (!isSameDay(last(dates), end)) { - dates.push(resetHours(end)); - } - if (transactionPointsBeforeEndDate.length > 0) { for (const item of transactionPointsBeforeEndDate[firstIndex - 1].items) { dataGatheringItems.push({ @@ -226,10 +214,12 @@ export class PortfolioCalculator { } const { dataProviderInfos, values: marketSymbols } = - await this.currentRateService.getValues({ + await this.currentRateService.getValueRange({ dataGatheringItems, - dateQuery: { - in: dates + dateRange: { + start, + end, + step } }); @@ -322,9 +312,7 @@ export class PortfolioCalculator { }; } - for (const currentDate of dates) { - const dateString = format(currentDate, DATE_FORMAT); - + for (const dateString of Object.keys(marketSymbolMap)) { for (const symbol of Object.keys(valuesBySymbol)) { const symbolValues = valuesBySymbol[symbol];