diff --git a/apps/api/src/app/portfolio/current-rate.service.ts b/apps/api/src/app/portfolio/current-rate.service.ts index f4855329e..c98c0adba 100644 --- a/apps/api/src/app/portfolio/current-rate.service.ts +++ b/apps/api/src/app/portfolio/current-rate.service.ts @@ -15,6 +15,7 @@ import { isBefore, isToday } from 'date-fns'; import { flatten, isEmpty, uniqBy } from 'lodash'; import { GetValueObject } from './interfaces/get-value-object.interface'; +import { GetValueRangeParams } from './interfaces/get-value-range-params.interface'; import { GetValuesObject } from './interfaces/get-values-object.interface'; import { GetValuesParams } from './interfaces/get-values-params.interface'; @@ -163,6 +164,34 @@ export class CurrentRateService { return response; } + public async getValueRange({ + dataGatheringItems, + dateRange + }: GetValueRangeParams): Promise { + const values = await this.marketDataService + .getDecimatedRange({ + dateRange, + dataSources: dataGatheringItems.map((x) => x.dataSource), + symbols: dataGatheringItems.map((x) => x.symbol) + }) + .then((data) => { + return data.map(({ dataSource, date, marketPrice, symbol }) => { + return { + dataSource, + date, + marketPrice, + symbol + }; + }); + }); + + return { + dataProviderInfos: [], + errors: [], + values + }; + } + private containsToday(dates: Date[]): boolean { for (const date of dates) { if (isToday(date)) { diff --git a/apps/api/src/app/portfolio/interfaces/get-value-range-params.interface.ts b/apps/api/src/app/portfolio/interfaces/get-value-range-params.interface.ts new file mode 100644 index 000000000..62d2ff362 --- /dev/null +++ b/apps/api/src/app/portfolio/interfaces/get-value-range-params.interface.ts @@ -0,0 +1,8 @@ +import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces'; + +import { DateRange } from './date-range.interface'; + +export interface GetValueRangeParams { + dataGatheringItems: IDataGatheringItem[]; + dateRange: DateRange; +}