feat: Triple Barrier 시간장벽을 캘린더 분 기반으로 전환 (#329) #346

Merged
jihoson merged 2 commits from feature/issue-329-triple-barrier-calendar-minutes into feature/v3-session-policy-stream 2026-03-01 09:57:01 +09:00
Collaborator

Summary

  • backtest 파이프라인에서 Triple Barrier의 분 기반 시간장벽을 실제 사용하도록 연결
  • BacktestBartimestamp 필드 추가(옵션)
  • max_holding_minutes 사용 시 모든 bar의 timestamp 존재를 강제 검증
  • 통합 테스트를 max_holding_bars에서 max_holding_minutes 기준으로 전환
  • timestamp 누락 시 실패하는 검증 테스트 추가

Test

  • pytest -q tests/test_triple_barrier.py tests/test_backtest_pipeline_integration.py
  • python3 -m py_compile src/analysis/backtest_pipeline.py tests/test_backtest_pipeline_integration.py

Refs: #329

## Summary - backtest 파이프라인에서 Triple Barrier의 분 기반 시간장벽을 실제 사용하도록 연결 - `BacktestBar`에 `timestamp` 필드 추가(옵션) - `max_holding_minutes` 사용 시 모든 bar의 timestamp 존재를 강제 검증 - 통합 테스트를 `max_holding_bars`에서 `max_holding_minutes` 기준으로 전환 - timestamp 누락 시 실패하는 검증 테스트 추가 ## Test - `pytest -q tests/test_triple_barrier.py tests/test_backtest_pipeline_integration.py` - `python3 -m py_compile src/analysis/backtest_pipeline.py tests/test_backtest_pipeline_integration.py` Refs: #329
agentson added 1 commit 2026-03-01 09:44:33 +09:00
feat: switch backtest triple barrier to calendar-minute horizon (#329)
Some checks failed
Gitea CI / test (pull_request) Waiting to run
Gitea CI / test (push) Has been cancelled
701350fb65
agentson reviewed 2026-03-01 09:48:29 +09:00
agentson left a comment
Author
Collaborator

PR #346 Review: ACT-12 Triple Barrier 시간장벽 backtest pipeline 연결

LGTM

플랜 준수: ACT-12 (GAP-5, #329) — Triple Barrier 시간장벽을 캘린더 시간(분) 기반으로 전환. PR #334(triple_barrier.py)의 후속으로 backtest pipeline 연결 완성.

구현 품질:

  • BacktestBar.timestamp: datetime | None = None 기본값으로 하위 호환 유지
  • max_holding_minutes 설정 시에만 timestamp 필요 — 불필요한 제약 없음
  • any(ts is None for ts in timestamps) 전수 검사로 조용한 오동작 방지 (ValueError 즉시 발생)
  • 기존 테스트 3개 max_holding_barsmax_holding_minutes 마이그레이션 + _bars() 헬퍼 timestamp 추가
  • 신규 테스트: timestamp 누락 시 ValueError 확인

Nit (optional, 머지 차단 아님):

# 이 코드에서
if any(ts is None for ts in timestamps):
    raise ValueError(...)
resolved_timestamps = [ts for ts in timestamps if ts is not None]  # ← None 없음이 이미 보장됨

위 체크를 통과한 시점에서 if ts is not None 필터는 논리적으로 불필요합니다. mypy 타입 추론을 위한 코드라면 # type: ignore 또는 cast() 쪽이 의도를 더 명확히 표현합니다.

## PR #346 Review: ACT-12 Triple Barrier 시간장벽 backtest pipeline 연결 ### ✅ LGTM **플랜 준수**: ACT-12 (GAP-5, #329) — Triple Barrier 시간장벽을 캘린더 시간(분) 기반으로 전환. PR #334(triple_barrier.py)의 후속으로 backtest pipeline 연결 완성. **구현 품질:** - `BacktestBar.timestamp: datetime | None = None` 기본값으로 하위 호환 유지 - `max_holding_minutes` 설정 시에만 timestamp 필요 — 불필요한 제약 없음 - `any(ts is None for ts in timestamps)` 전수 검사로 조용한 오동작 방지 (ValueError 즉시 발생) - 기존 테스트 3개 `max_holding_bars` → `max_holding_minutes` 마이그레이션 + `_bars()` 헬퍼 timestamp 추가 - 신규 테스트: timestamp 누락 시 ValueError 확인 **Nit (optional, 머지 차단 아님):** ```python # 이 코드에서 if any(ts is None for ts in timestamps): raise ValueError(...) resolved_timestamps = [ts for ts in timestamps if ts is not None] # ← None 없음이 이미 보장됨 ``` 위 체크를 통과한 시점에서 `if ts is not None` 필터는 논리적으로 불필요합니다. mypy 타입 추론을 위한 코드라면 `# type: ignore` 또는 `cast()` 쪽이 의도를 더 명확히 표현합니다.
agentson added 1 commit 2026-03-01 09:50:47 +09:00
refactor: simplify timestamp normalization after non-null validation (#329)
Some checks are pending
Gitea CI / test (push) Waiting to run
Gitea CI / test (pull_request) Waiting to run
273a3c182a
Author
Collaborator

리뷰 nit 반영했습니다.\n\n- 를 제거하고, non-null 검증 직후 로 의도 명시\n- 테스트: ..... [100%]
5 passed in 0.16s (5 passed)\n- 컴파일: \n\n반영 커밋:

리뷰 nit 반영했습니다.\n\n- 를 제거하고, non-null 검증 직후 로 의도 명시\n- 테스트: ..... [100%] 5 passed in 0.16s (5 passed)\n- 컴파일: \n\n반영 커밋:
Author
Collaborator

리뷰 nit 반영했습니다.

  • resolved_timestamps = [ts for ts in timestamps if ts is not None] 제거
  • non-null 검증 직후 cast(list[datetime], timestamps)로 의도 명시

검증:

  • pytest -q tests/test_backtest_pipeline_integration.py (5 passed)
  • python3 -m py_compile src/analysis/backtest_pipeline.py

반영 커밋: 273a3c1

리뷰 nit 반영했습니다. - `resolved_timestamps = [ts for ts in timestamps if ts is not None]` 제거 - non-null 검증 직후 `cast(list[datetime], timestamps)`로 의도 명시 검증: - `pytest -q tests/test_backtest_pipeline_integration.py` (5 passed) - `python3 -m py_compile src/analysis/backtest_pipeline.py` 반영 커밋: `273a3c1`
agentson reviewed 2026-03-01 09:52:00 +09:00
agentson left a comment
Author
Collaborator

Nit 반영 확인

cast(list[datetime], timestamps) 로 교체 확인. 바로 위 any(ts is None) 체크가 None 부재를 보장하므로 런타임 비용 없이 타입 체커 만족 — 정확한 접근입니다. from typing import cast import 추가도 확인.

LGTM.

## Nit 반영 확인 ✅ `cast(list[datetime], timestamps)` 로 교체 확인. 바로 위 `any(ts is None)` 체크가 None 부재를 보장하므로 런타임 비용 없이 타입 체커 만족 — 정확한 접근입니다. `from typing import cast` import 추가도 확인. LGTM.
jihoson merged commit 2ba1d1ad4d into feature/v3-session-policy-stream 2026-03-01 09:57:01 +09:00
jihoson deleted branch feature/issue-329-triple-barrier-calendar-minutes 2026-03-01 09:57:01 +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#346