|
|
@ -2,6 +2,7 @@ import { HasPermission } from '@ghostfolio/api/decorators/has-permission.decorat |
|
|
|
import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard'; |
|
|
|
import { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.interceptor'; |
|
|
|
import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor'; |
|
|
|
import { ApiService } from '@ghostfolio/api/services/api/api.service'; |
|
|
|
import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'; |
|
|
|
import { HEADER_KEY_IMPERSONATION } from '@ghostfolio/common/config'; |
|
|
|
import type { |
|
|
@ -36,6 +37,7 @@ import { BenchmarkService } from './benchmark.service'; |
|
|
|
@Controller('benchmark') |
|
|
|
export class BenchmarkController { |
|
|
|
public constructor( |
|
|
|
private readonly apiService: ApiService, |
|
|
|
private readonly benchmarkService: BenchmarkService, |
|
|
|
@Inject(REQUEST) private readonly request: RequestWithUser |
|
|
|
) {} |
|
|
@ -114,20 +116,38 @@ export class BenchmarkController { |
|
|
|
@Param('dataSource') dataSource: DataSource, |
|
|
|
@Param('startDateString') startDateString: string, |
|
|
|
@Param('symbol') symbol: string, |
|
|
|
@Query('range') dateRange: DateRange = 'max' |
|
|
|
@Query('range') dateRange: DateRange = 'max', |
|
|
|
@Query('accounts') filterByAccounts?: string, |
|
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
|
@Query('dataSource') filterByDataSource?: string, |
|
|
|
@Query('symbol') filterBySymbol?: string, |
|
|
|
@Query('tags') filterByTags?: string, |
|
|
|
@Query('withExcludedAccounts') withExcludedAccountsParam = 'false' |
|
|
|
): Promise<BenchmarkMarketDataDetails> { |
|
|
|
const { endDate, startDate } = getIntervalFromDateRange( |
|
|
|
dateRange, |
|
|
|
new Date(startDateString) |
|
|
|
); |
|
|
|
|
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
|
filterByAccounts, |
|
|
|
filterByAssetClasses, |
|
|
|
filterByDataSource, |
|
|
|
filterBySymbol, |
|
|
|
filterByTags |
|
|
|
}); |
|
|
|
|
|
|
|
const withExcludedAccounts = withExcludedAccountsParam === 'true'; |
|
|
|
|
|
|
|
return this.benchmarkService.getMarketDataForUser({ |
|
|
|
dataSource, |
|
|
|
dateRange, |
|
|
|
endDate, |
|
|
|
filters, |
|
|
|
impersonationId, |
|
|
|
startDate, |
|
|
|
symbol, |
|
|
|
withExcludedAccounts, |
|
|
|
user: this.request.user |
|
|
|
}); |
|
|
|
} |
|
|
|