KIS Open API 조회전용 연동 + 직접매매 절대금지 안전게이트

매수/매도 주문 및 계좌 잔고조회를 API로 직접 실행하지 않는다는 원칙을
코드 레벨에서 강제하는 안전게이트(governance/rules/06, 07)와 함께,
시세/호가/공매도거래비중 등 조회전용 KIS Open API 연동 및 SQLite
수집 파이프라인을 추가한다.

- kis_api_client_v1: 모든 요청이 _assert_read_only를 통과해야 하며
  /trading/ 경로·주문 TR_ID는 RuntimeError로 즉시 차단
- kis_data_collection_v1: KIS 우선 + Naver 폴백, 네트워크 실패는
  개별 ticker 단위로 흡수(배치 전체 중단 없음)
- data_collection_store_v1 / storage_backend_v1: SQLite 캐노니컬
  저장소, PostgreSQL 전환 대비 백엔드 추상화
- Gitea 영업일 스케줄(2시간 간격) + CI 강제 게이트
  (validate_no_direct_api_trading_v1, validate_kis_api_credentials_v1)
This commit is contained in:
2026-06-21 20:04:44 +09:00
parent 34f6eebba6
commit 4cb206a269
20 changed files with 2034 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
# Gitea Secrets Setup
이 저장소는 KIS Open API와 Gitea workflow를 분리해서 사용한다.
실제 시크릿 등록은 Gitea 관리자 권한이 있는 운영자가 수행해야 한다.
## Required Secrets
### Shared
- `GITHUB_TOKEN`
### KIS read-only validation
- `KIS_APP_KEY_TEST`
- `KIS_APP_SECRET_TEST`
### KIS real data collection
- `KIS_APP_KEY`
- `KIS_APP_SECRET`
## Workflow Mapping
- `.gitea/workflows/kis_data_collection.yml`
- mock validation: `KIS_APP_KEY_TEST`, `KIS_APP_SECRET_TEST`
- real collection: `KIS_APP_KEY`, `KIS_APP_SECRET`
- `.gitea/workflows/qualitative_sell_strategy.yml`
- mock validation: `KIS_APP_KEY_TEST`, `KIS_APP_SECRET_TEST`
- real collection: `KIS_APP_KEY`, `KIS_APP_SECRET`
- `.gitea/workflows/ci.yml`
- mock validation: `KIS_APP_KEY_TEST`, `KIS_APP_SECRET_TEST`
## Runtime Rule
- mock 계정은 유효성 확인용이다.
- real 계정은 실제 데이터 수집용이다.
- 둘을 같은 단계에서 혼용하지 않는다.
## Verification
Run:
```bash
python tools/validate_gitea_secrets_contract_v1.py
```
The validator checks that the workflows reference the required secret names
with the expected separation between mock and real usage.