ksxt 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl
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.
- ksxt/__init__.py +3 -1
- ksxt/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/__pycache__/bithumb.cpython-312.pyc +0 -0
- ksxt/__pycache__/koreainvest.cpython-312.pyc +0 -0
- ksxt/__pycache__/upbit.cpython-312.pyc +0 -0
- ksxt/api/__init__.py +26 -0
- ksxt/api/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/api/__pycache__/bithumb.cpython-312.pyc +0 -0
- ksxt/api/__pycache__/koreainvest.cpython-312.pyc +0 -0
- ksxt/api/__pycache__/upbit.cpython-312.pyc +0 -0
- ksxt/api/auto/api_generator.py +54 -0
- ksxt/api/auto/bithumb.py +35 -0
- ksxt/api/auto/koreainvest.py +49 -0
- ksxt/api/auto/upbit.py +39 -0
- ksxt/api/bithumb.py +42 -0
- ksxt/api/koreainvest.py +40 -0
- ksxt/api/upbit.py +54 -0
- ksxt/async_/__init__.py +4 -0
- ksxt/async_/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/async_/__pycache__/bithumb.cpython-312.pyc +0 -0
- ksxt/async_/__pycache__/koreainvest.cpython-312.pyc +0 -0
- ksxt/async_/__pycache__/upbit.cpython-312.pyc +0 -0
- ksxt/async_/base/__init__.py +0 -0
- ksxt/async_/base/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/async_/base/__pycache__/async_exchange.cpython-312.pyc +0 -0
- ksxt/async_/base/__pycache__/throttler.cpython-312.pyc +0 -0
- ksxt/async_/base/async_exchange.py +232 -0
- ksxt/async_/base/throttler.py +63 -0
- ksxt/async_/bithumb.py +455 -0
- ksxt/async_/koreainvest.py +849 -0
- ksxt/async_/upbit.py +488 -0
- ksxt/base/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/base/__pycache__/errors.cpython-312.pyc +0 -0
- ksxt/base/__pycache__/exchange.cpython-312.pyc +0 -0
- ksxt/base/__pycache__/rest_exchange.cpython-312.pyc +0 -0
- ksxt/base/__pycache__/types.cpython-312.pyc +0 -0
- ksxt/base/com_exchange.py +2 -2
- ksxt/base/errors.py +10 -0
- ksxt/base/exchange.py +188 -497
- ksxt/base/rest_exchange.py +297 -113
- ksxt/base/types.py +1 -36
- ksxt/bithumb.py +504 -0
- ksxt/config/__init__.py +2 -1
- ksxt/config/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/config/bithumb.toml +380 -0
- ksxt/config/koreainvest.toml +312 -0
- ksxt/config/token.toml +7 -0
- ksxt/config/upbit.toml +428 -0
- ksxt/koreainvest.py +409 -1055
- ksxt/market/__pycache__/base.cpython-312.pyc +0 -0
- ksxt/market/__pycache__/db.cpython-312.pyc +0 -0
- ksxt/market/__pycache__/logging.cpython-312.pyc +0 -0
- ksxt/market/__pycache__/manager.cpython-312.pyc +0 -0
- ksxt/market/__pycache__/markets.cpython-312.pyc +0 -0
- ksxt/market/base.py +50 -50
- ksxt/market/db.py +5 -4
- ksxt/market/krx/__pycache__/kosdaq.cpython-312.pyc +0 -0
- ksxt/market/krx/__pycache__/kospi.cpython-312.pyc +0 -0
- ksxt/market/krx/__pycache__/stock.cpython-312.pyc +0 -0
- ksxt/market/krx/kosdaq.py +150 -147
- ksxt/market/krx/kospi.py +179 -175
- ksxt/market/krx/stock.py +136 -134
- ksxt/market/logging.py +4 -4
- ksxt/market/manager.py +10 -12
- ksxt/market/markets.py +1 -1
- ksxt/market/us/__pycache__/amex.cpython-312.pyc +0 -0
- ksxt/market/us/__pycache__/nasdaq.cpython-312.pyc +0 -0
- ksxt/market/us/__pycache__/nyse.cpython-312.pyc +0 -0
- ksxt/market/us/__pycache__/stock.cpython-312.pyc +0 -0
- ksxt/market/us/amex.py +31 -31
- ksxt/market/us/nasdaq.py +31 -31
- ksxt/market/us/nyse.py +31 -31
- ksxt/market/us/stock.py +20 -28
- ksxt/models/__init__.py +16 -0
- ksxt/models/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/balance.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/cash.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/common.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/error.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/historical.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/market.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/order.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/orderbook.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/ticker.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/token.cpython-312.pyc +0 -0
- ksxt/models/__pycache__/transaction.cpython-312.pyc +0 -0
- ksxt/models/balance.py +30 -0
- ksxt/models/cash.py +15 -0
- ksxt/models/common.py +31 -0
- ksxt/models/error.py +13 -0
- ksxt/models/historical.py +26 -0
- ksxt/models/market.py +81 -0
- ksxt/models/order.py +42 -0
- ksxt/models/orderbook.py +32 -0
- ksxt/models/ticker.py +25 -0
- ksxt/models/token.py +14 -0
- ksxt/models/transaction.py +79 -0
- ksxt/parser/__pycache__/bithumb.cpython-312.pyc +0 -0
- ksxt/parser/__pycache__/koreainvest.cpython-312.pyc +0 -0
- ksxt/parser/__pycache__/parser.cpython-312.pyc +0 -0
- ksxt/parser/__pycache__/upbit.cpython-312.pyc +0 -0
- ksxt/parser/bithumb.py +300 -0
- ksxt/parser/koreainvest.py +323 -0
- ksxt/parser/parser.py +114 -0
- ksxt/parser/upbit.py +308 -0
- ksxt/upbit.py +499 -0
- ksxt/utils/__pycache__/safer.cpython-312.pyc +0 -0
- ksxt/utils/__pycache__/sorter.cpython-312.pyc +0 -0
- ksxt/utils/__pycache__/timer.cpython-312.pyc +0 -0
- ksxt/utils/safer.py +48 -0
- ksxt/utils/sorter.py +8 -0
- ksxt/utils/timer.py +47 -0
- {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/METADATA +11 -1
- ksxt-0.0.10.dist-info/RECORD +119 -0
- {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/WHEEL +1 -1
- ksxt/__pycache__/__init__.cpython-39.pyc +0 -0
- ksxt/__pycache__/koreainvest.cpython-39.pyc +0 -0
- ksxt/base/__pycache__/__init__.cpython-39.pyc +0 -0
- ksxt/base/__pycache__/exchange.cpython-39.pyc +0 -0
- ksxt/base/__pycache__/rest_exchange.cpython-39.pyc +0 -0
- ksxt/base/__pycache__/restexchange.cpython-39.pyc +0 -0
- ksxt/base/__pycache__/types.cpython-39.pyc +0 -0
- ksxt/base/api_response.py +0 -68
- ksxt/config/__pycache__/__init__.cpython-39.pyc +0 -0
- ksxt/config/tr_app.json +0 -381
- ksxt/config/tr_dev.json +0 -446
- ksxt/market/__pycache__/base.cpython-39.pyc +0 -0
- ksxt/market/__pycache__/db.cpython-39.pyc +0 -0
- ksxt/market/__pycache__/logging.cpython-39.pyc +0 -0
- ksxt/market/__pycache__/manager.cpython-39.pyc +0 -0
- ksxt/market/__pycache__/markets.cpython-39.pyc +0 -0
- ksxt/market/krx/__pycache__/kosdaq.cpython-39.pyc +0 -0
- ksxt/market/krx/__pycache__/kospi.cpython-39.pyc +0 -0
- ksxt/market/krx/__pycache__/stock.cpython-39.pyc +0 -0
- ksxt/market/us/__pycache__/amex.cpython-39.pyc +0 -0
- ksxt/market/us/__pycache__/nasdaq.cpython-39.pyc +0 -0
- ksxt/market/us/__pycache__/nyse.cpython-39.pyc +0 -0
- ksxt/market/us/__pycache__/stock.cpython-39.pyc +0 -0
- ksxt-0.0.8.dist-info/RECORD +0 -49
- {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/LICENSE.txt +0 -0
- {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/top_level.txt +0 -0
ksxt/market/us/nasdaq.py
CHANGED
@@ -48,30 +48,30 @@ from ksxt.market.us.stock import UsStockItem, UsStockMarket
|
|
48
48
|
@dataclass
|
49
49
|
class NasdaqItem(UsStockItem):
|
50
50
|
CONTROL = [
|
51
|
-
(
|
52
|
-
(
|
53
|
-
(
|
54
|
-
(
|
55
|
-
(
|
56
|
-
(
|
57
|
-
(
|
58
|
-
(
|
59
|
-
(
|
60
|
-
(
|
61
|
-
(
|
62
|
-
(
|
63
|
-
(
|
64
|
-
(
|
65
|
-
(
|
66
|
-
(
|
67
|
-
(
|
68
|
-
(
|
69
|
-
(
|
70
|
-
(
|
71
|
-
(
|
72
|
-
(
|
73
|
-
(
|
74
|
-
(
|
51
|
+
("ncod", 2 + 1),
|
52
|
+
("exid", 3 + 1),
|
53
|
+
("excd", 3 + 1),
|
54
|
+
("exnm", 16 + 1),
|
55
|
+
("symb", 16 + 1),
|
56
|
+
("rsym", 16 + 1),
|
57
|
+
("knam", 64 + 1),
|
58
|
+
("enam", 64 + 1),
|
59
|
+
("stis", 1 + 1),
|
60
|
+
("curr", 4 + 1),
|
61
|
+
("zdiv", 1 + 1),
|
62
|
+
("ztyp", 1 + 1),
|
63
|
+
("base", 12 + 1),
|
64
|
+
("bnit", 8 + 1),
|
65
|
+
("anit", 8 + 1),
|
66
|
+
("mstm", 4 + 1),
|
67
|
+
("metm", 4 + 1),
|
68
|
+
("isdr", 1 + 1),
|
69
|
+
("drcd", 2 + 1),
|
70
|
+
("icod", 4 + 1),
|
71
|
+
("sjong", 1 + 1),
|
72
|
+
("ttyp", 1 + 1),
|
73
|
+
("etyp", 3 + 1),
|
74
|
+
("ttyp_sb", 3 + 1),
|
75
75
|
]
|
76
76
|
|
77
77
|
# Notional code
|
@@ -91,9 +91,9 @@ class NasdaqItem(UsStockItem):
|
|
91
91
|
# English name
|
92
92
|
enam: str
|
93
93
|
# Security Type
|
94
|
-
stis: Literal[
|
94
|
+
stis: Literal["1", "2", "3", "4"]
|
95
95
|
# currency
|
96
|
-
curr: str
|
96
|
+
curr: str
|
97
97
|
# float position
|
98
98
|
zdiv: str
|
99
99
|
# data type
|
@@ -115,11 +115,11 @@ class NasdaqItem(UsStockItem):
|
|
115
115
|
# 업종분류코드
|
116
116
|
icod: str
|
117
117
|
# 지수구성종목 존재 여부
|
118
|
-
sjong: Literal[
|
118
|
+
sjong: Literal["0", "1"]
|
119
119
|
# Tick Size Type
|
120
120
|
ttyp: str
|
121
121
|
#
|
122
|
-
etyp: Literal[
|
122
|
+
etyp: Literal["001", "002", "003", "004", "005", "006"]
|
123
123
|
# Tick size type 상세 (ttyp 8일 경우 사용) : 런던 제트라 유로넥스트
|
124
124
|
ttyp_sb: str
|
125
125
|
|
@@ -129,7 +129,7 @@ class NasdaqItem(UsStockItem):
|
|
129
129
|
|
130
130
|
|
131
131
|
class _NasdaqItem(Base):
|
132
|
-
__tablename__ =
|
132
|
+
__tablename__ = "nasdaq"
|
133
133
|
# Notional code
|
134
134
|
ncod = Column(String)
|
135
135
|
# Exchange ID
|
@@ -149,7 +149,7 @@ class _NasdaqItem(Base):
|
|
149
149
|
# Security Type
|
150
150
|
stis = Column(String)
|
151
151
|
# currency
|
152
|
-
curr = Column(String)
|
152
|
+
curr = Column(String)
|
153
153
|
# float position
|
154
154
|
zdiv = Column(String)
|
155
155
|
# data type
|
@@ -182,4 +182,4 @@ class _NasdaqItem(Base):
|
|
182
182
|
|
183
183
|
class Nasdaq(UsStockMarket[NasdaqItem, _NasdaqItem]):
|
184
184
|
def __init__(self, client):
|
185
|
-
super().__init__(client,
|
185
|
+
super().__init__(client, "nasdaq", "나스닥", "https://new.real.download.dws.co.kr/common/master/nasmst.cod.zip")
|
ksxt/market/us/nyse.py
CHANGED
@@ -48,30 +48,30 @@ from ksxt.market.us.stock import UsStockItem, UsStockMarket
|
|
48
48
|
@dataclass
|
49
49
|
class NyseItem(UsStockItem):
|
50
50
|
CONTROL = [
|
51
|
-
(
|
52
|
-
(
|
53
|
-
(
|
54
|
-
(
|
55
|
-
(
|
56
|
-
(
|
57
|
-
(
|
58
|
-
(
|
59
|
-
(
|
60
|
-
(
|
61
|
-
(
|
62
|
-
(
|
63
|
-
(
|
64
|
-
(
|
65
|
-
(
|
66
|
-
(
|
67
|
-
(
|
68
|
-
(
|
69
|
-
(
|
70
|
-
(
|
71
|
-
(
|
72
|
-
(
|
73
|
-
(
|
74
|
-
(
|
51
|
+
("ncod", 2 + 1),
|
52
|
+
("exid", 3 + 1),
|
53
|
+
("excd", 3 + 1),
|
54
|
+
("exnm", 16 + 1),
|
55
|
+
("symb", 16 + 1),
|
56
|
+
("rsym", 16 + 1),
|
57
|
+
("knam", 64 + 1),
|
58
|
+
("enam", 64 + 1),
|
59
|
+
("stis", 1 + 1),
|
60
|
+
("curr", 4 + 1),
|
61
|
+
("zdiv", 1 + 1),
|
62
|
+
("ztyp", 1 + 1),
|
63
|
+
("base", 12 + 1),
|
64
|
+
("bnit", 8 + 1),
|
65
|
+
("anit", 8 + 1),
|
66
|
+
("mstm", 4 + 1),
|
67
|
+
("metm", 4 + 1),
|
68
|
+
("isdr", 1 + 1),
|
69
|
+
("drcd", 2 + 1),
|
70
|
+
("icod", 4 + 1),
|
71
|
+
("sjong", 1 + 1),
|
72
|
+
("ttyp", 1 + 1),
|
73
|
+
("etyp", 3 + 1),
|
74
|
+
("ttyp_sb", 3 + 1),
|
75
75
|
]
|
76
76
|
|
77
77
|
# Notional code
|
@@ -91,9 +91,9 @@ class NyseItem(UsStockItem):
|
|
91
91
|
# English name
|
92
92
|
enam: str
|
93
93
|
# Security Type
|
94
|
-
stis: Literal[
|
94
|
+
stis: Literal["1", "2", "3", "4"]
|
95
95
|
# currency
|
96
|
-
curr: str
|
96
|
+
curr: str
|
97
97
|
# float position
|
98
98
|
zdiv: str
|
99
99
|
# data type
|
@@ -115,11 +115,11 @@ class NyseItem(UsStockItem):
|
|
115
115
|
# 업종분류코드
|
116
116
|
icod: str
|
117
117
|
# 지수구성종목 존재 여부
|
118
|
-
sjong: Literal[
|
118
|
+
sjong: Literal["0", "1"]
|
119
119
|
# Tick Size Type
|
120
120
|
ttyp: str
|
121
121
|
#
|
122
|
-
etyp: Literal[
|
122
|
+
etyp: Literal["001", "002", "003", "004", "005", "006"]
|
123
123
|
# Tick size type 상세 (ttyp 8일 경우 사용) : 런던 제트라 유로넥스트
|
124
124
|
ttyp_sb: str
|
125
125
|
|
@@ -129,7 +129,7 @@ class NyseItem(UsStockItem):
|
|
129
129
|
|
130
130
|
|
131
131
|
class _NyseItem(Base):
|
132
|
-
__tablename__ =
|
132
|
+
__tablename__ = "nyse"
|
133
133
|
# Notional code
|
134
134
|
ncod = Column(String)
|
135
135
|
# Exchange ID
|
@@ -149,7 +149,7 @@ class _NyseItem(Base):
|
|
149
149
|
# Security Type
|
150
150
|
stis = Column(String)
|
151
151
|
# currency
|
152
|
-
curr = Column(String)
|
152
|
+
curr = Column(String)
|
153
153
|
# float position
|
154
154
|
zdiv = Column(String)
|
155
155
|
# data type
|
@@ -182,4 +182,4 @@ class _NyseItem(Base):
|
|
182
182
|
|
183
183
|
class Nyse(UsStockMarket[NyseItem, _NyseItem]):
|
184
184
|
def __init__(self, client):
|
185
|
-
super().__init__(client,
|
185
|
+
super().__init__(client, "nyse", "뉴욕", "https://new.real.download.dws.co.kr/common/master/nysmst.cod.zip")
|
ksxt/market/us/stock.py
CHANGED
@@ -3,27 +3,20 @@ from typing import Generic, Iterable, Iterator, Literal, TypeVar, get_args
|
|
3
3
|
from ksxt.market.base import MarketItemBase, MarketBase
|
4
4
|
from ksxt.market.db import Base
|
5
5
|
|
6
|
-
STIS = {
|
7
|
-
'1': 'Index',
|
8
|
-
'2': 'Stock',
|
9
|
-
'3': 'ETP(ETF)',
|
10
|
-
'4': 'Warrant'
|
11
|
-
}
|
6
|
+
STIS = {"1": "Index", "2": "Stock", "3": "ETP(ETF)", "4": "Warrant"}
|
12
7
|
|
13
|
-
SJONG = {
|
14
|
-
'0': '구성종목없음',
|
15
|
-
'1': '구성종목있음'
|
16
|
-
}
|
8
|
+
SJONG = {"0": "구성종목없음", "1": "구성종목있음"}
|
17
9
|
|
18
10
|
ETYP = {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
"001": "ETF",
|
12
|
+
"002": "ETN",
|
13
|
+
"003": "ETC",
|
14
|
+
"004": "Others",
|
15
|
+
"005": "VIX Underlying ETF",
|
16
|
+
"006": "VIX Underlying ETN",
|
25
17
|
}
|
26
18
|
|
19
|
+
|
27
20
|
class UsStockItem(MarketItemBase):
|
28
21
|
# Notional code
|
29
22
|
ncod: str
|
@@ -42,9 +35,9 @@ class UsStockItem(MarketItemBase):
|
|
42
35
|
# English name
|
43
36
|
enam: str
|
44
37
|
# Security Type
|
45
|
-
stis: Literal[
|
38
|
+
stis: Literal["1", "2", "3", "4"]
|
46
39
|
# currency
|
47
|
-
curr: str
|
40
|
+
curr: str
|
48
41
|
# float position
|
49
42
|
zdiv: str
|
50
43
|
# data type
|
@@ -66,18 +59,18 @@ class UsStockItem(MarketItemBase):
|
|
66
59
|
# 업종분류코드
|
67
60
|
icod: str
|
68
61
|
# 지수구성종목 존재 여부
|
69
|
-
sjong: Literal[
|
62
|
+
sjong: Literal["0", "1"]
|
70
63
|
# Tick Size Type
|
71
64
|
ttyp: str
|
72
65
|
#
|
73
|
-
etyp: Literal[
|
66
|
+
etyp: Literal["001", "002", "003", "004", "005", "006"]
|
74
67
|
# Tick size type 상세 (ttyp 8일 경우 사용) : 런던 제트라 유로넥스트
|
75
68
|
ttyp_sb: str
|
76
69
|
|
77
70
|
@property
|
78
71
|
def stis_name(self) -> str:
|
79
72
|
return STIS.get(self.stis, None)
|
80
|
-
|
73
|
+
|
81
74
|
@property
|
82
75
|
def sjong_name(self) -> str:
|
83
76
|
return SJONG.get(self.sjong, None)
|
@@ -85,13 +78,13 @@ class UsStockItem(MarketItemBase):
|
|
85
78
|
@property
|
86
79
|
def etyp_name(self) -> str:
|
87
80
|
return ETYP.get(self.etyp, None)
|
88
|
-
|
81
|
+
|
89
82
|
def __init__(self, data: str):
|
90
|
-
super().__init__(data, delimiter=
|
83
|
+
super().__init__(data, delimiter="\t")
|
91
84
|
|
92
85
|
|
93
|
-
t_item = TypeVar(
|
94
|
-
t_dbitem = TypeVar(
|
86
|
+
t_item = TypeVar("t_item", bound=UsStockItem)
|
87
|
+
t_dbitem = TypeVar("t_dbitem", bound=Base)
|
95
88
|
|
96
89
|
|
97
90
|
class UsStockMarket(Generic[t_item, t_dbitem], MarketBase[t_item, t_dbitem]):
|
@@ -133,7 +126,7 @@ class UsStockMarket(Generic[t_item, t_dbitem], MarketBase[t_item, t_dbitem]):
|
|
133
126
|
Iterator[t_item]: 종목 정보
|
134
127
|
"""
|
135
128
|
return super().all() # type: ignore
|
136
|
-
|
129
|
+
|
137
130
|
def __getitem__(self, code: str) -> t_item:
|
138
131
|
"""
|
139
132
|
종목 검색 (종목코드 기준)
|
@@ -144,7 +137,6 @@ class UsStockMarket(Generic[t_item, t_dbitem], MarketBase[t_item, t_dbitem]):
|
|
144
137
|
Returns:
|
145
138
|
t_item: 종목 정보
|
146
139
|
"""
|
147
|
-
|
140
|
+
"""종목을 가져옵니다."""
|
148
141
|
_, db_type = get_args(self.__orig_bases__[0]) # type: ignore
|
149
142
|
return self._get(db_type.symb, code)
|
150
|
-
|
ksxt/models/__init__.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
from .transaction import (
|
2
|
+
KsxtWithdrawalHistoryResponse,
|
3
|
+
KsxtDepositHistoryResponse,
|
4
|
+
KsxtOpenOrderResponse,
|
5
|
+
KsxtClosedOrderResponse,
|
6
|
+
)
|
7
|
+
from .balance import KsxtBalanceResponse
|
8
|
+
from .cash import KsxtCashResponse
|
9
|
+
from .error import KsxtErrorResponse
|
10
|
+
from .historical import KsxtHistoricalDataResponse
|
11
|
+
from .market import KsxtTradeFeeResponse, KsxtSecurityResponse, KsxtMarketResponse, KsxtHolidayResponse
|
12
|
+
from .order import KsxtCreateOrderResponse, KsxtCancelOrderResponse, KsxtModifyOrderResponse
|
13
|
+
from .orderbook import KsxtSingleOrderBookResponse, KsxtMultiOrderBookResponse
|
14
|
+
from .ticker import KsxtTickerResponse, KsxtTickersResponse
|
15
|
+
|
16
|
+
from .token import KsxtTokenResponse
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
ksxt/models/balance.py
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from typing import List
|
3
|
+
|
4
|
+
from ksxt.models.common import GeneralResponse
|
5
|
+
|
6
|
+
|
7
|
+
class BalanceData(BaseModel):
|
8
|
+
symbol: str
|
9
|
+
name: str
|
10
|
+
evaluation_price: float
|
11
|
+
price: float
|
12
|
+
pnl_amount: float
|
13
|
+
pnl_ratio: float
|
14
|
+
qty: float
|
15
|
+
free_qty: float
|
16
|
+
used_qty: float
|
17
|
+
|
18
|
+
|
19
|
+
class BalanceInfo(BaseModel):
|
20
|
+
currency: str
|
21
|
+
total_amount: float
|
22
|
+
total_evaluation_amount: float
|
23
|
+
total_pnl_amount: float
|
24
|
+
total_pnl_ratio: float
|
25
|
+
balances: List[BalanceData]
|
26
|
+
|
27
|
+
|
28
|
+
# Balance에 대한 구체적인 Response 타입
|
29
|
+
class KsxtBalanceResponse(GeneralResponse[BalanceInfo]):
|
30
|
+
pass
|
ksxt/models/cash.py
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
|
3
|
+
from ksxt.models.common import GeneralResponse
|
4
|
+
|
5
|
+
|
6
|
+
class CashInfo(BaseModel):
|
7
|
+
currency: str
|
8
|
+
cash: float
|
9
|
+
cash_d1: float
|
10
|
+
cash_d2: float
|
11
|
+
|
12
|
+
|
13
|
+
# Cash에 대한 구체적인 Response 타입
|
14
|
+
class KsxtCashResponse(GeneralResponse[CashInfo]):
|
15
|
+
pass
|
ksxt/models/common.py
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
from typing import Any, Generic, Optional, TypeVar
|
2
|
+
from pydantic import BaseModel, Field
|
3
|
+
from datetime import datetime, UTC
|
4
|
+
|
5
|
+
|
6
|
+
class CommonResponseHeader(BaseModel):
|
7
|
+
# 요청 시간
|
8
|
+
request_time: datetime = datetime.now(UTC)
|
9
|
+
# 요청 Parameter
|
10
|
+
request_params: dict
|
11
|
+
|
12
|
+
|
13
|
+
class CommonResponse(BaseModel):
|
14
|
+
# response code (success / fail)
|
15
|
+
success: Optional[str] = None
|
16
|
+
# response message code
|
17
|
+
msg_code: Optional[str] = None
|
18
|
+
# response message
|
19
|
+
msg: Optional[str] = None
|
20
|
+
# 거래소 별 API 호출 시 반환되는 원본 Response 데이터
|
21
|
+
info: Any
|
22
|
+
|
23
|
+
|
24
|
+
# 제네릭을 사용한 전체 Response 모델
|
25
|
+
T = TypeVar("T")
|
26
|
+
|
27
|
+
|
28
|
+
class GeneralResponse(BaseModel, Generic[T]):
|
29
|
+
header: CommonResponseHeader
|
30
|
+
response: CommonResponse
|
31
|
+
info: Optional[T] = None
|
ksxt/models/error.py
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
from pydantic import BaseModel
|
3
|
+
|
4
|
+
from ksxt.models.common import GeneralResponse
|
5
|
+
|
6
|
+
|
7
|
+
class ErrorInfo(BaseModel):
|
8
|
+
error_code: Optional[str] = None
|
9
|
+
error_message: Optional[str] = None
|
10
|
+
|
11
|
+
|
12
|
+
class KsxtErrorResponse(GeneralResponse[ErrorInfo]):
|
13
|
+
pass
|
@@ -0,0 +1,26 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from typing import List, Optional
|
3
|
+
from datetime import datetime
|
4
|
+
|
5
|
+
from ksxt.models.common import GeneralResponse
|
6
|
+
|
7
|
+
|
8
|
+
class OHLCVData(BaseModel):
|
9
|
+
datetime: datetime
|
10
|
+
open_price: float | int
|
11
|
+
high_price: float | int
|
12
|
+
low_price: float | int
|
13
|
+
close_price: float | int
|
14
|
+
acml_volume: float | int
|
15
|
+
acml_amount: float | int
|
16
|
+
|
17
|
+
|
18
|
+
class HistoricalDataInfo(BaseModel):
|
19
|
+
symbol: str
|
20
|
+
security_name: Optional[str] = None
|
21
|
+
history: List[OHLCVData]
|
22
|
+
|
23
|
+
|
24
|
+
# Historical Data에 대한 구체적인 Response 타입
|
25
|
+
class KsxtHistoricalDataResponse(GeneralResponse[HistoricalDataInfo]):
|
26
|
+
pass
|
ksxt/models/market.py
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Dict, List, Optional
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
from ksxt.models.common import GeneralResponse
|
6
|
+
|
7
|
+
|
8
|
+
class TradeFeeInfo(BaseModel):
|
9
|
+
limit_bid_fee: float
|
10
|
+
limit_ask_fee: float
|
11
|
+
|
12
|
+
market_bid_fee: float
|
13
|
+
market_ask_fee: float
|
14
|
+
|
15
|
+
|
16
|
+
class SecurityData(BaseModel):
|
17
|
+
# 종목코드
|
18
|
+
symbol: str
|
19
|
+
# 종목이름
|
20
|
+
name: str
|
21
|
+
# 종목유형
|
22
|
+
type: str
|
23
|
+
|
24
|
+
# 매수 주문 수량 단위
|
25
|
+
bid_qty_unit: Optional[float] = 0
|
26
|
+
# 매도 주문 수량 단위
|
27
|
+
ask_qty_unit: Optional[float] = 0
|
28
|
+
|
29
|
+
# 최소 매수 주문 수량
|
30
|
+
bid_min_qty: Optional[float] = 0
|
31
|
+
# 최소 매도 주문 수량
|
32
|
+
ask_min_qty: Optional[float] = 0
|
33
|
+
# 최대 매수 주문 수량
|
34
|
+
bid_max_qty: Optional[float] = 0
|
35
|
+
# 최대 매도 주문 수량
|
36
|
+
ask_max_qty: Optional[float] = 0
|
37
|
+
|
38
|
+
# 최소 매수 주문 금액
|
39
|
+
bid_min_amount: Optional[float] = 0
|
40
|
+
# 최소 매도 주문 금액
|
41
|
+
ask_min_amount: Optional[float] = 0
|
42
|
+
# 최대 매수 주문 금액
|
43
|
+
bid_max_amount: Optional[float] = 0
|
44
|
+
# 최대 매도 주문 금액
|
45
|
+
ask_max_amount: Optional[float] = 0
|
46
|
+
|
47
|
+
warning_code: bool = False
|
48
|
+
|
49
|
+
|
50
|
+
class MarketInfo(BaseModel):
|
51
|
+
market_id: str
|
52
|
+
securities: Dict[str, SecurityData]
|
53
|
+
|
54
|
+
|
55
|
+
class HolidayInfo(BaseModel):
|
56
|
+
date: datetime
|
57
|
+
# 01 : 일요일 ~ 07: 토요일
|
58
|
+
weekend: str
|
59
|
+
is_holiday: bool
|
60
|
+
|
61
|
+
|
62
|
+
class HolidayHistory(BaseModel):
|
63
|
+
market: List[str]
|
64
|
+
country: str
|
65
|
+
history: List[HolidayInfo]
|
66
|
+
|
67
|
+
|
68
|
+
class KsxtTradeFeeResponse(GeneralResponse[TradeFeeInfo]):
|
69
|
+
pass
|
70
|
+
|
71
|
+
|
72
|
+
class KsxtSecurityResponse(GeneralResponse[SecurityData]):
|
73
|
+
pass
|
74
|
+
|
75
|
+
|
76
|
+
class KsxtMarketResponse(GeneralResponse[MarketInfo]):
|
77
|
+
pass
|
78
|
+
|
79
|
+
|
80
|
+
class KsxtHolidayResponse(GeneralResponse[HolidayHistory]):
|
81
|
+
pass
|
ksxt/models/order.py
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from typing import List, Optional
|
3
|
+
from datetime import datetime
|
4
|
+
|
5
|
+
from ksxt.models.common import GeneralResponse
|
6
|
+
|
7
|
+
|
8
|
+
class OrderBase(BaseModel):
|
9
|
+
datetime: datetime
|
10
|
+
order_id: str
|
11
|
+
symbol: str
|
12
|
+
name: str
|
13
|
+
price: float
|
14
|
+
qty: float
|
15
|
+
|
16
|
+
|
17
|
+
class CreateOrderResponse(BaseModel):
|
18
|
+
order_datetime: datetime
|
19
|
+
order_id: str
|
20
|
+
|
21
|
+
|
22
|
+
class CancelOrderResponse(BaseModel):
|
23
|
+
order_datetime: datetime
|
24
|
+
order_id: str
|
25
|
+
|
26
|
+
|
27
|
+
class ModifyOrderResponse(BaseModel):
|
28
|
+
order_datetime: datetime
|
29
|
+
order_id: str
|
30
|
+
|
31
|
+
|
32
|
+
# Orders에 대한 구체적인 Response 타입
|
33
|
+
class KsxtCreateOrderResponse(GeneralResponse[CreateOrderResponse]):
|
34
|
+
pass
|
35
|
+
|
36
|
+
|
37
|
+
class KsxtCancelOrderResponse(GeneralResponse[CancelOrderResponse]):
|
38
|
+
pass
|
39
|
+
|
40
|
+
|
41
|
+
class KsxtModifyOrderResponse(GeneralResponse[ModifyOrderResponse]):
|
42
|
+
pass
|
ksxt/models/orderbook.py
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from typing import Dict, List
|
3
|
+
|
4
|
+
from ksxt.models.common import GeneralResponse
|
5
|
+
|
6
|
+
|
7
|
+
class OrderBookData(BaseModel):
|
8
|
+
side: str
|
9
|
+
ob_num: int
|
10
|
+
ob_price: float
|
11
|
+
ob_qty: float
|
12
|
+
|
13
|
+
|
14
|
+
class OrderBookInfo(BaseModel):
|
15
|
+
total_asks_qty: float
|
16
|
+
total_bids_qty: float
|
17
|
+
asks: List[OrderBookData]
|
18
|
+
bids: List[OrderBookData]
|
19
|
+
|
20
|
+
|
21
|
+
class MultiSymbolOrderBookInfos(BaseModel):
|
22
|
+
order_books: Dict[str, OrderBookInfo]
|
23
|
+
|
24
|
+
|
25
|
+
# Single symbol OrderBook에 대한 구체적인 Response 타입
|
26
|
+
class KsxtSingleOrderBookResponse(GeneralResponse[OrderBookInfo]):
|
27
|
+
pass
|
28
|
+
|
29
|
+
|
30
|
+
# Multi symbol OrderBook에 대한 구체적인 Response 타입
|
31
|
+
class KsxtMultiOrderBookResponse(GeneralResponse[MultiSymbolOrderBookInfos]):
|
32
|
+
pass
|
ksxt/models/ticker.py
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Dict
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
from ksxt.models.common import GeneralResponse
|
6
|
+
|
7
|
+
|
8
|
+
class TickerInfo(BaseModel):
|
9
|
+
symbol: str
|
10
|
+
price: float
|
11
|
+
ts: datetime
|
12
|
+
|
13
|
+
|
14
|
+
class MultiSymbolTickerInfo(BaseModel):
|
15
|
+
tickers: Dict[str, TickerInfo]
|
16
|
+
|
17
|
+
|
18
|
+
# 단일 Ticker에 대한 Response 타입
|
19
|
+
class KsxtTickerResponse(GeneralResponse[TickerInfo]):
|
20
|
+
pass
|
21
|
+
|
22
|
+
|
23
|
+
# 복수 Ticker에 대한 Response 타입
|
24
|
+
class KsxtTickersResponse(GeneralResponse[MultiSymbolTickerInfo]):
|
25
|
+
pass
|