Skip to content

Comments

feat: Support Stock Market Indices in Portfolio Performance#7

Merged
nenadjakic merged 7 commits intomainfrom
storia
Dec 18, 2025
Merged

feat: Support Stock Market Indices in Portfolio Performance#7
nenadjakic merged 7 commits intomainfrom
storia

Conversation

@nenadjakic
Copy link
Owner

Description

This PR adds support for tracking major stock market indices (S&P 500, NASDAQ, STOXX 50, STOXX 600) in both backend and frontend, allowing users to compare their portfolio performance against market benchmarks.

Changes Made

Backend

  • Added INDEX asset type to AssetType enum
  • Created Index entity extending ListedAsset
  • Added Flyway migration (V20251216210219) to:
    • Update CHECK constraint to include INDEX type
    • Seed major indices with Yahoo Finance symbols
  • Updated REST API (getPortfolioPerformanceChart):
    • Added optional indices parameter
    • Modified PortfolioChartResponse DTO to include indices data
  • Enhanced PortfolioService:
    • Added calculateIndicesPerformance() method
    • Injected AssetRepository and AssetHistoryRepository
    • Calculates normalized percentage changes for selected indices
  • Regenerated OpenAPI specification

Frontend

  • Updated Dashboard/Overview P&L chart:
    • Added index selection UI with toggle buttons
    • Chart displays portfolio P/L alongside selected indices
    • All series normalized to start at 0% for easy comparison
    • Enhanced tooltip to show all series data
    • Added legend for better clarity
  • Regenerated API client from updated OpenAPI spec

Acceptance Criteria Met

✅ New entity inherits Asset and is reflected in the enum discriminator
✅ Database is seeded with index data using Flyway migration
getPortfolioPerformanceChart REST method supports selected indices
✅ Frontend allows selecting indices on the Dashboard/Overview P&L chart
✅ OpenAPI specification is updated

Testing

  • Migration runs successfully and seeds indices
  • API returns index performance data when requested
  • Frontend displays indices correctly on chart
  • Chart updates dynamically when indices are selected/deselected

Screenshots

N/A - Backend and frontend changes work together to enable index comparison

Resolves #IN-1, #IN-2, #IN-3, #IN-4

- Added INDEX asset type to AssetType enum
- Created Index entity extending ListedAsset
- Added Flyway migration to seed major indices (S&P500, NASDAQ, STOXX50, STOXX600)
- Updated PortfolioChartResponse DTO to include indices data
- Modified getPortfolioPerformanceChart REST API to accept optional indices parameter
- Enhanced PortfolioService to calculate normalized index performance
- Updated frontend Dashboard/Overview P&L chart to allow selecting benchmark indices
- Regenerated OpenAPI specification

Resolves: IN-1, IN-2, IN-3, IN-4
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive support for tracking major stock market indices (S&P 500, NASDAQ, STOXX 50, STOXX 600) to enable portfolio performance benchmarking. The implementation spans both backend and frontend, introducing a new INDEX asset type, database migrations for seeding index data, enhanced REST APIs for retrieving index performance, and UI components for index selection and visualization.

Key Changes:

  • Added INDEX asset type with database migration to seed major market indices
  • Enhanced portfolio performance API to accept optional indices parameter and calculate normalized percentage changes
  • Updated frontend dashboard to display index selection UI with toggle buttons and visualize multiple series on the P&L chart

Reviewed changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
backend/data/src/main/kotlin/com/github/nenadjakic/investiq/data/enum/AssetType.kt Added INDEX enum value to AssetType
backend/data/src/main/kotlin/com/github/nenadjakic/investiq/data/entity/asset/Index.kt Created new Index entity extending ListedAsset
backend/data/src/main/resources/migrations/V20251216210219__add_index_asset_type_and_seed_indices.sql Migration to add INDEX type to constraint and seed major indices
backend/service/src/main/kotlin/com/github/nenadjakic/investiq/service/PortfolioService.kt Added calculateIndicesPerformance method and injected required repositories
backend/common/src/main/kotlin/com/github/nenadjakic/investiq/common/dto/PortfolioChartResponse.kt Added optional indices map to response DTO
backend/app-rest/src/main/kotlin/com/github/nenadjakic/investiq/restapp/controller/PortfolioController.kt Added indices parameter to getPortfolioPerformanceChart endpoint
backend/app-rest/build.gradle.kts Added OpenAPI generation configuration
backend/app-cli/src/main/kotlin/com/github/nenadjakic/investiq/importer/command/TestCommand.kt Added test command (should be removed)
backend/spring-shell.log Log file added (should be gitignored)
frontend/src/dashboard/overview/overview.ts Added index selection logic and chart rendering for multiple series
frontend/src/dashboard/overview/overview.html Added index toggle buttons UI
frontend/src/reference-data/reference-data.ts Reset statistics to '0' (unrelated change)
frontend/src/app/core/api/ Regenerated API client with updated types and endpoints
frontend/openapi.json Updated OpenAPI specification
frontend/package.json & frontend/package-lock.json Removed Angular Material dependencies
frontend/src/custom-theme.scss Removed Angular Material theme file
frontend/angular.json Removed custom theme reference
Files not reviewed (1)
  • frontend/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

nenadjakic and others added 5 commits December 17, 2025 20:30
…ta/entity/asset/Index.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/importer/command/TestCommand.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/service/PortfolioService.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nenadjakic nenadjakic self-assigned this Dec 18, 2025
@nenadjakic nenadjakic merged commit 4b3047c into main Dec 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant