Skip to content

Commit c653e88

Browse files
authored
Merge pull request #6 from uJhin/1.1.7
Update Version 1.1.7.6
2 parents 5e33468 + 8d82f1f commit c653e88

File tree

5 files changed

+57
-44
lines changed

5 files changed

+57
-44
lines changed

upbit/authentication.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ def matches(self, url):
3131
return MAPPER not in url
3232

3333
def apply(self, request):
34-
request.headers['User-Agent'] = "ujhin's Upbit SDKs"
34+
payload = self.generate_payload(request)
35+
36+
request.headers['User-Agent' ] = "ujhin's Upbit SDKs"
3537
request.headers['Accept-Encoding'] = 'gzip, deflate'
36-
request.headers['Accept'] = '*/*'
37-
request.headers['Connection'] = 'keep-alive'
38-
request.headers['Authorization'] = self.generate_payload(request)
38+
request.headers['Accept' ] = '*/*'
39+
request.headers['Connection' ] = 'keep-alive'
40+
request.headers['Authorization' ] = payload
3941
return request
4042

4143
def generate_payload(self, request):
@@ -51,11 +53,11 @@ def generate_payload(self, request):
5153
if params:
5254
query = self.generate_query(params)
5355

54-
h = hashlib.sha512()
55-
h.update(query.encode())
56-
query_hash = h.hexdigest()
56+
sha512 = hashlib.sha512()
57+
sha512.update(query.encode())
58+
query_hash = sha512.hexdigest()
5759

58-
payload['query_hash'] = query_hash
60+
payload['query_hash' ] = query_hash
5961
payload['query_hash_alg'] = 'SHA512'
6062

6163
jwt_token = jwt.encode(payload, self.secret_key)

upbit/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ def __init__(
3131
**kwargs
3232
).SWGClient
3333

34-
self.APIKey = models.APIKey(self.__client)
35-
self.Account = models.Account(self.__client)
36-
self.Candle = models.Candle(self.__client)
37-
self.Deposit = models.Deposit(self.__client)
38-
self.Market = models.Market(self.__client)
39-
self.Order = models.Order(self.__client)
40-
self.Trade = models.Trade(self.__client)
34+
self.APIKey = models.APIKey(self.__client)
35+
self.Account = models.Account(self.__client)
36+
self.Candle = models.Candle(self.__client)
37+
self.Deposit = models.Deposit(self.__client)
38+
self.Market = models.Market(self.__client)
39+
self.Order = models.Order(self.__client)
40+
self.Trade = models.Trade(self.__client)
4141
self.Withdraw = models.Withdraw(self.__client)
4242

4343
def __str__(self):

upbit/models.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def Candle_minutes(self, **kwargs) -> dict:
139139
:type to: str
140140
141141
:param count: 캔들 개수 (최대 200개까지 요청 가능) (optional)
142-
:type count: number
142+
:type count: int
143143
"""
144144

145145
future = self.__client.Candle.Candle_minutes(**kwargs)
@@ -160,7 +160,7 @@ def Candle_days(self, **kwargs) -> dict:
160160
:type to: str
161161
162162
:param count: 캔들 개수 (optional)
163-
:type count: number
163+
:type count: int
164164
165165
:param convertingPriceUnit: 종가 환산 화폐 단위 (생략 가능, KRW로 명시할 시 원화 환산 가격을 반환.)
166166
`convertingPriceUnit` 파라미터의 경우, 원화 마켓이 아닌 다른 마켓(ex. BTC, ETH)의 일봉 요청 시
@@ -187,7 +187,7 @@ def Candle_weeks(self, **kwargs) -> dict:
187187
:type to: str
188188
189189
:param count: 캔들 개수 (optional)
190-
:type count: number
190+
:type count: int
191191
"""
192192

