fix: exchange-aware latest BUY matching (#323) #338

Merged
jihoson merged 1 commits from feature/issue-323-buy-match-exchange-code into feature/v3-session-policy-stream 2026-02-28 17:37:44 +09:00
Collaborator

Summary

  • Extend get_latest_buy_trade to accept exchange_code and prioritize exact exchange match
  • Keep fallback for legacy rows with null/empty exchange_code
  • Pass exchange_code from runtime sell paths in main.py
  • Add DB unit test for exchange-aware buy matching

Validation

  • pytest -q tests/test_db.py tests/test_main.py -k "get_latest_buy_trade_prefers_exchange_code_match or sell_updates_original_buy_decision_outcome"
## Summary - Extend `get_latest_buy_trade` to accept `exchange_code` and prioritize exact exchange match - Keep fallback for legacy rows with null/empty exchange_code - Pass exchange_code from runtime sell paths in `main.py` - Add DB unit test for exchange-aware buy matching ## Validation - pytest -q tests/test_db.py tests/test_main.py -k "get_latest_buy_trade_prefers_exchange_code_match or sell_updates_original_buy_decision_outcome"
agentson added 1 commit 2026-02-28 14:38:59 +09:00
fix: include exchange_code in latest BUY matching key (#323)
Some checks failed
Gitea CI / test (pull_request) Waiting to run
Gitea CI / test (push) Has been cancelled
47aadcb4e7
Author
Collaborator

Ticket Maturity Update (2026-02-28)

  • Implemented: done
  • Integrated: done
  • Observed: done (targeted test commands executed and passing)
  • Accepted: pending (reviewer + runtime verifier approval required)

Coverage Matrix:

Stage Status
Implemented PASS
Integrated PASS
Observed PASS
Accepted NOT_OBSERVED
## Ticket Maturity Update (2026-02-28) - Implemented: done - Integrated: done - Observed: done (targeted test commands executed and passing) - Accepted: pending (reviewer + runtime verifier approval required) Coverage Matrix: | Stage | Status | | --- | --- | | Implemented | PASS | | Integrated | PASS | | Observed | PASS | | Accepted | NOT_OBSERVED |
agentson reviewed 2026-02-28 16:15:44 +09:00
agentson left a comment
Author
Collaborator

Review: PR #338 — fix: exchange-aware latest BUY matching (#323)

플랜 일치: ACT-06 정확히 일치

  • exchange_code 존재 시 매칭 키에 포함, NULL 하위 호환 유지

코드 품질: 우수

  • 우선순위 매칭: CASE WHEN exchange_code = ? THEN 0 ELSE 1 END 로 정확한 exchange 우선, NULL/empty 폴백 — 설계 의도에 정확히 부합
  • 하위 호환: exchange_code가 NULL/empty인 레거시 행도 후보에 포함
  • 호출부 반영: main.py 실시간/일간 2곳 모두 exchange_code=market.exchange_code 전달
  • exchange_code=None일 때: 기존 동작 완전 유지 (else 브랜치)

테스트: 충분

  • 동일 티커 다중 exchange 매칭 테스트: legacy(empty) + matched(NASD) → matched 우선 확인

결론: LGTM

## Review: PR #338 — fix: exchange-aware latest BUY matching (#323) ### 플랜 일치: ✅ ACT-06 정확히 일치 - exchange_code 존재 시 매칭 키에 포함, NULL 하위 호환 유지 ### 코드 품질: ✅ 우수 - **우선순위 매칭**: `CASE WHEN exchange_code = ? THEN 0 ELSE 1 END` 로 정확한 exchange 우선, NULL/empty 폴백 — 설계 의도에 정확히 부합 - **하위 호환**: exchange_code가 NULL/empty인 레거시 행도 후보에 포함 - **호출부 반영**: main.py 실시간/일간 2곳 모두 `exchange_code=market.exchange_code` 전달 - **exchange_code=None일 때**: 기존 동작 완전 유지 (else 브랜치) ### 테스트: ✅ 충분 - 동일 티커 다중 exchange 매칭 테스트: legacy(empty) + matched(NASD) → matched 우선 확인 ### 결론: **LGTM** ✅
agentson force-pushed feature/issue-323-buy-match-exchange-code from 47aadcb4e7 to 92261da414 2026-02-28 17:17:41 +09:00 Compare
Author
Collaborator

컨플릭트 해결 완료했습니다.

조치:

  • feature/v3-session-policy-stream 최신 기준으로 rebase
  • 충돌 파일 tests/test_db.py에서 두 테스트(exchange_code 매칭, decision_logs session_id migration)를 모두 유지하도록 병합
  • 강제 푸시: git push --force-with-lease

검증:

  • pytest -q tests/test_db.py tests/test_main.py -k "get_latest_buy_trade_prefers_exchange_code_match or sell_updates_original_buy_decision_outcome"
  • 결과: 2 passed
컨플릭트 해결 완료했습니다. 조치: - `feature/v3-session-policy-stream` 최신 기준으로 rebase - 충돌 파일 `tests/test_db.py`에서 두 테스트(`exchange_code 매칭`, `decision_logs session_id migration`)를 모두 유지하도록 병합 - 강제 푸시: `git push --force-with-lease` 검증: - `pytest -q tests/test_db.py tests/test_main.py -k "get_latest_buy_trade_prefers_exchange_code_match or sell_updates_original_buy_decision_outcome"` - 결과: 2 passed
jihoson merged commit b8569d9de1 into feature/v3-session-policy-stream 2026-02-28 17:37:44 +09:00
jihoson deleted branch feature/issue-323-buy-match-exchange-code 2026-02-28 17:37:44 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#338