Files
QuantEngineByItz/spec/55_execution_simulator_contract.yaml
T
kjh2064 13e9ccad55 WBS-7.6/7.9/7.7: 슬리피지 보정 + Naver 모니터링 + E2E 통합테스트
WBS-7.6 (슬리피지 5bps 보정):
- 이론치 5bps를 calibration_registry.yaml에 EXECUTION_SLIPPAGE_BPS 등록
- spec/55_execution_simulator_contract.yaml에서 threshold 참조로 변경
- calibration_trigger: 실제 거래 20건 누적 후 actual_slippage 추적해 필요시 보정

WBS-7.9 (Naver 스크래핑 Cloudflare 403 모니터링):
- tools/fetch_naver_market_data_v1.py: HTTP 403 감지 시 CLOUDFLARE_BLOCKED_403 상태 반환
- 구조화된 에러 처리로 무조건 실패 대신 graceful degradation 가능
- spec/exit/qualitative_sell_strategy_v1.yaml: WBS-7.9 처리 문서화
- 실제 차단 발생 시 대체 경로 없음(KRX=OTP 필수, investing.com=이미 차단)
  → 운영: 차단 발생 시 수동 실행 또는 slack 경고

WBS-7.7 (E2E 통합테스트):
- 기존 tests/integration/test_kis_collection_to_snapshot_admin_and_sell_strategy_v1.py 검증
- 3개 테스트 모두 PASS:
  * KIS 수집 → SQLite 적재 → snapshot_admin 대시보드 읽기 round-trip
  * Naver 폴백 차단 시 graceful degradation 검증 (개별 ticker 실패 흡수)
  * 정성매도전략 평가 → SQLite 저장 → 조회 round-trip
- 네트워크 미사용 (mock 데이터, graceful failure)으로 CI 안정성 확보

전체 테스트: 135/135 PASS (unit 61 + integration 3 + formula/formula_registry/... 71)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-22 23:02:33 +09:00

75 lines
2.6 KiB
YAML

schema_version: execution_simulator_contract.v1
contract_id: H004_EXECUTION_SIMULATOR
harness_file: tools/validate_execution_simulator_v1.py
authority: spec/55_execution_simulator_contract.yaml
has_code_implementation: true
code_path: "tools/validate_execution_simulator_v1.py"
created_at: '2026-06-10T23:29:00+09:00'
purpose: >
틱 정규화, 최소주문수량, 예수금, D+2 현금, 슬리피지 적용 후
실제 주문 가능성을 검증한다. 유효하지 않은 주문이 단 1건이라도
있으면 릴리즈를 차단한다.
simulation_parameters:
tick_normalization:
rule: 가격은 해당 종목의 호가단위(tick size)로 내림하여 정규화
source: spec/13_formula_registry.yaml → TICK_NORMALIZATION_V1
minimum_order_quantity:
krx_stock: 1주
etf: 1주
slippage_model:
type: fixed_spread
bps: calibration_registry.EXECUTION_SLIPPAGE_BPS
note: >
시장가 주문 기준 평균 슬리피지. WBS-7.6(2026-06-22)에서
spec/calibration_registry.yaml의 EXECUTION_SLIPPAGE_BPS(5bps, EXPERT_PRIOR)로
정규화. 실측 거래 데이터 20건 이상 누적 후 actual_slippage 추적해
필요시 보정 (차이 > 1bps 시).
cash_floor:
d_plus_2_recognition: true
minimum_reserve_krw: 10000000
note: D+2 결제 예정 현금은 즉시 가용 현금으로 인정하되, 매수 후 잔여 현금이 최소 준비금 미만이면 차단
goal_target_krw: 500000000
inputs:
- field: final_decision_packet_active.json
source: Temp/final_decision_packet_active.json
required: true
- field: account_snapshot
source: spec/15_account_snapshot_contract.yaml
required: true
output_fields:
- name: invalid_order_count
type: int
description: 틱·수량·현금 조건 위반 주문 수
- name: cash_floor_after_orders_krw
type: float
description: 모든 매수 주문 실행 후 예상 잔여 현금
- name: slippage_adjusted_orders
type: list[dict]
description: 슬리피지 반영 후 최종 주문 목록
- name: gate
type: str
enum: [PASS, FAIL]
acceptance_criteria:
- invalid_order_count: 0
- cash_floor_after_orders_krw_gte_required: true
hard_gates:
- gate_id: NO_INVALID_ORDERS
condition: invalid_order_count == 0
on_fail: BLOCK_RELEASE
- gate_id: CASH_FLOOR_MAINTAINED
condition: cash_floor_after_orders_krw >= minimum_reserve_krw
on_fail: BLOCK_RELEASE
- gate_id: TICK_NORMALIZED
condition: all order prices are tick-normalized
on_fail: BLOCK_RELEASE
owner: risk_manager
lifecycle_state: active
retirement_condition: >
실제 증권사 API 연동 시뮬레이터로 교체될 때까지 유효하다.