193193
future = self.__client.Candle.Candle_weeks(**kwargs)
@@ -208,7 +208,7 @@ def Candle_month(self, **kwargs) -> dict:
208208
:type to: str
209209
210210
:param count: 캔들 개수 (optional)
211-
:type count: number
211+
:type count: int
212212
"""
213213

214214
future = self.__client.Candle.Candle_month(**kwargs)
@@ -269,7 +269,7 @@ def Deposit_generate_coin_address(self, **kwargs) -> dict:
269269
270270
271271
:param currency: Currency 코드
272-
:type currency: string
272+
:type currency: str
273273
"""
274274

275275
future = self.__client.Deposit.Deposit_generate_coin_address(**kwargs)
@@ -282,13 +282,13 @@ def Deposit_info(self, **kwargs) -> dict:
282282
## 개별 입금 조회
283283
284284
:param uuid: 입금 UUID (optional)
285-
:type uuid: string
285+
:type uuid: str
286286
287287
:param txid: 입금 TXID (optional)
288-
:type txid: string
288+
:type txid: str
289289
290290
:param currency: Currency 코드 (optional)
291-
:type currency: string
291+
:type currency: str
292292
"""
293293

294294
future = self.__client.Deposit.Deposit_info(**kwargs)
@@ -319,10 +319,10 @@ def Deposit_info_all(self, **kwargs) -> dict:
319319
:type txids: list
320320
321321
:param limit: 개수 제한 (default: 100, max: 100) (optional)
322-
:type limit: number
322+
:type limit: int
323323
324324
:param page: 페이지 수, default: 1 (optional)
325-
:type page: number
325+
:type page: int
326326
327327
:param order_by: 정렬 방식 (optional)
328328
- asc : 오름차순
@@ -431,10 +431,10 @@ def Order_info_all(self, **kwargs) -> dict:
431431
:type identifiers: array
432432
433433
:param page: 페이지 수, default: 1 (optional)
434-
:type page: number
434+
:type page: int
435435
436436
:param limit: 요청 개수, default: 100 (optional)
437-
:type limit: number
437+
:type limit: int
438438
439439
:param order_by: 정렬 방식 (optional)
440440
- asc : 오름차순
@@ -505,10 +505,10 @@ def Order_cancel(self, **kwargs) -> dict:
505505
[NOTE] `uuid` 혹은 `identifier` 둘 중 하나의 값이 반드시 포함되어야 합니다.
506506
507507
:param uuid: 취소할 주문의 UUID (optional)
508-
:type uuid: string
508+
:type uuid: str
509509
510510
:param identifier: 조회용 사용자 지정 값 (optional)
511-
:type identifier: string
511+
:type identifier: str
512512
"""
513513

