# Complete - m-backtest-multi-timeframe-coverage/01_fill_policy

## 완료 일시

2026-06-20

## 요약

Backtest fill policy를 timeframe-neutral next-bar OHLC semantics로 정리하고, 3회 리뷰 루프 끝에 PASS로 종결했다.

## 루프 이력

| Plan | Review | Verdict | 메모 |
|------|--------|---------|------|
| `plan_local_G07_0.log` | `code_review_local_G07_0.log` | FAIL | pending limit carry-forward, order instrument enqueue, last-bar discard test evidence 보완 필요 |
| `plan_local_G07_1.log` | `code_review_local_G07_1.log` | FAIL | cross-instrument enqueue regression test가 실제 cross-instrument order를 만들지 않아 보완 필요 |
| `plan_local_G07_2.log` | `code_review_local_G07_2.log` | PASS | cross-instrument enqueue regression test 보강 후 PASS |

## 구현/정리 내용

- `FillPolicyNextBarOHLC`와 `FillOrderOnBar`를 canonical fill policy/helper로 추가하고 legacy daily 이름은 compatibility alias/wrapper로 유지했다.
- worker backtest engine을 same-instrument next available bar에서 `FillOrderOnBar`로 체결하도록 변경했다.
- 미체결 limit order는 이후 matching bar까지 pending으로 유지하고, 마지막 bar 이후 남은 pending order는 실행하지 않는 정책을 검증했다.
- strategy order enqueue를 현재 bar instrument가 아니라 `order.InstrumentID` 기준으로 수행하도록 검증했다.
- monthly/daily/minute deterministic backtest fixture evidence를 추가했다.

## 최종 검증

- `go test -count=1 ./services/worker/internal/backtest -run 'TestEngineQueuesOrdersByOrderInstrumentID'` - PASS; `ok git.toki-labs.com/toki/alt/services/worker/internal/backtest 0.004s`
- `go test -count=1 ./services/worker/internal/backtest -run 'TestEngine(DoesNotFillPendingOrderWithoutNextBar|QueuesOrdersByOrderInstrumentID|CarriesUncrossedLimitOrderToLaterMatchingBar)'` - PASS; `ok git.toki-labs.com/toki/alt/services/worker/internal/backtest 0.003s`
- `go test -count=1 ./packages/domain/...` - PASS; domain backtest, market, trading packages passed.
- `go test -count=1 ./services/worker/...` - PASS; worker packages passed, including `services/worker/internal/backtest`.
- `git diff --check` - PASS; no output.

## Roadmap Completion

- Milestone: `agent-roadmap/phase/backtest-loop/milestones/backtest-multi-timeframe-coverage.md`
- Completed task ids:
  - `fill-policy`: PASS; evidence=`plan_local_G07_0.log`, `code_review_local_G07_0.log`, `plan_local_G07_1.log`, `code_review_local_G07_1.log`, `plan_local_G07_2.log`, `code_review_local_G07_2.log`; verification=`go test -count=1 ./services/worker/...`
- Not completed task ids: 없음

## Spec Completion

- SDD: `agent-roadmap/sdd/backtest-loop/backtest-multi-timeframe-coverage/SDD.md`
- Completed scenario ids:
  - `S07`: PASS; task=`fill-policy`; evidence=`plan_local_G07_0.log`, `code_review_local_G07_0.log`, `plan_local_G07_1.log`, `code_review_local_G07_1.log`, `plan_local_G07_2.log`, `code_review_local_G07_2.log`; verification=`go test -count=1 ./services/worker/...`
- Not completed scenario ids: 없음

## 잔여 Nit

- 없음

## 후속 작업

- 없음
