Skip to content

fix(review): load live positions using the supported schema - #371

Merged
brokermr810 merged 1 commit into
OpenByteInc:mainfrom
AmazingZ-sys:fix/review-position-schema
Nov 13, 2026
Merged

brokermr810 merged 1 commit into
OpenByteInc:mainfrom
AmazingZ-sys:fix/review-position-schema

Conversation

@AmazingZ-sys

Copy link
Copy Markdown
Contributor

Summary

Live strategy reviews select created_at from qd_strategy_positions, but the shipped table only has updated_at. PostgreSQL rejects the query and the exception handler returns an empty list, so a completed review can omit open positions and unrealized PnL. Remove the unsupported column without changing the database schema.

Related issue

Small bug fix reproduced against current main; no existing matching issue found.

Changes

  • Select the supported live-position fields, including updated_at.
  • Add a regression test using temporary PostgreSQL tables created from the canonical migrations/init.sql definitions and the production placeholder adapter. It checks strategy filtering, position/PnL evidence reaching the AI input, empty results, and the existing virtual-position timestamp behavior.

Test plan

  • Reproduced before the fix: the new test fails with column "created_at" does not exist and an open-position count of zero.
  • After the fix, Python 3.12 / isolated PostgreSQL 18: python -m pytest tests/test_strategy_review_positions.py tests/test_strategy_review_execution_mode.py tests/test_strategy_review_evidence.py tests/test_strategy_review_billing.py -q — 51 passed. Set QD_TEST_POSTGRES_DSN or DATABASE_URL to a test database for the PostgreSQL case; it uses temporary tables and rolls back.
  • ruff check app/services/strategy_review.py tests/test_strategy_review_positions.py — passed.
  • python scripts/backend_quality_check.py and git diff --check — passed.

API documentation

No route, schema, or public HTTP contract changes; no migration required.

Signed-off-by: Amazingz <amazingzsys@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@brokermr810 brokermr810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed schema/query correctness and regression coverage. Backend tests, CodeQL, secret scan, SonarCloud, Snyk, DCO, and REUSE passed. The pip-audit failure is the existing soupsieve 2.9 baseline on main; this PR does not modify dependencies.

@brokermr810
brokermr810 merged commit 6a0fe63 into OpenByteInc:main Nov 13, 2026
14 of 15 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.

2 participants