514514
future = self.__client.Order.Order_cancel(**kwargs)
@@ -553,7 +553,7 @@ def Trade_ticks(self, **kwargs) -> dict:
553553
:type to: str
554554
555555
:param count: 체결 개수 (optional)
556-
:type count: number
556+
:type count: int
557557
558558
:param cursor: 페이지네이션 커서 (sequentialId)
559559
`sequential_id` 필드는 체결의 유일성 판단을 위한 근거로 쓰일 수 있습니다.
@@ -562,7 +562,7 @@ def Trade_ticks(self, **kwargs) -> dict:
562562
563563
:param daysAgo: 최근 체결 날짜 기준 7일 이내의 이전 데이터 조회 가능.
564564
비워서 요청 시 가장 최근 체결 날짜 반환. (범위: 1 ~ 7) (optional)
565-
:type daysAgo: number
565+
:type daysAgo: int
566566
"""
567567

568568
future = self.__client.Trade.Trade_ticks(**kwargs)
@@ -611,7 +611,7 @@ def Withdraw_coin(self, **kwargs) -> dict:
611611
:type address: str
612612
613613
:param secondary_address: 2차 출금 주소 (필요한 코인에 한해서) (optional)
614-
:type secondary_address: string
614+
:type secondary_address: str
615615
616616
:param transaction_type: 출금 유형 (optional)
617617
- default : 일반출금
@@ -648,7 +648,7 @@ def Withdraw_info_all(self, **kwargs) -> dict:
648648
## 출금 리스트를 조회한다.
649649
650650
:param currency: Currency 코드 (optional)
651-
:type currency: string
651+
:type currency: str
652652
653653
:param state: 출금 상태 (optional)
654654
- submitting : 처리 중
@@ -659,7 +659,7 @@ def Withdraw_info_all(self, **kwargs) -> dict:
659659
- processing : 처리 중
660660
- done : 완료
661661
- canceled : 취소됨
662-
:type state: string
662+
:type state: str
663663
664664
:param uuids: 출금 UUID의 목록 (optional)
665665
:type uuids: list
@@ -668,10 +668,10 @@ def Withdraw_info_all(self, **kwargs) -> dict:
668668
:type txids: list
669669
670670
:param limit: 개수 제한 (default: 100, max: 100) (optional)
671-
:type limit: number
671+
:type limit: int
672672
673673
:param page: 페이지 수, default: 1 (optional)
674-
:type page: number
674+
:type page: int
675675
676676
:param order_by: 정렬 방식 (optional)
677677
- asc : 오름차순

upbit/pkginfo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ def _get_versions(package_name):
2929
PACKAGE_NAME = 'upbit-client'
3030

3131
OPEN_API_VERSION = '1.1.7'
32-
CURRENT_VERSION = OPEN_API_VERSION+'.5'
32+
CURRENT_VERSION = OPEN_API_VERSION+'.6'
3333

3434
RELEASED_VERSION = _get_versions(PACKAGE_NAME)
3535
LATEST_VERSION = RELEASED_VERSION[0]
3636

3737

3838
if LATEST_VERSION != CURRENT_VERSION:
3939
logging.basicConfig(format="[%(levelname)s] %(message)s")
40-
logging.warning(f"""
41-
{PACKAGE_NAME} is currently a newer version: {LATEST_VERSION}\n
42-
Please update to the latest version using the pip command:
43-
`pip install --upgrade {PACKAGE_NAME}`
44-
""")
40+
logging.warning(
41+
f"{PACKAGE_NAME} is currently a newer version: {LATEST_VERSION}\n"
42+
f"Please update to the latest version using the pip command:"
43+
f"`pip install --upgrade {PACKAGE_NAME}`"
44+
)

upbit/websocket.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
WEBSOCKET_URI = "wss://api.upbit.com/websocket/v1"
1010

11+
FIELD_TYPES = ['ticker', 'trade', 'orderbook']
12+
FIELD_FORMATS = ['SIMPLE', 'DEFAULT']
13+
1114

1215
class UpbitWebSocket:
1316
"""
@@ -58,6 +61,14 @@ def connect(
5861
ping_interval: Union[int, float] = None,
5962
ping_timeout: Union[int, float] = None
6063
):
64+
"""
65+
:param ping_interval: ping 간격 제한
66+
:type ping_interval: Union[int, float]
67+
68+
:param ping_timeout: ping 시간 초과 제한
69+
:type ping_timeout: Union[int, float]
70+
"""
71+
6172
self.Connection = websockets.connect(
6273
uri=self.URI,
6374
ping_interval=ping_interval,
@@ -107,7 +118,7 @@ def generate_type_field(
107118

108119
field = {}
109120

110-
if type in ['ticker', 'trade', 'orderbook']:
121+
if type in FIELD_TYPES:
111122
field["type"] = type
112123
else:
113124
raise ValueError("'type' is not available")
@@ -147,7 +158,7 @@ def generate_payload(
147158
payload.extend(type_fields)
148159

149160
fmt = format.upper()
150-
fmt = fmt if fmt in ['SIMPLE', 'DEFAULT'] else 'DEFAULT'
161+
fmt = fmt if fmt in FIELD_FORMATS else 'DEFAULT'
151162
payload.append({"format": fmt})
152163

153164
return json.dumps(payload)

0 commit comments

Comments
 (0)