kiwoompy 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.3
2
+ Name: kiwoompy
3
+ Version: 0.1.2
4
+ Summary: 키움증권 REST API Python 라이브러리
5
+ Author: meonji-gogo
6
+ Author-email: meonji-gogo <meonji-gogo@users.noreply.github.com>
7
+ Requires-Dist: httpx>=0.28.1
8
+ Requires-Dist: tenacity>=9.1.4
9
+ Requires-Dist: websockets>=16.0
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+
13
+ # kiwoompy
14
+
15
+ 키움증권 REST API를 Python에서 편하게 쓰기 위한 라이브러리입니다.
16
+
17
+ [![PyPI](https://img.shields.io/pypi/v/kiwoompy)](https://pypi.org/project/kiwoompy/)
18
+ [![Python](https://img.shields.io/pypi/pyversions/kiwoompy)](https://pypi.org/project/kiwoompy/)
19
+ [![Docs](https://img.shields.io/badge/docs-meonji--gogo.github.io-blue)](https://meonji-gogo.github.io/kiwoompy/)
20
+ [![License](https://img.shields.io/pypi/l/kiwoompy)](LICENSE)
21
+
22
+ ## 설치
23
+
24
+ ```bash
25
+ pip install kiwoompy
26
+ ```
27
+
28
+ uv 사용 시:
29
+
30
+ ```bash
31
+ uv add kiwoompy
32
+ ```
33
+
34
+ Python 3.12 이상이 필요합니다.
35
+
36
+ ## 사전 준비
37
+
38
+ [키움증권 OpenAPI](https://openapi.kiwoom.com)에서 앱을 등록하고 **App Key** / **App Secret**을 발급받아야 합니다.
39
+
40
+ > **주의** — App Key와 App Secret은 코드에 직접 넣지 마세요. 환경 변수나 시크릿 매니저로 관리하세요.
41
+
42
+ ## 빠른 시작
43
+
44
+ ```python
45
+ from kiwoompy import KiwoomClient
46
+
47
+ client = KiwoomClient(
48
+ env="demo", # "demo"(모의투자) / "real"(실계좌)
49
+ appkey="YOUR_APP_KEY",
50
+ secretkey="YOUR_APP_SECRET",
51
+ )
52
+
53
+ # 계좌 잔고 조회
54
+ balance = client.query.get_account_balance()
55
+ print(balance.tot_evlt_amt) # 총평가금액
56
+
57
+ for item in balance.holdings:
58
+ print(item.stk_nm, item.evlt_amt)
59
+ ```
60
+
61
+ ```python
62
+ # 시장가 매수
63
+ result = client.order.buy("005930", quantity="1", trade_type="market")
64
+ print(result.ord_no)
65
+
66
+ # 지정가 매도
67
+ client.order.sell("005930", quantity="1", trade_type="limit", price="75000")
68
+ ```
69
+
70
+ context manager도 지원합니다.
71
+
72
+ ```python
73
+ with KiwoomClient(env="demo", appkey="...", secretkey="...") as client:
74
+ deposit = client.query.get_deposit(query_type="normal")
75
+ print(deposit.entr) # 예수금
76
+ ```
77
+
78
+ ## 기능
79
+
80
+ - **OAuth2 인증** — 접근토큰 발급·만료 자동 관리
81
+ - **환경 분리** — 모의투자 / 실계좌 한 줄로 전환
82
+ - **유량 제어** — 모의 2건/초, 실전 20건/초 자동 적용
83
+ - **자동 재시도** — 네트워크 오류·5xx 지수 백오프 재시도 (최대 3회)
84
+ - **입력값 보완** — 계좌번호 상품코드 누락 시 자동 보완
85
+ - **타입 힌트** — IDE 자동완성·정적 분석 지원
86
+
87
+ ## 에러 처리
88
+
89
+ ```python
90
+ from kiwoompy import KiwoomAuthError, KiwoomApiError
91
+
92
+ try:
93
+ client = KiwoomClient(env="demo", appkey="wrong", secretkey="wrong")
94
+ except KiwoomAuthError as e:
95
+ print(f"인증 실패: {e}")
96
+ except KiwoomApiError as e:
97
+ print(f"API 오류: {e}")
98
+ ```
99
+
100
+ | 예외 | 발생 조건 |
101
+ |------|-----------|
102
+ | `KiwoomAuthError` | 잘못된 키, 토큰 미발급 상태에서 API 호출 |
103
+ | `KiwoomApiError` | 네트워크 오류, 5xx 서버 오류, 응답 파싱 실패 |
104
+
105
+ ## 문서
106
+
107
+ 전체 사용법과 API 레퍼런스는 문서 사이트를 참고해 주세요.
108
+
109
+ 👉 **https://meonji-gogo.github.io/kiwoompy**
110
+
111
+ ## 키움증권 REST API 공지 알리미
112
+
113
+ 키움증권 REST API 공지사항·변경 사항을 텔레그램으로 받아볼 수 있습니다.
114
+
115
+ 👉 **https://t.me/+2do4kWIhBmg3OTM1**
116
+
117
+ ## 라이선스
118
+
119
+ MIT
@@ -0,0 +1,107 @@
1
+ # kiwoompy
2
+
3
+ 키움증권 REST API를 Python에서 편하게 쓰기 위한 라이브러리입니다.
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/kiwoompy)](https://pypi.org/project/kiwoompy/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/kiwoompy)](https://pypi.org/project/kiwoompy/)
7
+ [![Docs](https://img.shields.io/badge/docs-meonji--gogo.github.io-blue)](https://meonji-gogo.github.io/kiwoompy/)
8
+ [![License](https://img.shields.io/pypi/l/kiwoompy)](LICENSE)
9
+
10
+ ## 설치
11
+
12
+ ```bash
13
+ pip install kiwoompy
14
+ ```
15
+
16
+ uv 사용 시:
17
+
18
+ ```bash
19
+ uv add kiwoompy
20
+ ```
21
+
22
+ Python 3.12 이상이 필요합니다.
23
+
24
+ ## 사전 준비
25
+
26
+ [키움증권 OpenAPI](https://openapi.kiwoom.com)에서 앱을 등록하고 **App Key** / **App Secret**을 발급받아야 합니다.
27
+
28
+ > **주의** — App Key와 App Secret은 코드에 직접 넣지 마세요. 환경 변수나 시크릿 매니저로 관리하세요.
29
+
30
+ ## 빠른 시작
31
+
32
+ ```python
33
+ from kiwoompy import KiwoomClient
34
+
35
+ client = KiwoomClient(
36
+ env="demo", # "demo"(모의투자) / "real"(실계좌)
37
+ appkey="YOUR_APP_KEY",
38
+ secretkey="YOUR_APP_SECRET",
39
+ )
40
+
41
+ # 계좌 잔고 조회
42
+ balance = client.query.get_account_balance()
43
+ print(balance.tot_evlt_amt) # 총평가금액
44
+
45
+ for item in balance.holdings:
46
+ print(item.stk_nm, item.evlt_amt)
47
+ ```
48
+
49
+ ```python
50
+ # 시장가 매수
51
+ result = client.order.buy("005930", quantity="1", trade_type="market")
52
+ print(result.ord_no)
53
+
54
+ # 지정가 매도
55
+ client.order.sell("005930", quantity="1", trade_type="limit", price="75000")
56
+ ```
57
+
58
+ context manager도 지원합니다.
59
+
60
+ ```python
61
+ with KiwoomClient(env="demo", appkey="...", secretkey="...") as client:
62
+ deposit = client.query.get_deposit(query_type="normal")
63
+ print(deposit.entr) # 예수금
64
+ ```
65
+
66
+ ## 기능
67
+
68
+ - **OAuth2 인증** — 접근토큰 발급·만료 자동 관리
69
+ - **환경 분리** — 모의투자 / 실계좌 한 줄로 전환
70
+ - **유량 제어** — 모의 2건/초, 실전 20건/초 자동 적용
71
+ - **자동 재시도** — 네트워크 오류·5xx 지수 백오프 재시도 (최대 3회)
72
+ - **입력값 보완** — 계좌번호 상품코드 누락 시 자동 보완
73
+ - **타입 힌트** — IDE 자동완성·정적 분석 지원
74
+
75
+ ## 에러 처리
76
+
77
+ ```python
78
+ from kiwoompy import KiwoomAuthError, KiwoomApiError
79
+
80
+ try:
81
+ client = KiwoomClient(env="demo", appkey="wrong", secretkey="wrong")
82
+ except KiwoomAuthError as e:
83
+ print(f"인증 실패: {e}")
84
+ except KiwoomApiError as e:
85
+ print(f"API 오류: {e}")
86
+ ```
87
+
88
+ | 예외 | 발생 조건 |
89
+ |------|-----------|
90
+ | `KiwoomAuthError` | 잘못된 키, 토큰 미발급 상태에서 API 호출 |
91
+ | `KiwoomApiError` | 네트워크 오류, 5xx 서버 오류, 응답 파싱 실패 |
92
+
93
+ ## 문서
94
+
95
+ 전체 사용법과 API 레퍼런스는 문서 사이트를 참고해 주세요.
96
+
97
+ 👉 **https://meonji-gogo.github.io/kiwoompy**
98
+
99
+ ## 키움증권 REST API 공지 알리미
100
+
101
+ 키움증권 REST API 공지사항·변경 사항을 텔레그램으로 받아볼 수 있습니다.
102
+
103
+ 👉 **https://t.me/+2do4kWIhBmg3OTM1**
104
+
105
+ ## 라이선스
106
+
107
+ MIT
@@ -0,0 +1,40 @@
1
+ [project]
2
+ name = "kiwoompy"
3
+ version = "0.1.2"
4
+ description = "키움증권 REST API Python 라이브러리"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "meonji-gogo", email = "meonji-gogo@users.noreply.github.com" }
8
+ ]
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "httpx>=0.28.1",
12
+ "tenacity>=9.1.4",
13
+ "websockets>=16.0",
14
+ ]
15
+
16
+ [dependency-groups]
17
+ docs = [
18
+ "mkdocs-material>=9.6,<10",
19
+ "mkdocs>=1.6,<2",
20
+ "mkdocstrings[python]>=0.29",
21
+ ]
22
+
23
+ dev = [
24
+ "pytest-mock>=3.15.1",
25
+ "python-dotenv>=1.2.1",
26
+ ]
27
+
28
+
29
+ [build-system]
30
+ requires = ["uv_build>=0.9.28,<0.10.0"]
31
+ build-backend = "uv_build"
32
+
33
+ [tool.pytest.ini_options]
34
+ testpaths = ["tests"]
35
+ addopts = "--ignore=tests/e2e"
36
+ markers = [
37
+ "mock: 단위 테스트, 외부 의존 없음 (CI 실행)",
38
+ "demo: 모의투자 환경 e2e 테스트 (로컬 전용)",
39
+ "real: 실계좌 환경 e2e 테스트 (로컬 전용, 실제 주문 발생 가능)",
40
+ ]