Skip to main content

kis-trader

check PyPI Python License

한국어 | English

한국투자증권(한투) KIS Open API를 타입을 갖춘 깔끔한 파이썬 API로 감싼 비공식 클라이언트입니다.

  • 넓은 범위 — 국내·해외 주식·지수·ETF·ETN·ELW·선물옵션·채권의 시세·재무·수급, 계좌 잔고·손익, 순위·조건검색, 시장·일정, 퇴직연금.
  • 주문 — 매수·매도·정정·취소, 신용·예약·TWAP/VWAP 분할.
  • 안전 코어 — 같은 주문의 중복 전송은 기본 차단되고, 타임아웃 시 재전송하지 않고 reconcile() 로 접수 여부를 직접 확인합니다. 신용거래는 기본 차단. 전송 전 리스크 한도는 KISClient(..., risk=RiskLimits(...))로 명시해 사용합니다.
  • 실시간 — 시세·호가·체결통보를 WebSocket으로 수신.
  • 세 가지 인터페이스 — 파이썬 API · 터미널 명령 kis · AI 에이전트용 MCP 서버/스킬.

1. 설치

pip install kis-trader

파이썬 3.11 이상이 필요합니다.

Claude Desktop 같은 AI 에이전트에서 MCP 서버로 쓰려면 mcp 옵션을 함께 설치합니다:

pip install 'kis-trader[mcp]'

2. 빠른 시작

from kis_trader import KISClient

kis = KISClient(app_key="…", app_secret="…", account="12345678-01", environment="paper")

kis.domestic.stock("005930").quote()                 # 삼성전자 현재가
kis.overseas.stock("AAPL").quote()                   # 애플 (거래소 자동 판별)
kis.domestic.ranking.by_change(direction="gainers")  # 오늘 상승률 순위

터미널에서 kis config 를 실행하면 계좌 종류별로 앱키와 계좌를 대화형으로 입력받아 저장합니다. 환경변수나 KISConfig(...).save() 로 저장할 수도 있으며, 한 번 저장해 두면 이후 KISClient() 를 인자 없이 열 수 있습니다. 프로필(계좌 종류)과 환경(실전/모의)은 별도 축이라, 같은 프로필을 환경만 바꿔 실전·모의로 각각 엽니다 -- 먼저 모의로 주문 흐름을 확인한 뒤 실전으로 옮겨도 됩니다. 발급과 저장은 자격증명과 프로필 문서를 참고하세요.

3. 구조

KISClient 아래에 자산군과 주문이 네임스페이스로 분리되어 있습니다.

kis.domestic   # 국내: 주식·지수·ETF·ELW·선물옵션·채권·순위·시장·일정
kis.overseas   # 해외: 주식·지수·선물옵션·순위
kis.account    # 계좌 조회 (잔고·손익·보유·미체결; .domestic/.overseas 시장별 뷰, IRP는 .pension 퇴직연금)
kis.orders     # 접수한 주문의 조회(미체결)·확인·정정·취소

종목과 계약은 핸들로 잡으면 시세 조회부터 주문까지 그대로 이어집니다.

kis.domestic.stock("005930")     # 국내 주식 -- 현재가·차트·호가·매수·매도
kis.overseas.stock("AAPL")       # 해외 주식 -- 거래소 자동 판별
kis.domestic.futures("101W09")   # 지수선물
kis.domestic.option("201W09350")    # 지수옵션

4. 주문

report = kis.domestic.stock("005930").buy(quantity=10, limit_price=70000)  # 10주 매수
kis.orders.modify(report.client_order_id, limit_price=70500)   # 가격 정정
kis.orders.cancel(report.client_order_id)                      # 취소

전송 타임아웃 등으로 접수 여부가 불명일 때만 kis.orders.reconcile(report.client_order_id) 로 상태를 확정합니다(완료된 주문엔 저장소에 남은 결과를 돌려줄 뿐 증권사 재조회는 하지 않습니다).

주문은 되돌릴 수 없습니다. 중복 주문을 막는 안전장치가 기본으로 동작합니다(신용거래는 기본 차단). 자세한 규칙은 주문 문서에 있습니다.

5. 명령줄 (kis)

설치하면 kis 터미널 명령이 함께 설치됩니다. 파이썬 코드를 쓰지 않고도 터미널에서 바로 조회하고 주문할 수 있습니다. 주문은 --execute 를 붙이기 전까지는 실제로 전송되지 않습니다(기본이 dry-run).

kis config                      # 자격증명을 대화형으로 입력받아 프로필에 저장
kis stock quote 005930
kis search 삼성전자
kis ranking change --direction gainers
kis account balance
kis order buy 005930 10 --limit-price 70000
kis order buy 005930 10 --limit-price 70000 --execute paper --yes

채권·선물·옵션·해외·예약주문·TWAP 등 전체 명령과 옵션은 명령줄 문서를 보세요.

6. AI 코딩 에이전트에서 사용

Claude Code·Codex 같은 AI 도구로 계좌를 다루려면 plugins/kis-trader/skills/kis-trader/ 스킬을 씁니다. Claude 스킬 · Codex 스킬 문서를 참고하세요.

MCP 호환 에이전트(Claude Desktop 등)에서는 kis_trader.mcp 서버(pip install 'kis-trader[mcp]' 후 kis-mcp)로 계좌 조회·주문 미리보기와 국내·해외 주식 주문·정정·취소 도구를 쓸 수 있습니다. 채팅에서 보는 계좌·환경을 재시작 없이 바꿀 수 있고, 기본은 모의투자이며, 실전 주문은 이중 잠금·사람 확인·세션 서킷브레이커를 거칩니다(신규·정정은 RiskLimits 와 종목 허용목록까지; 취소는 노출을 줄이므로 제외). MCP 서버 문서를 참고하세요.

7. 문서

전체 문서는 https://seokhoonj.github.io/kis-trader/ 에 있습니다(소스: docs/).

파트 장
시작하기 빠른 시작 · 앱키 발급 · 자격증명과 프로필
국내 주식 시세 · 재무·실적 · 종목 수급 · 계좌·손익 · 주문
시장·검색 순위·조건검색 · 시장·지수 · 기업행위·일정
해외·연금 해외주식 · 퇴직연금
다른 상품 ETF·ETN · ELW · 선물·옵션 · 채권
명령줄·에이전트 Command Line · Claude Code Skill · Codex Skill · MCP Server
참고 실시간(WebSocket) · 한계·미구현

각 메서드의 인자와 반환값은 파이썬 help() 로 바로 확인할 수 있습니다 (예: help(kis.domestic.stock)).

8. 라이선스

MIT

Metadata

Release files for kis-trader 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kis-trader 0.9.0
File Size Uploaded
kis_trader-0.9.0.tar.gz 987.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kis-trader 0.9.0
File Interpreter ABI Platform
kis_trader-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.7 MB

Release files / kis_trader-0.9.0.tar.gz

Download URL kis_trader-0.9.0.tar.gz
Size 987.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f3c1a44d26a4c484eb723a6ec4e46097ae63c4d8aee6c9e94332cbbdc8715333
BLAKE2b-256 checksum
How to use checksums
635fb1bedce1a6192da95d9a320cff13949473090d2ad1dc49257aad94137677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / kis_trader-0.9.0-py3-none-any.whl

Download URL kis_trader-0.9.0-py3-none-any.whl
Size 689.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a98eff502acda1af50443c944e38b2409b761590c800cdea3a40e7efcd02c59
BLAKE2b-256 checksum
How to use checksums
c76923ed9759b44bb2ccc91c7d8242eaf5c7eb1a4f8c72b8b9977c9d438a6c4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.10.0

2 release files

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page