feat: add shared account capital allocation policy
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
- Baseline Seed: .stage-pilot/bootstrap/baseline.yaml
|
||||
- Status: draft
|
||||
- Owner: project maintainers
|
||||
- Last Updated (KST): 2026-06-19 (BAT-047 — dcy-031 이벤트 발행 연결 신뢰성)
|
||||
- Last Updated (KST): 2026-07-29 (BAT-062 — 공통 계좌 자본배분 순수 정책)
|
||||
- Source Discovery / Batch: bootstrap-baseline (pre-Discovery, 3-phase lifecycle 밖의 bootstrap 산출물)
|
||||
|
||||
## Project Summary
|
||||
@@ -66,6 +66,7 @@
|
||||
│ ├── domain/slot/ # slot 순수 도메인 (BAT-001, 무의존)
|
||||
│ │ ├── __init__.py · state.py · models.py(+EXPECTED_SLOT_FIELDS) · errors.py
|
||||
│ │ ├── repository.py(Protocol, instance 스코프) · service.py · in_memory_repository.py
|
||||
│ ├── domain/capital_allocation.py # 전략 공통 계좌 자본배분 순수 정책 (BAT-062 / REQ-127)
|
||||
│ ├── domain/pricing.py # KRX 호가단위(tick) 산출 순수 함수 (BAT-044 / REQ-083, dcy-030)
|
||||
│ ├── application/ # 유스케이스 (BAT-002, BAT-004, BAT-006, BAT-007, BAT-008)
|
||||
│ │ ├── ports.py # IntentStore Protocol
|
||||
@@ -98,6 +99,7 @@
|
||||
│ └── cli.py # trex-core CLI: pause/resume/paused + universe/slots/enter/exit/cancel + report(REQ-088) (BAT-008/020/046 / REQ-032)
|
||||
└── tests/
|
||||
├── domain/slot/ # test_state / test_service / test_contract
|
||||
├── domain/test_capital_allocation.py # 메가·탑50 대표값 + 무작위 현금 불변식 (BAT-062)
|
||||
├── domain/ # test_domain_import_sweep (NFR-1 가드, BAT-006/BAT-007)
|
||||
├── application/ # test_intent_concurrency · test_execution · test_execution_ledger · test_ledger_outbox · test_messaging_intent_consumer · test_messaging_snapshot_consumer · test_messaging_event_publisher
|
||||
├── runtime/ # test_config_dotenv · test_daemon_no_http_surface (BAT-007 HTTP 표면 0 회귀 가드)
|
||||
@@ -112,6 +114,10 @@
|
||||
- `trex_core/domain/slot/`
|
||||
- 자산 중심 영구 슬롯 순수 도메인. 5 상태 머신(`state.py`, inactive 기준 + 인스턴스 스코프 advisory lock id), 데이터 모델 + 컬럼 계약(`models.py`, `EXPECTED_SLOT_FIELDS` 포함), 예외(`errors.py`), 저장소 계약(`repository.py` Protocol — instance 스코프 list/count/reconcile), 도메인 서비스(`service.py`), in-memory 구현(`in_memory_repository.py`).
|
||||
- 외부 의존 0 — stdlib 와 패키지 내부 참조만 사용(정적 import 스윕으로 확인됨).
|
||||
- `trex_core/domain/capital_allocation.py` (BAT-062 / dcy-042)
|
||||
- 계좌 가용 현금, 슬롯 수, 후보별 보호 한 주 가격을 받아 후보별 최대 배정액과 제외 사유를 결정한다.
|
||||
- 브로커·Portfolio Hub·전략·환경·저장소를 읽지 않는다. 호출 계층이 외부 입력과 후보·슬롯을 제공하고 최종 주문수량을 산출한다.
|
||||
- 최악 활성 슬롯 배정 합이 실제 현금을 넘지 않는 불변식을 모듈 내부와 속성 테스트에서 검증한다.
|
||||
- `trex_core/application/strategy_state.py` (BAT-042 / dcy-028)
|
||||
- slot strategy-state 저장소 경계: `StrategyStateStore` Protocol + `InMemoryStrategyStateStore` + 공용 `_cas`(occupancy_seq+version) + reject reason 상수 + byte size cap. opaque UTF-8 `data`(core 무해석). PG 구현은 `adapters/persistence/postgresql.py`의 `PgStrategyStateStore`(`slot_strategy_state` 테이블, 마이그레이션 014/015). 슬롯 본체에는 `Slot.occupancy_seq` 컬럼 1개만 추가(full 3계층 분할은 후속).
|
||||
- `tests/domain/slot/`
|
||||
@@ -123,7 +129,7 @@
|
||||
|
||||
## Dependency Rules
|
||||
|
||||
- 순수 도메인(`trex_core/domain/slot/`)은 저장소 구현, 브로커, 네트워크, CLI 등 인프라에 직접 의존하지 않는다.
|
||||
- 순수 도메인(`trex_core/domain/slot/`, `trex_core/domain/capital_allocation.py`)은 저장소 구현, 브로커, 네트워크, CLI 등 인프라에 직접 의존하지 않는다.
|
||||
- 저장소 접근은 오직 `SlotRepository` Protocol 을 통해서만 이뤄지고 구현체는 주입된다.
|
||||
- 인프라(향후 PostgreSQL 구현, CLI, config)는 도메인을 의존할 수 있으나 그 역은 금지한다.
|
||||
|
||||
@@ -161,3 +167,4 @@
|
||||
- 2026-06-07 :: BAT-013 — 다중 인스턴스 RabbitMQ 토폴로지(`topology.py` 동적 큐명 빌더 `intent/snapshot/control_queue(instance_key)` default 리터럴 하위호환 + `trex.direct`(topic)/`trex.broadcast`(fanout) exchange + `direct_routing_key`, `rabbitmq.declare_topology(instance_key)` per-instance 큐/바인딩+control dual, `config.DaemonInstanceConfig.from_toml`+`DaemonConfig.from_config`+`instance_key` 필드, daemon `--config` 필수 진입점 + instance_key 큐 구독, `.gitignore` 인스턴스 TOML + `config/instance.example.toml`) (REQ-048~051).
|
||||
- 2026-06-10 :: BAT-030 (dcy-020 마감) — 자산 중심 전환: `runtime/reset.py` + `trex-core-reset` 콘솔 스크립트(데이터 보존 cutover 폐기 — wipe+재초기화로 대체, REQ-064 CHG-20260610-03), `application/preallocation_scheduler.py` 삭제(일일 preallocation 폐기), 마이그레이션 010(inactive CHECK)/011(trading_date·entry_count drop), repo 계약 instance 스코프 개편, `ops_checks.py` transition_log 기반 재작성, config 에서 `total_slots`/`daily_preallocation_time` 제거 (REQ-056~065).
|
||||
- 2026-06-10 :: BAT-031 (dcy-021 포지션 사이징) — state.py(holding→pending_buy 전이), service.py(pending_sell qty sentinel), intents.py(증액 admission·SellIntent.qty), execution.py(부분 매도 dispatch·매수 체결 가중평균·브로커 정본 resync·증액 롤백), messaging_handlers.py(sell qty). 신규 코드 모듈 없음(기존 확장). (REQ-066/067/057/061/062)
|
||||
- 2026-07-29 :: BAT-062 (dcy-042 공통 계좌 자본배분) — `domain/capital_allocation.py` 순수 정책과 대표값·무작위 불변식 테스트 추가. 외부 현금·호가 조회와 최종 주문수량 산출은 호출 계층에 유지. (REQ-127)
|
||||
|
||||
Reference in New Issue
Block a user