Skip to content

Implement portfolio performance analytics (APY, Sharpe ratio, drawdown) #225

Description

@robertocarlous

Summary

Users can see current positions but have no historical performance view. Adding analytics calculations on YieldSnapshot data would unlock portfolio reporting.

Proposed Solution

Extend GET /api/analytics to return:

  • Realized APY: annualised return from YieldSnapshot history
  • Sharpe Ratio: risk-adjusted return (requires volatility calculation over snapshots)
  • Max Drawdown: largest peak-to-trough decline in portfolio value
  • Protocol Allocation %: breakdown by protocol

Compute in src/routes/analytics.ts using existing snapshot data; no new data collection needed.

Acceptance Criteria

  • GET /api/analytics?period=30d|90d|1y returns metrics object
  • APY calculation verified against manual calculation on test data
  • Sharpe ratio uses risk-free rate from env var (default 0)
  • Unit tests for each calculation function in src/utils/analytics.ts
  • OpenAPI spec updated

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions