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.
Files changed (141) hide show
  1. ksxt/__init__.py +3 -1
  2. ksxt/__pycache__/__init__.cpython-312.pyc +0 -0
  3. ksxt/__pycache__/bithumb.cpython-312.pyc +0 -0
  4. ksxt/__pycache__/koreainvest.cpython-312.pyc +0 -0
  5. ksxt/__pycache__/upbit.cpython-312.pyc +0 -0
  6. ksxt/api/__init__.py +26 -0
  7. ksxt/api/__pycache__/__init__.cpython-312.pyc +0 -0
  8. ksxt/api/__pycache__/bithumb.cpython-312.pyc +0 -0
  9. ksxt/api/__pycache__/koreainvest.cpython-312.pyc +0 -0
  10. ksxt/api/__pycache__/upbit.cpython-312.pyc +0 -0
  11. ksxt/api/auto/api_generator.py +54 -0
  12. ksxt/api/auto/bithumb.py +35 -0
  13. ksxt/api/auto/koreainvest.py +49 -0
  14. ksxt/api/auto/upbit.py +39 -0
  15. ksxt/api/bithumb.py +42 -0
  16. ksxt/api/koreainvest.py +40 -0
  17. ksxt/api/upbit.py +54 -0
  18. ksxt/async_/__init__.py +4 -0
  19. ksxt/async_/__pycache__/__init__.cpython-312.pyc +0 -0
  20. ksxt/async_/__pycache__/bithumb.cpython-312.pyc +0 -0
  21. ksxt/async_/__pycache__/koreainvest.cpython-312.pyc +0 -0
  22. ksxt/async_/__pycache__/upbit.cpython-312.pyc +0 -0
  23. ksxt/async_/base/__init__.py +0 -0
  24. ksxt/async_/base/__pycache__/__init__.cpython-312.pyc +0 -0
  25. ksxt/async_/base/__pycache__/async_exchange.cpython-312.pyc +0 -0
  26. ksxt/async_/base/__pycache__/throttler.cpython-312.pyc +0 -0
  27. ksxt/async_/base/async_exchange.py +232 -0
  28. ksxt/async_/base/throttler.py +63 -0
  29. ksxt/async_/bithumb.py +455 -0
  30. ksxt/async_/koreainvest.py +849 -0
  31. ksxt/async_/upbit.py +488 -0
  32. ksxt/base/__pycache__/__init__.cpython-312.pyc +0 -0
  33. ksxt/base/__pycache__/errors.cpython-312.pyc +0 -0
  34. ksxt/base/__pycache__/exchange.cpython-312.pyc +0 -0
  35. ksxt/base/__pycache__/rest_exchange.cpython-312.pyc +0 -0
  36. ksxt/base/__pycache__/types.cpython-312.pyc +0 -0
  37. ksxt/base/com_exchange.py +2 -2
  38. ksxt/base/errors.py +10 -0
  39. ksxt/base/exchange.py +188 -497
  40. ksxt/base/rest_exchange.py +297 -113
  41. ksxt/base/types.py +1 -36
  42. ksxt/bithumb.py +504 -0
  43. ksxt/config/__init__.py +2 -1
  44. ksxt/config/__pycache__/__init__.cpython-312.pyc +0 -0
  45. ksxt/config/bithumb.toml +380 -0
  46. ksxt/config/koreainvest.toml +312 -0
  47. ksxt/config/token.toml +7 -0
  48. ksxt/config/upbit.toml +428 -0
  49. ksxt/koreainvest.py +409 -1055
  50. ksxt/market/__pycache__/base.cpython-312.pyc +0 -0
  51. ksxt/market/__pycache__/db.cpython-312.pyc +0 -0
  52. ksxt/market/__pycache__/logging.cpython-312.pyc +0 -0
  53. ksxt/market/__pycache__/manager.cpython-312.pyc +0 -0
  54. ksxt/market/__pycache__/markets.cpython-312.pyc +0 -0
  55. ksxt/market/base.py +50 -50
  56. ksxt/market/db.py +5 -4
  57. ksxt/market/krx/__pycache__/kosdaq.cpython-312.pyc +0 -0
  58. ksxt/market/krx/__pycache__/kospi.cpython-312.pyc +0 -0
  59. ksxt/market/krx/__pycache__/stock.cpython-312.pyc +0 -0
  60. ksxt/market/krx/kosdaq.py +150 -147
  61. ksxt/market/krx/kospi.py +179 -175
  62. ksxt/market/krx/stock.py +136 -134
  63. ksxt/market/logging.py +4 -4
  64. ksxt/market/manager.py +10 -12
  65. ksxt/market/markets.py +1 -1
  66. ksxt/market/us/__pycache__/amex.cpython-312.pyc +0 -0
  67. ksxt/market/us/__pycache__/nasdaq.cpython-312.pyc +0 -0
  68. ksxt/market/us/__pycache__/nyse.cpython-312.pyc +0 -0
  69. ksxt/market/us/__pycache__/stock.cpython-312.pyc +0 -0
  70. ksxt/market/us/amex.py +31 -31
  71. ksxt/market/us/nasdaq.py +31 -31
  72. ksxt/market/us/nyse.py +31 -31
  73. ksxt/market/us/stock.py +20 -28
  74. ksxt/models/__init__.py +16 -0
  75. ksxt/models/__pycache__/__init__.cpython-312.pyc +0 -0
  76. ksxt/models/__pycache__/balance.cpython-312.pyc +0 -0
  77. ksxt/models/__pycache__/cash.cpython-312.pyc +0 -0
  78. ksxt/models/__pycache__/common.cpython-312.pyc +0 -0
  79. ksxt/models/__pycache__/error.cpython-312.pyc +0 -0
  80. ksxt/models/__pycache__/historical.cpython-312.pyc +0 -0
  81. ksxt/models/__pycache__/market.cpython-312.pyc +0 -0
  82. ksxt/models/__pycache__/order.cpython-312.pyc +0 -0
  83. ksxt/models/__pycache__/orderbook.cpython-312.pyc +0 -0
  84. ksxt/models/__pycache__/ticker.cpython-312.pyc +0 -0
  85. ksxt/models/__pycache__/token.cpython-312.pyc +0 -0
  86. ksxt/models/__pycache__/transaction.cpython-312.pyc +0 -0
  87. ksxt/models/balance.py +30 -0
  88. ksxt/models/cash.py +15 -0
  89. ksxt/models/common.py +31 -0
  90. ksxt/models/error.py +13 -0
  91. ksxt/models/historical.py +26 -0
  92. ksxt/models/market.py +81 -0
  93. ksxt/models/order.py +42 -0
  94. ksxt/models/orderbook.py +32 -0
  95. ksxt/models/ticker.py +25 -0
  96. ksxt/models/token.py +14 -0
  97. ksxt/models/transaction.py +79 -0
  98. ksxt/parser/__pycache__/bithumb.cpython-312.pyc +0 -0
  99. ksxt/parser/__pycache__/koreainvest.cpython-312.pyc +0 -0
  100. ksxt/parser/__pycache__/parser.cpython-312.pyc +0 -0
  101. ksxt/parser/__pycache__/upbit.cpython-312.pyc +0 -0
  102. ksxt/parser/bithumb.py +300 -0
  103. ksxt/parser/koreainvest.py +323 -0
  104. ksxt/parser/parser.py +114 -0
  105. ksxt/parser/upbit.py +308 -0
  106. ksxt/upbit.py +499 -0
  107. ksxt/utils/__pycache__/safer.cpython-312.pyc +0 -0
  108. ksxt/utils/__pycache__/sorter.cpython-312.pyc +0 -0
  109. ksxt/utils/__pycache__/timer.cpython-312.pyc +0 -0
  110. ksxt/utils/safer.py +48 -0
  111. ksxt/utils/sorter.py +8 -0
  112. ksxt/utils/timer.py +47 -0
  113. {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/METADATA +11 -1
  114. ksxt-0.0.10.dist-info/RECORD +119 -0
  115. {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/WHEEL +1 -1
  116. ksxt/__pycache__/__init__.cpython-39.pyc +0 -0
  117. ksxt/__pycache__/koreainvest.cpython-39.pyc +0 -0
  118. ksxt/base/__pycache__/__init__.cpython-39.pyc +0 -0
  119. ksxt/base/__pycache__/exchange.cpython-39.pyc +0 -0
  120. ksxt/base/__pycache__/rest_exchange.cpython-39.pyc +0 -0
  121. ksxt/base/__pycache__/restexchange.cpython-39.pyc +0 -0
  122. ksxt/base/__pycache__/types.cpython-39.pyc +0 -0
  123. ksxt/base/api_response.py +0 -68
  124. ksxt/config/__pycache__/__init__.cpython-39.pyc +0 -0
  125. ksxt/config/tr_app.json +0 -381
  126. ksxt/config/tr_dev.json +0 -446
  127. ksxt/market/__pycache__/base.cpython-39.pyc +0 -0
  128. ksxt/market/__pycache__/db.cpython-39.pyc +0 -0
  129. ksxt/market/__pycache__/logging.cpython-39.pyc +0 -0
  130. ksxt/market/__pycache__/manager.cpython-39.pyc +0 -0
  131. ksxt/market/__pycache__/markets.cpython-39.pyc +0 -0
  132. ksxt/market/krx/__pycache__/kosdaq.cpython-39.pyc +0 -0
  133. ksxt/market/krx/__pycache__/kospi.cpython-39.pyc +0 -0
  134. ksxt/market/krx/__pycache__/stock.cpython-39.pyc +0 -0
  135. ksxt/market/us/__pycache__/amex.cpython-39.pyc +0 -0
  136. ksxt/market/us/__pycache__/nasdaq.cpython-39.pyc +0 -0
  137. ksxt/market/us/__pycache__/nyse.cpython-39.pyc +0 -0
  138. ksxt/market/us/__pycache__/stock.cpython-39.pyc +0 -0
  139. ksxt-0.0.8.dist-info/RECORD +0 -49
  140. {ksxt-0.0.8.dist-info → ksxt-0.0.10.dist-info}/LICENSE.txt +0 -0
  141. {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
- ('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)
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['1', '2', '3', '4']
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['0', '1']
118
+ sjong: Literal["0", "1"]
119
119
  # Tick Size Type
120
120
  ttyp: str
121
121
  #
122
- etyp: Literal['001', '002', '003', '004', '005', '006']
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__ = 'nasdaq'
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, 'nasdaq', '나스닥', 'https://new.real.download.dws.co.kr/common/master/nasmst.cod.zip')
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
- ('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)
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['1', '2', '3', '4']
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['0', '1']
118
+ sjong: Literal["0", "1"]
119
119
  # Tick Size Type
120
120
  ttyp: str
121
121
  #
122
- etyp: Literal['001', '002', '003', '004', '005', '006']
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__ = 'nyse'
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, 'nyse', '뉴욕', 'https://new.real.download.dws.co.kr/common/master/nysmst.cod.zip')
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
- '001': 'ETF',
20
- '002': 'ETN',
21
- '003': 'ETC',
22
- '004': 'Others',
23
- '005': 'VIX Underlying ETF',
24
- '006': 'VIX Underlying ETN'
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['1', '2', '3', '4']
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['0', '1']
62
+ sjong: Literal["0", "1"]
70
63
  # Tick Size Type
71
64
  ttyp: str
72
65
  #
73
- etyp: Literal['001', '002', '003', '004', '005', '006']
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='\t')
83
+ super().__init__(data, delimiter="\t")
91
84
 
92
85
 
93
- t_item = TypeVar('t_item', bound=UsStockItem)
94
- t_dbitem = TypeVar('t_dbitem', bound=Base)
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
-
@@ -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
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
@@ -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