KIS Open API → Vellab Live Trading Integration Playbook (KR Equities)

2026-02-24 · finance

KIS Open API → Vellab Live Trading Integration Playbook (KR Equities)

Date: 2026-02-24 (KST)

TL;DR

If Vellab is moving from research-only into Korean live execution, the first bottleneck is not alpha — it is broker/API reliability and control-plane discipline.

This playbook distills what matters most for a safe first rollout with 한국투자증권(KIS) Open API:

  1. Implement hard API guardrails first (rate limits, reconnect policy, idempotency)
  2. Treat live trading as a state machine + reconciliation system, not “call order endpoint and pray”
  3. Encode KR market/session constraints + legal no-go patterns into pre-trade checks
  4. Ship in phases (paper shadow → tiny real notional → capped ramp)

1) Verified KIS Operational Constraints (Must Encode in Code)

1.1 Auth + Endpoint Shape

From official KIS sample/auth artifacts:

Implementation note: store AppKey/Secret in secret manager only (no git, no plaintext dotfiles in repo).

1.2 Official Rate/Session Limits (공지 기반)

KIS official notice (“API 호출 유량 안내 (REST, 웹소켓) (2025.08.07 기준)”) states:

Design implication:

1.3 Reconnect Abuse Risk (New 2026 notice)

Official 2026-02-24 notice warns: repeated connect/disconnect loops or endless subscribe/unsubscribe loops can cause temporary block of IP + appkey.

Design implication:

1.4 Service Lifecycle Constraints (Legacy OpenAPI page still useful)

Design implication: build monthly “service liveness check” ops task; never discover expiration during market open.


2) KR Market + Legal Constraints to Encode (Not Optional)

2.1 Session-Time Gating

For KRX equities, baseline windows (as summarized in 생활법령정보):

Engine impact:

2.2 Market Abuse Guardrails

Automated systems are still fully subject to 자본시장법 (e.g., 시세조종행위 금지, 제176조).

Practical controls for bots:

This must be represented as machine-enforced risk rules, not policy text only.


3) Vellab Reference Architecture for KIS Integration

3.1 Core Components

  1. Broker Adapter (broker-kis)
    • REST client, WS client, auth/token manager
    • TR-ID mapping + request builders
  2. Execution Orchestrator
    • parent→child slicing, urgency policy, retry policy
  3. Risk Gateway
    • pre-trade checks (session, max notional, max position, kill-switch state)
  4. Order State Store
    • durable order intents + broker ack/fill events
  5. Reconciliation Worker
    • periodic compare: local state vs broker state (orders, fills, positions, cash)
  6. Telemetry + Alerting
    • latency, reject code distribution, limiter hits, reconnect count, stale stream age

3.2 Minimal Interface Contract

interface BrokerGateway {
  placeOrder(intent: OrderIntent): Promise<BrokerAck>
  cancelOrder(orderId: string): Promise<CancelAck>
  replaceOrder(orderId: string, patch: ReplacePatch): Promise<ReplaceAck>
  getOpenOrders(account: string): Promise<BrokerOrder[]>
  getPositions(account: string): Promise<Position[]>
  streamTicks(symbols: string[], onTick: (t: Tick) => void): Unsubscribe
}

Keep strategy code broker-agnostic. KIS-specific quirks stay in adapter layer.

3.3 Order Lifecycle State Machine

Recommended durable states:

INTENT_CREATED -> SUBMITTED -> ACKED -> PARTIAL_FILLED -> FILLED

with side branches:

REJECTED, CANCEL_PENDING -> CANCELED, EXPIRED, RECONCILE_REQUIRED

Never treat HTTP 200 as final fill truth.


4) Implementation Plan (Phased, Low-Blast-Radius)

Phase 0 — Connectivity + Auth Hardening

Exit criteria: 1-week paper soak with zero runaway loops.

Phase 1 — Read-Only Reliability Layer

Exit criteria: state drift MTTR < 5 min in test runs.

Phase 2 — Paper Trading Execution

Exit criteria: 200+ paper orders, deterministic lifecycle integrity.

Phase 3 — Tiny Real Capital Pilot

Exit criteria: two weeks without unresolved reconcile break.

Phase 4 — Controlled Ramp


5) KIS-Specific Engineering Checklist


6) Suggested First Vellab Backlog Tickets

  1. feat(api): add broker gateway abstraction + persistence schema
  2. feat(kis): oauth token manager + approval key manager
  3. feat(kis): rate limiter buckets (real/paper/token)
  4. feat(kis-ws): resilient stream client with exponential backoff
  5. feat(exec): order intent state machine + event log
  6. feat(risk): KR session gate + max loss/day + max order value
  7. feat(reconcile): broker-vs-local drift checker
  8. feat(obs): execution reliability dashboard panels

7) References


One-line takeaway

For KIS live trading, your edge comes from execution reliability + compliance-safe automation discipline before model sophistication.