Skip to content

Commit

Permalink
Update Version 1.1.7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
uJhin committed Mar 4, 2021
1 parent a78f00a commit 813104d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 44 deletions.
18 changes: 10 additions & 8 deletions client/python/upbit/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ def matches(self, url):
return MAPPER not in url

def apply(self, request):
request.headers['User-Agent'] = "ujhin's Upbit SDKs"
payload = self.generate_payload(request)

request.headers['User-Agent' ] = "ujhin's Upbit SDKs"
request.headers['Accept-Encoding'] = 'gzip, deflate'
request.headers['Accept'] = '*/*'
request.headers['Connection'] = 'keep-alive'
request.headers['Authorization'] = self.generate_payload(request)
request.headers['Accept' ] = '*/*'
request.headers['Connection' ] = 'keep-alive'
request.headers['Authorization' ] = payload
return request

def generate_payload(self, request):
Expand All @@ -51,11 +53,11 @@ def generate_payload(self, request):
if params:
query = self.generate_query(params)

h = hashlib.sha512()
h.update(query.encode())
query_hash = h.hexdigest()
sha512 = hashlib.sha512()
sha512.update(query.encode())
query_hash = sha512.hexdigest()

payload['query_hash'] = query_hash
payload['query_hash' ] = query_hash
payload['query_hash_alg'] = 'SHA512'

jwt_token = jwt.encode(payload, self.secret_key)
Expand Down
14 changes: 7 additions & 7 deletions client/python/upbit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def __init__(
**kwargs
).SWGClient

self.APIKey = models.APIKey(self.__client)
self.Account = models.Account(self.__client)
self.Candle = models.Candle(self.__client)
self.Deposit = models.Deposit(self.__client)
self.Market = models.Market(self.__client)
self.Order = models.Order(self.__client)
self.Trade = models.Trade(self.__client)
self.APIKey = models.APIKey(self.__client)
self.Account = models.Account(self.__client)
self.Candle = models.Candle(self.__client)
self.Deposit = models.Deposit(self.__client)
self.Market = models.Market(self.__client)
self.Order = models.Order(self.__client)
self.Trade = models.Trade(self.__client)
self.Withdraw = models.Withdraw(self.__client)

def __str__(self):
Expand Down
42 changes: 21 additions & 21 deletions client/python/upbit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def Candle_minutes(self, **kwargs) -> dict:
:type to: str
:param count: 캔들 개수 (최대 200개까지 요청 가능) (optional)
:type count: number
:type count: int
"""

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

future = self.__client.Candle.Candle_weeks(**kwargs)
Expand All @@ -208,7 +208,7 @@ def Candle_month(self, **kwargs) -> dict:
:type to: str
:param count: 캔들 개수 (optional)
:type count: number
:type count: int
"""

future = self.__client.Candle.Candle_month(**kwargs)
Expand Down Expand Up @@ -269,7 +269,7 @@ def Deposit_generate_coin_address(self, **kwargs) -> dict:
:param currency: Currency 코드
:type currency: string
:type currency: str
"""

future = self.__client.Deposit.Deposit_generate_coin_address(**kwargs)
Expand All @@ -282,13 +282,13 @@ def Deposit_info(self, **kwargs) -> dict:
## 개별 입금 조회
:param uuid: 입금 UUID (optional)
:type uuid: string
:type uuid: str
:param txid: 입금 TXID (optional)
:type txid: string
:type txid: str
:param currency: Currency 코드 (optional)
:type currency: string
:type currency: str
"""

