|
@ -65,11 +65,19 @@ export class PortfolioController { |
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
public async getChart( |
|
|
public async getChart( |
|
|
@Headers('impersonation-id') impersonationId: string, |
|
|
@Headers('impersonation-id') impersonationId: string, |
|
|
@Query('range') range |
|
|
@Query('accounts') filterByAccounts?: string, |
|
|
|
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
|
|
|
@Query('range') range?: DateRange, |
|
|
|
|
|
@Query('tags') filterByTags?: string |
|
|
): Promise<PortfolioChart> { |
|
|
): Promise<PortfolioChart> { |
|
|
const historicalDataContainer = await this.portfolioService.getChart( |
|
|
const historicalDataContainer = await this.portfolioService.getChart( |
|
|
impersonationId, |
|
|
impersonationId, |
|
|
range |
|
|
range, |
|
|
|
|
|
this.buildFiltersFromQueries( |
|
|
|
|
|
filterByAccounts, |
|
|
|
|
|
filterByAssetClasses, |
|
|
|
|
|
filterByTags |
|
|
|
|
|
) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
let chartData = historicalDataContainer.items; |
|
|
let chartData = historicalDataContainer.items; |
|
@ -278,11 +286,19 @@ export class PortfolioController { |
|
|
@UseInterceptors(TransformDataSourceInResponseInterceptor) |
|
|
@UseInterceptors(TransformDataSourceInResponseInterceptor) |
|
|
public async getPerformance( |
|
|
public async getPerformance( |
|
|
@Headers('impersonation-id') impersonationId: string, |
|
|
@Headers('impersonation-id') impersonationId: string, |
|
|
@Query('range') range |
|
|
@Query('accounts') filterByAccounts?: string, |
|
|
|
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
|
|
|
@Query('range') range?: DateRange, |
|
|
|
|
|
@Query('tags') filterByTags?: string |
|
|
): Promise<PortfolioPerformanceResponse> { |
|
|
): Promise<PortfolioPerformanceResponse> { |
|
|
const performanceInformation = await this.portfolioService.getPerformance( |
|
|
const performanceInformation = await this.portfolioService.getPerformance( |
|
|
impersonationId, |
|
|
impersonationId, |
|
|
range |
|
|
range, |
|
|
|
|
|
this.buildFiltersFromQueries( |
|
|
|
|
|
filterByAccounts, |
|
|
|
|
|
filterByAssetClasses, |
|
|
|
|
|
filterByTags |
|
|
|
|
|
) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
@ -333,11 +349,19 @@ export class PortfolioController { |
|
|
@UseInterceptors(TransformDataSourceInResponseInterceptor) |
|
|
@UseInterceptors(TransformDataSourceInResponseInterceptor) |
|
|
public async getPositions( |
|
|
public async getPositions( |
|
|
@Headers('impersonation-id') impersonationId: string, |
|
|
@Headers('impersonation-id') impersonationId: string, |
|
|
@Query('range') range |
|
|
@Query('accounts') filterByAccounts?: string, |
|
|
|
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
|
|
|
@Query('range') range?: DateRange, |
|
|
|
|
|
@Query('tags') filterByTags?: string |
|
|
): Promise<PortfolioPositions> { |
|
|
): Promise<PortfolioPositions> { |
|
|
const result = await this.portfolioService.getPositions( |
|
|
const result = await this.portfolioService.getPositions( |
|
|
impersonationId, |
|
|
impersonationId, |
|
|
range |
|
|
range, |
|
|
|
|
|
this.buildFiltersFromQueries( |
|
|
|
|
|
filterByAccounts, |
|
|
|
|
|
filterByAssetClasses, |
|
|
|
|
|
filterByTags |
|
|
|
|
|
) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
@ -423,7 +447,10 @@ export class PortfolioController { |
|
|
@Get('summary') |
|
|
@Get('summary') |
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
@UseGuards(AuthGuard('jwt')) |
|
|
public async getSummary( |
|
|
public async getSummary( |
|
|
@Headers('impersonation-id') impersonationId |
|
|
@Headers('impersonation-id') impersonationId, |
|
|
|
|
|
@Query('accounts') filterByAccounts?: string, |
|
|
|
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
|
|
|
@Query('tags') filterByTags?: string |
|
|
): Promise<PortfolioSummary> { |
|
|
): Promise<PortfolioSummary> { |
|
|
if ( |
|
|
if ( |
|
|
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && |
|
|
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && |
|
@ -435,7 +462,15 @@ export class PortfolioController { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let summary = await this.portfolioService.getSummary(impersonationId); |
|
|
const filters = this.buildFiltersFromQueries( |
|
|
|
|
|
filterByAccounts, |
|
|
|
|
|
filterByAssetClasses, |
|
|
|
|
|
filterByTags |
|
|
|
|
|
); |
|
|
|
|
|
let summary = await this.portfolioService.getSummary( |
|
|
|
|
|
impersonationId, |
|
|
|
|
|
filters |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
impersonationId || |
|
|
impersonationId || |
|
@ -516,4 +551,37 @@ export class PortfolioController { |
|
|
|
|
|
|
|
|
return await this.portfolioService.getReport(impersonationId); |
|
|
return await this.portfolioService.getReport(impersonationId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private buildFiltersFromQueries( |
|
|
|
|
|
filterByAccounts?: string, |
|
|
|
|
|
filterByAssetClasses?: string, |
|
|
|
|
|
filterByTags?: string |
|
|
|
|
|
) { |
|
|
|
|
|
const accountIds = filterByAccounts?.split(',') ?? []; |
|
|
|
|
|
const assetClasses = filterByAssetClasses?.split(',') ?? []; |
|
|
|
|
|
const tagIds = filterByTags?.split(',') ?? []; |
|
|
|
|
|
|
|
|
|
|
|
const filters: Filter[] = [ |
|
|
|
|
|
...accountIds.map((accountId) => { |
|
|
|
|
|
return <Filter>{ |
|
|
|
|
|
id: accountId, |
|
|
|
|
|
type: 'ACCOUNT' |
|
|
|
|
|
}; |
|
|
|
|
|
}), |
|
|
|
|
|
...assetClasses.map((assetClass) => { |
|
|
|
|
|
return <Filter>{ |
|
|
|
|
|
id: assetClass, |
|
|
|
|
|
type: 'ASSET_CLASS' |
|
|
|
|
|
}; |
|
|
|
|
|
}), |
|
|
|
|
|
...tagIds.map((tagId) => { |
|
|
|
|
|
return <Filter>{ |
|
|
|
|
|
id: tagId, |
|
|
|
|
|
type: 'TAG' |
|
|
|
|
|
}; |
|
|
|
|
|
}) |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
return filters; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|