Files
trex-core/docs/srs/Integration/req-085_order-result-logging.md
T
genichinandClaude Opus 4.8 d8d9021260 feat(execution,obs): 호가단위 스냅(dcy-030/#28) + 운영 관측성(dcy-029/#29) + REL-007 환류
dcy-030 (issue #28, P0 체결 복구):
- REQ-083 KRX 호가단위(tick) 순수 유틸 (domain/pricing.py)
- REQ-070 CHG: 슬리피지 실효가 호가단위 스냅 — 상한 준수(매수 floor/매도 ceil)
  + band<1tick 하한/상한 보장 + 부동소수 epsilon 가드. 147700→148400/54500→54700.
- BAT-044 release-candidate

dcy-029 (issue #29, 운영 관측성):
- REQ-084 구조화 로깅 기반 (runtime/logging_setup.py): ISO8601 KST·레벨·Loki JSON
  ·correlation id(slot_id)
- REQ-085 주문 결과 로깅 (event=order_submit|fill|reject)
- REQ-087 거부 ERROR 가시성 (조용한 롤백 제거)
- REQ-086 청산 reason+actor 동반 노출 (안전망/전략 구분, 신규 필드 없음)
- REQ-088 운영 조회 CLI report (application/operator_report.py, 보유·오늘 체결
  ·실현 PnL net·대기, direct-DB)
- REQ-089 운영자 런북 docs/operations.md
- REQ-090 baseline 정합 (runtime-flows·project-structure·interface-contract)
- BAT-045(P0)·BAT-046(P1) release-candidate

REL-007: confirmed → feedback-captured (운영 인스턴스 라이브 검증 + #28/#29 환류
정규화). BAT-037~041 released.

검증: 537 passed, 47 skipped, 회귀 0, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 13:19:31 +09:00

3.5 KiB

req-085: 주문 결과 로깅 — submit/체결/거부 일관 tailable 로그

  • Status: Implemented
  • Type: Integration
  • Priority: High
  • Owner: project maintainers

Intent

  • 주문 결과(체결/거부)가 산발적 로그·DB(slot_transition_log)에만 남아 호가단위 거부(#28)를 수 시간 못 봤다. 모든 주문 submit과 그 결과(체결가·수량·수수료·세금, 또는 거부+사유)를 타임스탬프 달린 일관(tailable) 로그 라인으로 출력해 grep/tail로 당일 체결·거부를 즉시 전수 추출할 수 있게 한다. (dcy-029 FR-2)

Requirement

  • 집행 루프(execution.py)의 주문 dispatch/poll 경로에서 다음 이벤트를 일관된 안정적 키를 가진 한 줄 로그로 남긴다:
    • submit: side, symbol, slot_id, qty, limit_price(또는 시장가), order_type.
    • fill: side, symbol, slot_id, 체결가, 체결수량, fee, tax.
    • reject: side, symbol, slot_id, 거부 사유.
  • 로그 라인은 안정적 키(예: event=order_submit|order_fill|order_reject, symbol=, slot_id=)를 포함해 grep 필터가 가능해야 한다. JSON 포맷(REQ-084) 시 동일 필드가 구조화 키로 나간다.
  • correlation id(REQ-084)가 설정돼 있으면 submit/fill/reject 로그가 같은 id를 공유한다.
  • 기존 슬롯 전이/원장 기록 동작은 변경하지 않는다(로그 추가만, additive).

Acceptance Criteria

  1. Given 매수 주문 dispatch, When submit, Then event=order_submit + side/symbol/slot_id/qty/limit_price를 포함한 한 줄 로그가 남는다.
  2. Given 체결, When poll fill, Then event=order_fill + 체결가/체결수량/fee/tax를 포함한 로그가 남는다.
  3. Given 거부, When poll/ dispatch reject, Then event=order_reject + 사유를 포함한 로그가 남는다.
  4. Given TREX_LOG_FORMAT=json, When 위 이벤트, Then 해당 키들이 JSON 구조화 필드로 출력된다.
  5. Given 일련의 체결/거부, When grep "event=order_reject", Then 당일 거부 주문을 전수 추출할 수 있다.
  6. Given correlation id 설정 컨텍스트, When submit→fill, Then 두 로그가 동일 correlation id를 가진다.

Impacted Area

  • Docs: docs/runtime-flows.md(주문 집행 루프 — 결과 로깅)
  • Modules: trex_core/application/execution.py(_dispatch/_poll/_on_filled/_rollback 로깅), REQ-084 로깅 기반 소비
  • Tests: tests/application/test_execution* (submit/fill/reject 로그 caplog 단위)

Notes

  • FR-4(거부 ERROR 레벨)는 REQ-087에서 다룬다. 본 REQ는 submit/fill/reject의 일관 구조·가시성(레벨 무관)에 집중하되, reject 로그 라인은 REQ-087과 동일 지점에서 협조한다.
  • 출처: dcy-029 FR-2.

Change Log

CHG-20260616-01

  • Date: 2026-06-16
  • Author: Justin Ko

Change Summary

  • dcy-029 FR-2로부터 최초 생성(Proposed).

CHG-20260616-02

  • Date: 2026-06-16
  • Author: Justin Ko
  • Type: status
  • Summary: Proposed → Approved (confirm-req). 필수 필드·구체 AC 충족, source dcy-029(confirmed, Open OQ 0) 정합. dcy-029 P0/P1 batch 편성 예정.

CHG-20260616-IMPL

  • Date: 2026-06-16
  • Author: Justin Ko
  • Type: status
  • Summary: Approved → Implemented (confirm-req-implemented, BAT-045 release-candidate, dcy-029 P0). 근거: 단위 AC 매핑(logging_setup text/json/KST/cid/idempotent, execution 주문 결과 submit/fill/reject + cid=slot_id + 거부 ERROR). 35 passed(logging+execution_policy), 전체 529 passed/47 skipped 회귀 0, ruff clean. 실 Loki 적재는 release 운영 검증 위임. Blocking Issues 없음.