future = self.__client.Deposit.Deposit_info(**kwargs)
Expand Down Expand Up @@ -319,10 +319,10 @@ def Deposit_info_all(self, **kwargs) -> dict:
:type txids: list
:param limit: 개수 제한 (default: 100, max: 100) (optional)
:type limit: number
:type limit: int
:param page: 페이지 수, default: 1 (optional)
:type page: number
:type page: int
:param order_by: 정렬 방식 (optional)
- asc : 오름차순
Expand Down Expand Up @@ -431,10 +431,10 @@ def Order_info_all(self, **kwargs) -> dict:
:type identifiers: array
:param page: 페이지 수, default: 1 (optional)
:type page: number
:type page: int
:param limit: 요청 개수, default: 100 (optional)
:type limit: number
:type limit: int
:param order_by: 정렬 방식 (optional)
- asc : 오름차순
Expand Down Expand Up @@ -505,10 +505,10 @@ def Order_cancel(self, **kwargs) -> dict:
[NOTE] `uuid` 혹은 `identifier` 둘 중 하나의 값이 반드시 포함되어야 합니다.
:param uuid: 취소할 주문의 UUID (optional)
:type uuid: string
:type uuid: str
:param identifier: 조회용 사용자 지정 값 (optional)
:type identifier: string
:type identifier: str
"""

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

future = self.__client.Trade.Trade_ticks(**kwargs)
Expand Down Expand Up @@ -611,7 +611,7 @@ def Withdraw_coin(self, **kwargs) -> dict:
:type address: str
:param secondary_address: 2차 출금 주소 (필요한 코인에 한해서) (optional)
:type secondary_address: string
:type secondary_address: str
:param transaction_type: 출금 유형 (optional)
- default : 일반출금
Expand Down Expand Up @@ -648,7 +648,7 @@ def Withdraw_info_all(self, **kwargs) -> dict:
## 출금 리스트를 조회한다.
:param currency: Currency 코드 (optional)
:type currency: string
:type currency: str
:param state: 출금 상태 (optional)
- submitting : 처리 중
Expand All @@ -659,7 +659,7 @@ def Withdraw_info_all(self, **kwargs) -> dict:
- processing : 처리 중
- done : 완료
- canceled : 취소됨
:type state: string
:type state: str
:param uuids: 출금 UUID의 목록 (optional)
:type uuids: list
Expand All @@ -668,10 +668,10 @@ def Withdraw_info_all(self, **kwargs) -> dict:
:type txids: list
:param limit: 개수 제한 (default: 100, max: 100) (optional)
:type limit: number
:type limit: int
:param page: 페이지 수, default: 1 (optional)
:type page: number
:type page: int
:param order_by: 정렬 방식 (optional)
- asc : 오름차순
Expand Down
12 changes: 6 additions & 6 deletions client/python/upbit/pkginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def _get_versions(package_name):
PACKAGE_NAME = 'upbit-client'

OPEN_API_VERSION = '1.1.7'
CURRENT_VERSION = OPEN_API_VERSION+'.5'
CURRENT_VERSION = OPEN_API_VERSION+'.6'

RELEASED_VERSION = _get_versions(PACKAGE_NAME)
LATEST_VERSION = RELEASED_VERSION[0]


if LATEST_VERSION != CURRENT_VERSION:
logging.basicConfig(format="[%(levelname)s] %(message)s")
logging.warning(f"""
{PACKAGE_NAME} is currently a newer version: {LATEST_VERSION}\n
Please update to the latest version using the pip command:
`pip install --upgrade {PACKAGE_NAME}`
""")
logging.warning(
f"{PACKAGE_NAME} is currently a newer version: {LATEST_VERSION}\n"
f"Please update to the latest version using the pip command:"
f"`pip install --upgrade {PACKAGE_NAME}`"
)
15 changes: 13 additions & 2 deletions client/python/upbit/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

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

FIELD_TYPES = ['ticker', 'trade', 'orderbook']
FIELD_FORMATS = ['SIMPLE', 'DEFAULT']


class UpbitWebSocket:
"""
Expand Down Expand Up @@ -58,6 +61,14 @@ def connect(
ping_interval: Union[int, float] = None,
ping_timeout: Union[int, float] = None
):
"""
:param ping_interval: ping 간격 제한
:type ping_interval: Union[int, float]
:param ping_timeout: ping 시간 초과 제한
:type ping_timeout: Union[int, float]
"""

self.Connection = websockets.connect(
uri=self.URI,
ping_interval=ping_interval,
Expand Down Expand Up @@ -107,7 +118,7 @@ def generate_type_field(

field = {}

if type in ['ticker', 'trade', 'orderbook']:
if type in FIELD_TYPES:
field["type"] = type
else:
raise ValueError("'type' is not available")
Expand Down Expand Up @@ -147,7 +158,7 @@ def generate_payload(
payload.extend(type_fields)

fmt = format.upper()
fmt = fmt if fmt in ['SIMPLE', 'DEFAULT'] else 'DEFAULT'
fmt = fmt if fmt in FIELD_FORMATS else 'DEFAULT'
payload.append({"format": fmt})

return json.dumps(payload)
Expand Down

0 comments on commit 813104d

Please sign in to comment.