Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/portfolio/portfolio.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,47 @@ export class PortfolioController {
);
}

@Get("portfolios/:portfolioId/metrics/roi")
@ApiOperation({
summary:
"Get Return on Investment (ROI) relative to the invested cost basis",
})
@UseGuards(PortfolioOwnerGuard)
async getROI(@Param("portfolioId") portfolioId: string) {
const roi = await this.performanceService.calculateROI(portfolioId);
return { portfolioId, roi };
}

@Get("portfolios/:portfolioId/metrics/drawdown")
@ApiOperation({
summary:
"Get current drawdown relative to the all-time peak portfolio value",
})
@UseGuards(PortfolioOwnerGuard)
async getCurrentDrawdown(@Param("portfolioId") portfolioId: string) {
const currentDrawdown =
await this.performanceService.calculateCurrentDrawdown(portfolioId);
return { portfolioId, currentDrawdown };
}

@Get("portfolios/:portfolioId/metrics/periods")
@ApiOperation({
summary: "Get standard period returns (YTD, 1Y, 3Y, 5Y) for the portfolio",
})
@UseGuards(PortfolioOwnerGuard)
async getPeriodReturns(@Param("portfolioId") portfolioId: string) {
return this.performanceService.calculatePeriodReturns(portfolioId);
}

@Get("portfolios/:portfolioId/metrics/allocation")
@ApiOperation({
summary: "Get the current allocation breakdown (ticker → percentage)",
})
@UseGuards(PortfolioOwnerGuard)
async getAllocationBreakdown(@Param("portfolioId") portfolioId: string) {
return this.performanceService.getAllocationBreakdown(portfolioId);
}

// Backtesting Endpoints

@Post("backtests")
Expand Down
Loading
Loading