ksxt 1.0.4__py3-none-any.whl → 1.0.6__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/__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/__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/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/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/async_/base/__pycache__/async_exchange.cpython-312.pyc +0 -0
- ksxt/async_/base/async_exchange.py +23 -17
- ksxt/async_/bithumb.py +56 -21
- ksxt/async_/koreainvest.py +87 -8
- ksxt/async_/upbit.py +67 -24
- 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__/rate_limiter.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/exchange.py +42 -23
- ksxt/base/rest_exchange.py +32 -28
- ksxt/bithumb.py +48 -14
- ksxt/config/__pycache__/__init__.cpython-312.pyc +0 -0
- ksxt/config/token.toml +3 -7
- ksxt/koreainvest.py +37 -8
- 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/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/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/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 +17 -4
- ksxt/models/transaction.py +22 -28
- 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 +124 -23
- ksxt/parser/koreainvest.py +84 -21
- ksxt/parser/parser.py +30 -10
- ksxt/parser/upbit.py +134 -27
- ksxt/upbit.py +55 -18
- 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-1.0.4.dist-info → ksxt-1.0.6.dist-info}/METADATA +1 -1
- ksxt-1.0.6.dist-info/RECORD +119 -0
- {ksxt-1.0.4.dist-info → ksxt-1.0.6.dist-info}/WHEEL +1 -1
- ksxt/async_/base/__pycache__/throttler.cpython-312.pyc +0 -0
- ksxt-1.0.4.dist-info/RECORD +0 -120
- {ksxt-1.0.4.dist-info → ksxt-1.0.6.dist-info}/LICENSE.txt +0 -0
- {ksxt-1.0.4.dist-info → ksxt-1.0.6.dist-info}/top_level.txt +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
ksxt/base/exchange.py
CHANGED
@@ -3,7 +3,7 @@ import json
|
|
3
3
|
from datetime import datetime
|
4
4
|
import time
|
5
5
|
import pytz
|
6
|
-
from typing import Dict
|
6
|
+
from typing import Dict
|
7
7
|
import ast
|
8
8
|
|
9
9
|
from requests import Session
|
@@ -85,8 +85,8 @@ class Exchange:
|
|
85
85
|
self,
|
86
86
|
symbol: str,
|
87
87
|
time_frame: str,
|
88
|
-
start:
|
89
|
-
end:
|
88
|
+
start: datetime | None = None,
|
89
|
+
end: datetime | None = None,
|
90
90
|
base_market: str = "KRW",
|
91
91
|
):
|
92
92
|
"""
|
@@ -95,8 +95,8 @@ class Exchange:
|
|
95
95
|
Args:
|
96
96
|
symbol (str): 종목코드
|
97
97
|
time_frame (str): 봉조회기준
|
98
|
-
start (
|
99
|
-
end (
|
98
|
+
start (datetime | None, optional): 조회 시작일. Defaults to None.
|
99
|
+
end (datetime | None, optional): 조회 종료일. Defaults to None.
|
100
100
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
101
101
|
"""
|
102
102
|
pass
|
@@ -139,14 +139,25 @@ class Exchange:
|
|
139
139
|
"""
|
140
140
|
pass
|
141
141
|
|
142
|
-
def fetch_balance(
|
142
|
+
def fetch_balance(
|
143
|
+
self,
|
144
|
+
acc_num: str,
|
145
|
+
base_market: str = "KRW",
|
146
|
+
excluded_symbols: list[str] | None = None,
|
147
|
+
included_symbols: list[str] | None = None,
|
148
|
+
filter_delisted: bool = True,
|
149
|
+
min_amount: float = 0,
|
150
|
+
):
|
143
151
|
"""
|
144
152
|
보유 자산 조회
|
145
153
|
|
146
154
|
Args:
|
147
155
|
acc_num (str): 계좌 번호
|
148
156
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
149
|
-
excluded_symbols (
|
157
|
+
excluded_symbols (list[str] | None, optional): 제외할 종목 리스트. Defaults to None.
|
158
|
+
included_symbols (list[str] | None, optional): 포함할 종목 리스트. Defaults to None.
|
159
|
+
filter_delisted (bool, optional): 거래 지원 종료되거나 상장 폐지된 종목 필터링 여부. Defaults to True.
|
160
|
+
min_amount (float, optional): 최소 자산 금액 필터링. Defaults to 0.
|
150
161
|
"""
|
151
162
|
pass
|
152
163
|
|
@@ -179,22 +190,30 @@ class Exchange:
|
|
179
190
|
"""
|
180
191
|
pass
|
181
192
|
|
182
|
-
def fetch_deposit_history(
|
193
|
+
def fetch_deposit_history(
|
194
|
+
self, acc_num: str, start: datetime | None = None, end: datetime | None = None, base_market: str = "KRW"
|
195
|
+
):
|
183
196
|
"""
|
184
197
|
입금 내역 조회
|
185
198
|
|
186
199
|
Args:
|
187
200
|
acc_num (str): 계좌 번호
|
201
|
+
start (datetime | None, optional): 조회 시작일. Defaults to None.
|
202
|
+
end (datetime | None, optional): 조회 종료일. Defaults to None.
|
188
203
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
189
204
|
"""
|
190
205
|
pass
|
191
206
|
|
192
|
-
def fetch_withdrawal_history(
|
207
|
+
def fetch_withdrawal_history(
|
208
|
+
self, acc_num: str, start: datetime | None = None, end: datetime | None = None, base_market: str = "KRW"
|
209
|
+
):
|
193
210
|
"""
|
194
211
|
출금 내역 조회
|
195
212
|
|
196
213
|
Args:
|
197
214
|
acc_num (str): 계좌 번호
|
215
|
+
start (datetime | None, optional): 조회 시작일. Defaults to None.
|
216
|
+
end (datetime | None, optional): 조회 종료일. Defaults to None.
|
198
217
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
199
218
|
"""
|
200
219
|
pass
|
@@ -229,7 +248,7 @@ class Exchange:
|
|
229
248
|
pass
|
230
249
|
|
231
250
|
def cancel_order(
|
232
|
-
self, acc_num: str, order_id: str, symbol:
|
251
|
+
self, acc_num: str, order_id: str, symbol: str | None = "", qty: float = 0, *args, base_market: str = "KRW"
|
233
252
|
):
|
234
253
|
"""
|
235
254
|
미체결 주문 취소
|
@@ -237,7 +256,7 @@ class Exchange:
|
|
237
256
|
Args:
|
238
257
|
acc_num (str): 계좌정보(계좌번호, 지갑정보)
|
239
258
|
order_id (str): 주문 정보(주문 id)
|
240
|
-
symbol (str, optional): 종목정보(종목코드). Defaults to ''.
|
259
|
+
symbol (str | None, optional): 종목정보(종목코드). Defaults to ''.
|
241
260
|
qty (float, optional): 수량. Defaults to 0..
|
242
261
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
243
262
|
"""
|
@@ -246,9 +265,9 @@ class Exchange:
|
|
246
265
|
def fetch_open_order(
|
247
266
|
self,
|
248
267
|
acc_num: str,
|
249
|
-
symbol:
|
250
|
-
start:
|
251
|
-
end:
|
268
|
+
symbol: str | None = "",
|
269
|
+
start: datetime | None = None,
|
270
|
+
end: datetime | None = None,
|
252
271
|
base_market: str = "KRW",
|
253
272
|
):
|
254
273
|
"""
|
@@ -256,9 +275,9 @@ class Exchange:
|
|
256
275
|
|
257
276
|
Args:
|
258
277
|
acc_num (str): 계좌정보(계좌번호, 지갑정보)
|
259
|
-
symbol (str, optional): 종목정보(종목코드) Defaults to ''.
|
260
|
-
start (
|
261
|
-
end (
|
278
|
+
symbol (str | None, optional): 종목정보(종목코드) Defaults to ''.
|
279
|
+
start (datetime | None, optional): 조회 시작일자. Defaults to None.
|
280
|
+
end (datetime | None, optional): 조회 종료일자. Defaults to None.
|
262
281
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
263
282
|
"""
|
264
283
|
pass
|
@@ -266,9 +285,9 @@ class Exchange:
|
|
266
285
|
def fetch_closed_order(
|
267
286
|
self,
|
268
287
|
acc_num: str,
|
269
|
-
symbol:
|
270
|
-
start:
|
271
|
-
end:
|
288
|
+
symbol: str | None = "",
|
289
|
+
start: datetime | None = None,
|
290
|
+
end: datetime | None = None,
|
272
291
|
base_market: str = "KRW",
|
273
292
|
):
|
274
293
|
"""
|
@@ -276,9 +295,9 @@ class Exchange:
|
|
276
295
|
|
277
296
|
Args:
|
278
297
|
acc_num (str): 계좌정보(계좌번호, 지갑정보)
|
279
|
-
symbol (str, optional): 종목정보(종목코드) Defaults to ''.
|
280
|
-
start (
|
281
|
-
end (
|
298
|
+
symbol (str | None, optional): 종목정보(종목코드) Defaults to ''.
|
299
|
+
start (datetime | None, optional): 조회 시작일자. Defaults to None.
|
300
|
+
end (datetime | None, optional): 조회 종료일자. Defaults to None.
|
282
301
|
base_market (str, optional): Market 구분 코드. Defaults to 'KRW'.
|
283
302
|
"""
|
284
303
|
pass
|
ksxt/base/rest_exchange.py
CHANGED
@@ -5,7 +5,7 @@ import toml
|
|
5
5
|
import os
|
6
6
|
from pathlib import Path
|
7
7
|
|
8
|
-
from typing import Any, Dict, List, Literal
|
8
|
+
from typing import Any, Dict, List, Literal
|
9
9
|
|
10
10
|
from datetime import datetime, UTC
|
11
11
|
import pytz
|
@@ -232,16 +232,14 @@ class RestExchange(Exchange):
|
|
232
232
|
security_type,
|
233
233
|
method_type,
|
234
234
|
api_type: Any = "public",
|
235
|
-
headers:
|
236
|
-
body:
|
237
|
-
params:
|
235
|
+
headers: Any | None = None,
|
236
|
+
body: Any | None = None,
|
237
|
+
params: Any | None = None,
|
238
238
|
config={},
|
239
239
|
):
|
240
240
|
pass
|
241
241
|
|
242
|
-
def fetch2(
|
243
|
-
self, path, security_type, params={}, headers: Optional[Any] = None, body: Optional[Any] = None, config={}
|
244
|
-
):
|
242
|
+
def fetch2(self, path, security_type, params={}, headers: Any | None = None, body: Any | None = None, config={}):
|
245
243
|
is_activate = self.is_activate(path=path, security_type=security_type)
|
246
244
|
if not is_activate:
|
247
245
|
return {
|
@@ -266,9 +264,7 @@ class RestExchange(Exchange):
|
|
266
264
|
request = self.sign(path, security_type, method_type, api_type, headers, body, params, config)
|
267
265
|
return self.fetch(request["url"], request["method"], request["headers"], request["body"], request["params"])
|
268
266
|
|
269
|
-
def request(
|
270
|
-
self, path, security_type, params={}, headers: Optional[Any] = None, body: Optional[Any] = None, config={}
|
271
|
-
):
|
267
|
+
def request(self, path, security_type, params={}, headers: Any | None = None, body: Any | None = None, config={}):
|
272
268
|
return self.fetch2(path, security_type, params, headers, body, config)
|
273
269
|
|
274
270
|
# region base method
|
@@ -296,8 +292,8 @@ class RestExchange(Exchange):
|
|
296
292
|
self,
|
297
293
|
symbol: str,
|
298
294
|
time_frame: str,
|
299
|
-
start:
|
300
|
-
end:
|
295
|
+
start: datetime | None = None,
|
296
|
+
end: datetime | None = None,
|
301
297
|
base_market: str = "KRW",
|
302
298
|
) -> ksxt.models.KsxtHistoricalDataResponse:
|
303
299
|
raise NotSupportedError(f"{self.id} {self.fetch_historical_data_index.__qualname__}() is not supported yet.")
|
@@ -307,8 +303,8 @@ class RestExchange(Exchange):
|
|
307
303
|
self,
|
308
304
|
symbol: str,
|
309
305
|
time_frame: str,
|
310
|
-
start:
|
311
|
-
end:
|
306
|
+
start: datetime | None = None,
|
307
|
+
end: datetime | None = None,
|
312
308
|
base_market: str = "KRW",
|
313
309
|
) -> ksxt.models.KsxtHistoricalDataResponse:
|
314
310
|
raise NotSupportedError(f"{self.id} {self.fetch_historical_data.__qualname__}() is not supported yet.")
|
@@ -323,7 +319,13 @@ class RestExchange(Exchange):
|
|
323
319
|
|
324
320
|
@check_token
|
325
321
|
def fetch_balance(
|
326
|
-
self,
|
322
|
+
self,
|
323
|
+
acc_num: str,
|
324
|
+
base_market: str = "KRW",
|
325
|
+
excluded_symbols: list[str] | None = None,
|
326
|
+
included_symbols: list[str] | None = None,
|
327
|
+
filter_delisted: bool = True,
|
328
|
+
min_amount: float = 0,
|
327
329
|
) -> ksxt.models.KsxtBalanceResponse:
|
328
330
|
raise NotSupportedError(f"{self.id} {self.fetch_balance.__qualname__}() is not supported yet.")
|
329
331
|
|
@@ -344,12 +346,14 @@ class RestExchange(Exchange):
|
|
344
346
|
raise NotSupportedError(f"{self.id} {self.fetch_screener.__qualname__}() is not supported yet.")
|
345
347
|
|
346
348
|
@check_token
|
347
|
-
def fetch_deposit_history(
|
349
|
+
def fetch_deposit_history(
|
350
|
+
self, acc_num: str, start: datetime | None = None, end: datetime | None = None, base_market: str = "KRW"
|
351
|
+
) -> ksxt.models.KsxtDepositHistoryResponse:
|
348
352
|
raise NotSupportedError(f"{self.id} {self.fetch_deposit_history.__qualname__}() is not supported yet.")
|
349
353
|
|
350
354
|
@check_token
|
351
355
|
def fetch_withdrawal_history(
|
352
|
-
self, acc_num: str, base_market: str = "KRW"
|
356
|
+
self, acc_num: str, start: datetime | None = None, end: datetime | None = None, base_market: str = "KRW"
|
353
357
|
) -> ksxt.models.KsxtWithdrawalHistoryResponse:
|
354
358
|
raise NotSupportedError(f"{self.id} {self.fetch_withdrawal_history.__qualname__}() is not supported yet.")
|
355
359
|
|
@@ -360,16 +364,16 @@ class RestExchange(Exchange):
|
|
360
364
|
symbol: str,
|
361
365
|
ticket_type: Literal["EntryLong", "EntryShort", "ExitLong", "ExitShort"],
|
362
366
|
otype: Literal["limit", "market"],
|
363
|
-
price:
|
364
|
-
qty:
|
365
|
-
amount:
|
367
|
+
price: float | None = 0,
|
368
|
+
qty: float | None = 0,
|
369
|
+
amount: float | None = 0,
|
366
370
|
base_market: str = "KRW",
|
367
371
|
) -> ksxt.models.KsxtCreateOrderResponse:
|
368
372
|
raise NotSupportedError(f"{self.id} {self.create_order.__qualname__}() is not supported yet.")
|
369
373
|
|
370
374
|
@check_token
|
371
375
|
def cancel_order(
|
372
|
-
self, acc_num: str, order_id: str, symbol:
|
376
|
+
self, acc_num: str, order_id: str, symbol: str | None = "", qty: float = 0, *args, base_market: str = "KRW"
|
373
377
|
) -> ksxt.models.KsxtCancelOrderResponse:
|
374
378
|
raise NotSupportedError(f"{self.id} {self.cancel_order.__qualname__}() is not supported yet.")
|
375
379
|
|
@@ -381,7 +385,7 @@ class RestExchange(Exchange):
|
|
381
385
|
price: float,
|
382
386
|
qty: float,
|
383
387
|
*args,
|
384
|
-
symbol:
|
388
|
+
symbol: str | None = "",
|
385
389
|
base_market: str = "KRW",
|
386
390
|
) -> ksxt.models.KsxtModifyOrderResponse:
|
387
391
|
raise NotSupportedError(f"{self.id} {self.modify_order.__qualname__}() is not supported yet.")
|
@@ -390,9 +394,9 @@ class RestExchange(Exchange):
|
|
390
394
|
def fetch_open_order(
|
391
395
|
self,
|
392
396
|
acc_num: str,
|
393
|
-
symbol:
|
394
|
-
start:
|
395
|
-
end:
|
397
|
+
symbol: str | None = "",
|
398
|
+
start: datetime | None = None,
|
399
|
+
end: datetime | None = None,
|
396
400
|
base_market: str = "KRW",
|
397
401
|
) -> ksxt.models.KsxtOpenOrderResponse:
|
398
402
|
raise NotSupportedError(f"{self.id} {self.fetch_open_order.__qualname__}() is not supported yet.")
|
@@ -401,9 +405,9 @@ class RestExchange(Exchange):
|
|
401
405
|
def fetch_closed_order(
|
402
406
|
self,
|
403
407
|
acc_num: str,
|
404
|
-
symbol:
|
405
|
-
start:
|
406
|
-
end:
|
408
|
+
symbol: str | None = "",
|
409
|
+
start: datetime | None = None,
|
410
|
+
end: datetime | None = None,
|
407
411
|
base_market: str = "KRW",
|
408
412
|
) -> ksxt.models.KsxtClosedOrderResponse:
|
409
413
|
raise NotSupportedError(f"{self.id} {self.fetch_closed_order.__qualname__}() is not supported yet.")
|
ksxt/bithumb.py
CHANGED
@@ -3,7 +3,7 @@ import hashlib
|
|
3
3
|
import hmac
|
4
4
|
import json
|
5
5
|
import time
|
6
|
-
from datetime import datetime
|
6
|
+
from datetime import datetime, timezone
|
7
7
|
from typing import Any, Dict, List, Literal, Optional
|
8
8
|
from urllib.parse import urlencode
|
9
9
|
import uuid
|
@@ -25,6 +25,10 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
25
25
|
self.timezone = pytz.timezone("Asia/Seoul")
|
26
26
|
|
27
27
|
def safe_symbol(self, base_market: str, security: str) -> str:
|
28
|
+
# If security already contains a hyphen, assume it's correctly formatted
|
29
|
+
if "-" in security:
|
30
|
+
return security
|
31
|
+
|
28
32
|
return f"{base_market}-{security}"
|
29
33
|
|
30
34
|
def safe_security(self, symbol: str) -> str:
|
@@ -119,6 +123,10 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
119
123
|
) -> ksxt.models.KsxtHistoricalDataResponse:
|
120
124
|
params = {"market": self.safe_symbol(base_market=base_market, security=symbol), "count": 200}
|
121
125
|
|
126
|
+
if end:
|
127
|
+
end_utc = end.astimezone(timezone.utc)
|
128
|
+
params.update({"to": end_utc.strftime("%Y-%m-%d %H:%M:%S")})
|
129
|
+
|
122
130
|
common_header = self.create_common_header(request_params=params)
|
123
131
|
|
124
132
|
# TODO : time_frame 을 어떻게 고정시킬까? 우리는 분봉, 일봉, 주봉, 월봉 만 지원한다고 가정하면?
|
@@ -142,7 +150,10 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
142
150
|
if common_response.success != "0":
|
143
151
|
return ksxt.models.KsxtHistoricalDataResponse(header=common_header, response=common_response, info=None)
|
144
152
|
|
145
|
-
parsed_response = self.parser.parse_historical_data(
|
153
|
+
parsed_response = self.parser.parse_historical_data(
|
154
|
+
response=response, symbol=symbol, start=start, end=end, base_market=base_market
|
155
|
+
)
|
156
|
+
|
146
157
|
return ksxt.models.KsxtHistoricalDataResponse(
|
147
158
|
header=common_header, response=common_response, info=parsed_response
|
148
159
|
)
|
@@ -222,7 +233,13 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
222
233
|
return ksxt.models.KsxtMultiOrderBookResponse(header=common_header, response=common_response, info=parsed_info)
|
223
234
|
|
224
235
|
def fetch_balance(
|
225
|
-
self,
|
236
|
+
self,
|
237
|
+
acc_num: str,
|
238
|
+
base_market: str = "KRW",
|
239
|
+
excluded_symbols: list[str] | None = None,
|
240
|
+
included_symbols: list[str] | None = None,
|
241
|
+
filter_delisted: bool = True,
|
242
|
+
min_amount: float = 0,
|
226
243
|
) -> ksxt.models.KsxtBalanceResponse:
|
227
244
|
params = {}
|
228
245
|
|
@@ -237,7 +254,14 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
237
254
|
return ksxt.models.KsxtBalanceResponse(header=common_header, response=common_response, info=None)
|
238
255
|
|
239
256
|
# 데이터 파싱
|
240
|
-
parsed_info = self.parser.parse_balance(
|
257
|
+
parsed_info = self.parser.parse_balance(
|
258
|
+
response=response,
|
259
|
+
base_market=base_market,
|
260
|
+
excluded_symbols=excluded_symbols,
|
261
|
+
included_symbols=included_symbols,
|
262
|
+
filter_delisted=filter_delisted,
|
263
|
+
min_amount=min_amount,
|
264
|
+
)
|
241
265
|
|
242
266
|
return ksxt.models.KsxtBalanceResponse(header=common_header, response=common_response, info=parsed_info)
|
243
267
|
|
@@ -341,8 +365,8 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
341
365
|
self,
|
342
366
|
acc_num: str,
|
343
367
|
symbol: str | None = "",
|
344
|
-
start:
|
345
|
-
end:
|
368
|
+
start: datetime | None = None,
|
369
|
+
end: datetime | None = None,
|
346
370
|
base_market: str = "KRW",
|
347
371
|
) -> ksxt.models.KsxtOpenOrderResponse:
|
348
372
|
params = {
|
@@ -362,7 +386,9 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
362
386
|
return ksxt.models.KsxtOpenOrderResponse(header=common_header, response=common_response, info=None)
|
363
387
|
|
364
388
|
# 데이터 파싱
|
365
|
-
parsed_info = self.parser.parse_open_order_history(
|
389
|
+
parsed_info = self.parser.parse_open_order_history(
|
390
|
+
response=response, start=start, end=end, base_market=base_market
|
391
|
+
)
|
366
392
|
|
367
393
|
return ksxt.models.KsxtOpenOrderResponse(header=common_header, response=common_response, info=parsed_info)
|
368
394
|
|
@@ -370,8 +396,8 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
370
396
|
self,
|
371
397
|
acc_num: str,
|
372
398
|
symbol: Optional[str] = "",
|
373
|
-
start:
|
374
|
-
end:
|
399
|
+
start: datetime | None = None,
|
400
|
+
end: datetime | None = None,
|
375
401
|
base_market: str = "KRW",
|
376
402
|
) -> ksxt.models.KsxtClosedOrderResponse:
|
377
403
|
params = {"market": self.safe_symbol(base_market, symbol), "uuids": "", "state": "done"}
|
@@ -387,7 +413,9 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
387
413
|
return ksxt.models.KsxtClosedOrderResponse(header=common_header, response=common_response, info=None)
|
388
414
|
|
389
415
|
# 데이터 파싱
|
390
|
-
parsed_info = self.parser.parse_closed_order_history(
|
416
|
+
parsed_info = self.parser.parse_closed_order_history(
|
417
|
+
response=response, start=start, end=end, base_market=base_market
|
418
|
+
)
|
391
419
|
|
392
420
|
return ksxt.models.KsxtClosedOrderResponse(header=common_header, response=common_response, info=parsed_info)
|
393
421
|
|
@@ -464,7 +492,7 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
464
492
|
return ksxt.models.KsxtCreateOrderResponse(header=common_header, response=common_response, info=parsed_info)
|
465
493
|
|
466
494
|
def fetch_withdrawal_history(
|
467
|
-
self, acc_num: str, base_market: str = "KRW"
|
495
|
+
self, acc_num: str, start: datetime | None = None, end: datetime | None = None, base_market: str = "KRW"
|
468
496
|
) -> ksxt.models.KsxtWithdrawalHistoryResponse:
|
469
497
|
params = {"state": "done", "uuids": "", "txids": ""}
|
470
498
|
|
@@ -479,13 +507,17 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
479
507
|
return ksxt.models.KsxtWithdrawalHistoryResponse(header=common_header, response=common_response, info=None)
|
480
508
|
|
481
509
|
# 데이터 파싱
|
482
|
-
parsed_info = self.parser.parse_withdrawal_history(
|
510
|
+
parsed_info = self.parser.parse_withdrawal_history(
|
511
|
+
response=response, start=start, end=end, base_market=base_market
|
512
|
+
)
|
483
513
|
|
484
514
|
return ksxt.models.KsxtWithdrawalHistoryResponse(
|
485
515
|
header=common_header, response=common_response, info=parsed_info
|
486
516
|
)
|
487
517
|
|
488
|
-
def fetch_deposit_history(
|
518
|
+
def fetch_deposit_history(
|
519
|
+
self, acc_num: str, start: datetime | None = None, end: datetime | None = None, base_market: str = "KRW"
|
520
|
+
) -> ksxt.models.KsxtDepositHistoryResponse:
|
489
521
|
params = {"state": "ACCEPTED", "uuids": "", "txids": ""}
|
490
522
|
|
491
523
|
common_header = self.create_common_header(request_params=params)
|
@@ -499,7 +531,9 @@ class Bithumb(RestExchange, ImplicitAPI):
|
|
499
531
|
return ksxt.models.KsxtWithdrawalHistoryResponse(header=common_header, response=common_response, info=None)
|
500
532
|
|
501
533
|
# 데이터 파싱
|
502
|
-
parsed_info = self.parser.parse_deposit_history(
|
534
|
+
parsed_info = self.parser.parse_deposit_history(
|
535
|
+
response=response, start=start, end=end, base_market=base_market
|
536
|
+
)
|
503
537
|
|
504
538
|
return ksxt.models.KsxtWithdrawalHistoryResponse(
|
505
539
|
header=common_header, response=common_response, info=parsed_info
|
Binary file
|
ksxt/config/token.toml
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
[
|
2
|
-
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
|
3
|
-
expired = "2024-06-
|
4
|
-
|
5
|
-
[PSCWKArP3T1L4qMgyZ4DXIDlqcaK48jJW1J5]
|
6
|
-
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b2tlbiIsImF1ZCI6IjVjMWYzMWZhLTViYzEtNGM1OS04OGY1LTk5OTU5NmExMmMzMCIsInByZHRfY2QiOiIiLCJpc3MiOiJ1bm9ndyIsImV4cCI6MTcxODAwNDQ4NywiaWF0IjoxNzE3OTE4MDg3LCJqdGkiOiJQU0NXS0FyUDNUMUw0cU1neVo0RFhJRGxxY2FLNDhqSlcxSjUifQ.D6R4xlYKqZQykIyQUA5SgB6vxIEG33f_m_MzSrB9xGRdVKjcr0CyMleWeenyTZLAu6hQpu-3133uYachjI1zjw"
|
7
|
-
expired = "2024-06-10 16:28:07"
|
1
|
+
[PSXkvBM1hQXJDRHg2rLvC7Tr8SoyPudlbx9o]
|
2
|
+
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0b2tlbiIsImF1ZCI6IjEyYzYxZWIxLTU3YzQtNGFiZC1iN2JhLTM0OGIwOTBjY2NlMyIsInByZHRfY2QiOiIiLCJpc3MiOiJ1bm9ndyIsImV4cCI6MTcxOTM1OTE1NiwiaWF0IjoxNzE5MjcyNzU2LCJqdGkiOiJQU1hrdkJNMWhRWEpEUkhnMnJMdkM3VHI4U295UHVkbGJ4OW8ifQ.B1CJ7IMEkkqVpQ7ECM8otr6lVVmV2Yp_bRaBBRlcOo29MIQZ5z8g5oEcXyO-ghaUa8UJZguuo8Q7iQreRBYkZg"
|
3
|
+
expired = "2024-06-26 08:45:56"
|
ksxt/koreainvest.py
CHANGED
@@ -125,7 +125,13 @@ class KoreaInvest(RestExchange, ImplicitAPI):
|
|
125
125
|
|
126
126
|
@RestExchange.check_token
|
127
127
|
def fetch_balance(
|
128
|
-
self,
|
128
|
+
self,
|
129
|
+
acc_num: str,
|
130
|
+
base_market: str = "KRW",
|
131
|
+
excluded_symbols: list[str] | None = None,
|
132
|
+
included_symbols: list[str] | None = None,
|
133
|
+
filter_delisted: bool = True,
|
134
|
+
min_amount: float = 0,
|
129
135
|
) -> ksxt.models.KsxtBalanceResponse:
|
130
136
|
if base_market == "KRW":
|
131
137
|
params = {
|
@@ -153,7 +159,12 @@ class KoreaInvest(RestExchange, ImplicitAPI):
|
|
153
159
|
return ksxt.models.KsxtBalanceResponse(header=common_header, response=common_response, info=None)
|
154
160
|
|
155
161
|
parsed_info = self.parser.parse_balance(
|
156
|
-
response=response,
|
162
|
+
response=response,
|
163
|
+
base_market=base_market,
|
164
|
+
excluded_symbols=excluded_symbols,
|
165
|
+
included_symbols=included_symbols,
|
166
|
+
filter_delisted=filter_delisted,
|
167
|
+
min_amount=min_amount,
|
157
168
|
)
|
158
169
|
|
159
170
|
return ksxt.models.KsxtBalanceResponse(header=common_header, response=common_response, info=parsed_info)
|
@@ -248,7 +259,12 @@ class KoreaInvest(RestExchange, ImplicitAPI):
|
|
248
259
|
|
249
260
|
@RestExchange.check_token
|
250
261
|
def fetch_historical_data_index(
|
251
|
-
self,
|
262
|
+
self,
|
263
|
+
symbol: str,
|
264
|
+
time_frame: str,
|
265
|
+
start: datetime | None = None,
|
266
|
+
end: datetime | None = None,
|
267
|
+
base_market: str = "KRW",
|
252
268
|
) -> ksxt.models.KsxtHistoricalDataResponse:
|
253
269
|
if time_frame.endswith("D"):
|
254
270
|
param_code = "D"
|
@@ -285,13 +301,22 @@ class KoreaInvest(RestExchange, ImplicitAPI):
|
|
285
301
|
if common_response.success != "0":
|
286
302
|
return ksxt.models.KsxtHistoricalDataResponse(header=common_header, response=common_response, info=None)
|
287
303
|
|
288
|
-
|
304
|
+
parsed_response = self.parser.parse_historical_index_data(
|
305
|
+
response=response, symbol=symbol, start=start, end=end, base_market=base_market
|
306
|
+
)
|
289
307
|
|
290
|
-
return ksxt.models.KsxtHistoricalDataResponse(
|
308
|
+
return ksxt.models.KsxtHistoricalDataResponse(
|
309
|
+
header=common_header, response=common_response, info=parsed_response
|
310
|
+
)
|
291
311
|
|
292
312
|
@RestExchange.check_token
|
293
313
|
def fetch_historical_data(
|
294
|
-
self,
|
314
|
+
self,
|
315
|
+
symbol: str,
|
316
|
+
time_frame: str,
|
317
|
+
start: datetime | None = None,
|
318
|
+
end: datetime | None = None,
|
319
|
+
base_market: str = "KRW",
|
295
320
|
) -> ksxt.models.KsxtHistoricalDataResponse:
|
296
321
|
if time_frame.endswith("D"):
|
297
322
|
param_code = "D"
|
@@ -341,9 +366,13 @@ class KoreaInvest(RestExchange, ImplicitAPI):
|
|
341
366
|
if common_response.success != "0":
|
342
367
|
return ksxt.models.KsxtHistoricalDataResponse(header=common_header, response=common_response, info=None)
|
343
368
|
|
344
|
-
|
369
|
+
parsed_response = self.parser.parse_historical_data(
|
370
|
+
response=response, symbol=symbol, start=start, end=end, base_market=base_market
|
371
|
+
)
|
345
372
|
|
346
|
-
return ksxt.models.KsxtHistoricalDataResponse(
|
373
|
+
return ksxt.models.KsxtHistoricalDataResponse(
|
374
|
+
header=common_header, response=common_response, info=parsed_response
|
375
|
+
)
|
347
376
|
|
348
377
|
@RestExchange.check_token
|
349
378
|
def modify_order(
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|