feat: 국내주식 지정가 전환 및 미체결 처리 (#232) #233

Collaborator

Summary

  • KISBrokerget_domestic_pending_orders() (TTTC0084R, 실전전용/모의 즉시[]) 및 cancel_domestic_order() (실전 TTTC0013U / 모의 VTTC0013U) 추가
  • 국내 주문 price=0 → 지정가 전환 (2곳): BUY +0.2% / SELL -0.2%, kr_round_down KRX 틱 반올림 적용
  • handle_domestic_pending_orders 함수 추가 및 daily/realtime 두 모드에서 호출

세부 구현

src/broker/kis_api.py

  • get_domestic_pending_orders(): 모의 즉시 [], 실전 TTTC0084R GET 호출
  • cancel_domestic_order(): 실전 TTTC0013U / 모의 VTTC0013U, hashkey 필수, KRX_FWDG_ORD_ORGNO + ORGN_ODNO 포함

src/main.py

  • import kr_round_down 추가
  • trading_cycle 국내 주문: price=0kr_round_down(price * 1.002/0.998)
  • run_daily_session 국내 주문: 동일
  • handle_domestic_pending_orders: BUY→취소+쿨다운, SELL→취소+재주문(-0.4%, 최대1회)
  • daily/realtime 루프 내 domestic pending 체크 추가

테스트 (14개 신규)

  • test_broker.py: TestGetDomesticPendingOrders 3개 + TestCancelDomesticOrder 5개
  • test_main.py: TestHandleDomesticPendingOrders 4개 + TestDomesticLimitOrderPrice 2개

Test plan

  • pytest tests/test_broker.py -k "Domestic" — 8개 통과
  • pytest tests/test_main.py -k "Domestic" — 14개 통과
  • pytest --cov=src -q — 859 passed, 78% coverage
  • ruff check src/broker/kis_api.py — All checks passed
  • mypy src/broker/kis_api.py src/main.py --strict — 기존 오류만 (신규 없음)

Closes #232

🤖 Generated with Claude Code

## Summary - `KISBroker`에 `get_domestic_pending_orders()` (TTTC0084R, 실전전용/모의 즉시[]) 및 `cancel_domestic_order()` (실전 TTTC0013U / 모의 VTTC0013U) 추가 - 국내 주문 `price=0` → 지정가 전환 (2곳): BUY +0.2% / SELL -0.2%, `kr_round_down` KRX 틱 반올림 적용 - `handle_domestic_pending_orders` 함수 추가 및 daily/realtime 두 모드에서 호출 ## 세부 구현 ### `src/broker/kis_api.py` - `get_domestic_pending_orders()`: 모의 즉시 `[]`, 실전 `TTTC0084R` GET 호출 - `cancel_domestic_order()`: 실전 `TTTC0013U` / 모의 `VTTC0013U`, hashkey 필수, `KRX_FWDG_ORD_ORGNO` + `ORGN_ODNO` 포함 ### `src/main.py` - import `kr_round_down` 추가 - `trading_cycle` 국내 주문: `price=0` → `kr_round_down(price * 1.002/0.998)` - `run_daily_session` 국내 주문: 동일 - `handle_domestic_pending_orders`: BUY→취소+쿨다운, SELL→취소+재주문(-0.4%, 최대1회) - daily/realtime 루프 내 domestic pending 체크 추가 ### 테스트 (14개 신규) - `test_broker.py`: `TestGetDomesticPendingOrders` 3개 + `TestCancelDomesticOrder` 5개 - `test_main.py`: `TestHandleDomesticPendingOrders` 4개 + `TestDomesticLimitOrderPrice` 2개 ## Test plan - [x] `pytest tests/test_broker.py -k "Domestic"` — 8개 통과 - [x] `pytest tests/test_main.py -k "Domestic"` — 14개 통과 - [x] `pytest --cov=src -q` — 859 passed, 78% coverage - [x] `ruff check src/broker/kis_api.py` — All checks passed - [x] `mypy src/broker/kis_api.py src/main.py --strict` — 기존 오류만 (신규 없음) Closes #232 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-23 21:45:18 +09:00
- KISBroker에 get_domestic_pending_orders (TTTC0084R, 실전전용)
  및 cancel_domestic_order (실전 TTTC0013U / 모의 VTTC0013U) 추가
- main.py 국내 주문 price=0 → 지정가 전환 (2곳):
  · BUY +0.2% / SELL -0.2%, kr_round_down으로 KRX 틱 반올림 적용
- handle_domestic_pending_orders 함수 추가:
  · BUY 미체결 → 취소 + buy_cooldown 설정
  · SELL 미체결 → 취소 후 -0.4% 재주문 (최대 1회)
- daily/realtime 두 모드 market 루프 내 domestic pending 호출 추가
  (sell_resubmit_counts는 해외용과 공유, key prefix "KR:" vs 거래소코드)
- 테스트 14개 추가:
  · test_broker.py: TestGetDomesticPendingOrders 3개 + TestCancelDomesticOrder 5개
  · test_main.py: TestHandleDomesticPendingOrders 4개 + TestDomesticLimitOrderPrice 2개

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agentson added 1 commit 2026-02-23 21:45:53 +09:00
jihoson merged commit 425218c3be into feature/issue-229-overseas-pending-order-handling 2026-02-23 22:00:47 +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#233