STK10-05 공매도 수집·영속화 (거래일/공시일)
작업 내용
공매도 거래·잔고 수직 슬라이스를 구현한다. 공시 시차(거래 T+1, 잔고 T+2)를 반영해 trade_date와 disclosed_date를 분리 저장한다 (ADR-005).
- domain:
ShortSellingEntity,ShortSellingRepository·ShortSellingGatewayinterface - infrastructure/krx:
KrxShortSellingGatewayImpl— bld 호출·파싱, 거래일 파싱 - infrastructure/mysql:
ShortSellingRepositoryImpl— 전종목 1회 JDBC 벌크 upsert(INSERT … ON DUPLICATE KEY UPDATE),(symbol, trade_date)키, 행 단위 save 금지
다이어그램
처리 흐름
sequenceDiagram participant DS as MarketFlowDomainService participant Gw as KrxShortSellingGatewayImpl participant Client as KrxMdcClient participant Repo as ShortSellingRepositoryImpl DS->>Gw: fetch(disclosedDate) Gw->>Client: getJsonData(bld, disclosedDate) Client-->>Gw: rows (tradeDate 포함) Gw-->>DS: List<ShortSelling> DS->>Repo: upsertAll(by tradeDate)
클래스 의존
flowchart LR Impl[KrxShortSellingGatewayImpl] -.implements.-> Gw[ShortSellingGateway] Impl --> Client[KrxMdcClient] RepoImpl[ShortSellingRepositoryImpl] -.implements.-> Repo[ShortSellingRepository]
테스트 케이스
- KRX JSON을 ShortSelling Entity로 파싱한다 (공매도 거래량·잔고비중 매핑)
- 거래일과 공시일을 분리 저장한다
- 동일
(symbol, trade_date)재적재 시 멱등 upsert된다 - 잔고 공시(T+2) 미도래 종목은 거래만 저장하고 잔고는 null로 둔다
- 전종목을 1회 벌크 upsert로 적재한다 (행 단위 save 미사용)
- 빈 응답 시 graceful 처리한다