Skip to content

feat(cqrs): add projected portfolio status query#124

Merged
blackms merged 1 commit into
mainfrom
codex/projected-portfolio-status-query
Apr 26, 2026
Merged

feat(cqrs): add projected portfolio status query#124
blackms merged 1 commit into
mainfrom
codex/projected-portfolio-status-query

Conversation

@blackms

@blackms blackms commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a projected GetPortfolioStatusQuery handler backed by portfolio, position, order, and trading-state read models.
  • Adds a durable trading-state read model projected from TradingSuspendedEvent and TradingResumedEvent.
  • Uses active order projections for read-side trailing buy/sell pair summaries and keeps optional query sections lazy.

Acceptance Criteria

  • Given trading suspend/resume domain events, when they are dispatched, then they update and persist the trading-state projection.
  • Given projected portfolio, position, order, and trading state, when portfolio status is queried, then the response is aggregated from read models without using the legacy trading adapter.
  • Given optional portfolio status sections are disabled, when the query is handled, then positions, trailing orders, and order history are not loaded or returned.

Changes

  • Added ITradingStateReadModel and JSON projection/writer/handler for operational trading state.
  • Added GetPortfolioStatusHandler to aggregate projected portfolio status and order history.
  • Registered the trading-state read model in Autofac and isolated integration fixture wiring.
  • Added Application and Infrastructure tests covering RED/GREEN behavior.

Testing

  • dotnet test tests/IntelliTrader.Application.Tests/IntelliTrader.Application.Tests.csproj --no-restore
  • dotnet test tests/IntelliTrader.Infrastructure.Tests/IntelliTrader.Infrastructure.Tests.csproj --no-restore
  • dotnet test IntelliTrader.sln --no-restore
  • git diff --cached --check

Checklist

  • Tests pass
  • Coverage maintained
  • Linter clean via git diff --cached --check
  • Documentation updated: not applicable, internal CQRS slice

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@blackms has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 35 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 35 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47bf1a1e-2b67-4d68-bb20-ef3f22e40796

📥 Commits

Reviewing files that changed from the base of the PR and between 75a330f and 33fa115.

📒 Files selected for processing (10)
  • IntelliTrader.Application/Ports/Driven/ITradingStateReadModel.cs
  • IntelliTrader.Application/Trading/Handlers/PortfolioStatusQueryHandler.cs
  • IntelliTrader.Application/Trading/Queries/GetPortfolioStatusQuery.cs
  • IntelliTrader.Infrastructure/Adapters/Persistence/ReadModels/ITradingStateReadModelProjectionWriter.cs
  • IntelliTrader.Infrastructure/Adapters/Persistence/ReadModels/JsonTradingStateReadModel.cs
  • IntelliTrader.Infrastructure/Adapters/Persistence/ReadModels/TradingStateReadModelProjectionHandler.cs
  • IntelliTrader.Infrastructure/AppModule.cs
  • tests/IntelliTrader.Application.Tests/Trading/Handlers/PortfolioStatusQueryHandlerTests.cs
  • tests/IntelliTrader.Infrastructure.Tests/Adapters/Persistence/TradingStateReadModelProjectionTests.cs
  • tests/IntelliTrader.Infrastructure.Tests/Integration/InfrastructureTestFixture.cs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/projected-portfolio-status-query

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@blackms blackms merged commit 1beb511 into main Apr 26, 2026
2 checks passed
@blackms blackms deleted the codex/projected-portfolio-status-query branch April 26, 2026 21:54
@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.54209% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...on/Trading/Handlers/PortfolioStatusQueryHandler.cs 88.81% 8 Missing and 10 partials ⚠️
...ersistence/ReadModels/JsonTradingStateReadModel.cs 85.08% 12 Missing and 5 partials ⚠️
...adModels/TradingStateReadModelProjectionHandler.cs 80.00% 0 Missing and 1 partial ⚠️
IntelliTrader.Infrastructure/AppModule.cs 83.33% 1 Missing ⚠️
Files with missing lines Coverage Δ
...Application/Ports/Driven/ITradingStateReadModel.cs 100.00% <100.00%> (ø)
...ication/Trading/Queries/GetPortfolioStatusQuery.cs 100.00% <ø> (+100.00%) ⬆️
...adModels/TradingStateReadModelProjectionHandler.cs 80.00% <80.00%> (ø)
IntelliTrader.Infrastructure/AppModule.cs 86.50% <83.33%> (-0.13%) ⬇️
...ersistence/ReadModels/JsonTradingStateReadModel.cs 85.08% <85.08%> (ø)
...on/Trading/Handlers/PortfolioStatusQueryHandler.cs 88.81% <88.81%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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