Skip to content

Commit

Permalink
Merge pull request #24 from uJhin/1.3.1
Browse files Browse the repository at this point in the history
[Update] Update Version 1.3.1.0
  • Loading branch information
uJhin authored Feb 6, 2022
2 parents 1085538 + 49c13b1 commit 13b7c93
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
classifiers = [
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
'Programming Language :: Python :: 3.10',
],
keywords = [
'Upbit',
Expand Down
4 changes: 2 additions & 2 deletions upbit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Please read the official Upbit Client document.
Documents: https://ujhin.github.io/upbit-client-docs/
- Upbit OPEN API Version: 1.2.2
- Upbit OPEN API Version: 1.3.1
- Author: ujhin
- Email: [email protected]
- GitHub: https://github.com/uJhin
Expand All @@ -15,5 +15,5 @@
from . import pkginfo


__all__ = ['client', 'websocket']
__all__ = [ "client", "websocket" ]
__version__ = pkginfo.CURRENT_VERSION
4 changes: 2 additions & 2 deletions upbit/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
class APIKeyAuthenticator(Authenticator):

MAPPER = "swg_mapper.json"
QUERY_PARAMS = ("uuids", "txids", "identifiers", "states")
QUERY_PARAMS = ( "uuids", "txids", "identifiers", "states" )


def __init__(
self,
host: str,
host : str,
access_key: str,
secret_key: str
):
Expand Down
2 changes: 1 addition & 1 deletion upbit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Upbit:
- Base URL: https://api.upbit.com
- Base Path: /v1
- Upbit OPEN API Version: 1.2.2
- Upbit OPEN API Version: 1.3.1
- Author: ujhin
- Email: [email protected]
- GitHub: https://github.com/uJhin
Expand Down
16 changes: 8 additions & 8 deletions upbit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ def __init__(
**kwargs
):

arg_config = kwargs.get('config')
arg_spec_uri = kwargs.get('spec_uri')
arg_config = kwargs.get("config")
arg_spec_uri = kwargs.get("spec_uri")
config = {
'also_return_response': False,
'validate_responses': False,
'use_models': False,
'host': HOST
"also_return_response": False,
"validate_responses" : False,
"use_models" : False,
"host" : HOST
} if not arg_config else arg_config
spec_uri = SPEC_URI if not arg_spec_uri else arg_spec_uri

if access_key and secret_key:

request_client = RequestsClient()
request_client.authenticator = APIKeyAuthenticator(
host=config['host'],
host=config["host"],
access_key=access_key,
secret_key=secret_key
)
Expand All @@ -55,7 +55,7 @@ def __init__(
)

@property
def SWGClient(self):
def SWGClient(self) -> SwaggerClient:
return self.__client


Expand Down
6 changes: 3 additions & 3 deletions upbit/pkginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Please read the official Upbit Client document.
Documents: https://ujhin.github.io/upbit-client-docs/
- Upbit OPEN API Version: 1.2.2
- Upbit OPEN API Version: 1.3.1
- Author: ujhin
- Email: [email protected]
- GitHub: https://github.com/uJhin
Expand All @@ -28,8 +28,8 @@ def _get_versions(package_name):

PACKAGE_NAME = "upbit-client"

OPEN_API_VERSION = "1.2.2"
CURRENT_VERSION = OPEN_API_VERSION+".4"
OPEN_API_VERSION = "1.3.1"
CURRENT_VERSION = OPEN_API_VERSION+".0"

RELEASED_VERSION = _get_versions(PACKAGE_NAME)
LATEST_VERSION = RELEASED_VERSION[0]
Expand Down
8 changes: 4 additions & 4 deletions upbit/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

from typing import Union
import typing as t


class HTTPFutureExtractor:

@staticmethod
def remaining_request(headers: dict) -> dict:
def remaining_request(headers: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
"""
Check Request limit times
Expand All @@ -24,7 +24,7 @@ def remaining_request(headers: dict) -> dict:
}

@staticmethod
def future_extraction(http_future) -> dict:
def future_extraction(http_future) -> t.Dict[str, t.Any]:
resp = http_future.future.result()
remaining = HTTPFutureExtractor.remaining_request(resp.headers)

Expand Down Expand Up @@ -59,7 +59,7 @@ def future_extraction(http_future) -> dict:
class Validator:

@staticmethod
def validate_price(price: Union[int, float, str]) -> float:
def validate_price(price: t.Union[int, float, str]) -> float:
"""
Please read the official Upbit Client document.
Documents: https://ujhin.github.io/upbit-client-docs/
Expand Down
38 changes: 19 additions & 19 deletions upbit/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid
import json

from typing import Union, List
import typing as t


class UpbitWebSocket:
Expand All @@ -21,15 +21,15 @@ class UpbitWebSocket:
"""

WEBSOCKET_URI = "wss://api.upbit.com/websocket/v1"
FIELD_TYPES = ("ticker", "trade", "orderbook")
FIELD_FORMATS = ("SIMPLE", "DEFAULT")
FIELD_TYPES = ( "ticker", "trade", "orderbook" )
FIELD_FORMATS = ( "SIMPLE", "DEFAULT" )


def __init__(
self,
uri: Union[str] = None,
ping_interval: Union[int, float] = None,
ping_timeout: Union[int, float] = None
uri : str = None,
ping_interval: t.Union[int, float] = None,
ping_timeout : t.Union[int, float] = None
):

self.__uri = uri if uri else UpbitWebSocket.WEBSOCKET_URI
Expand Down Expand Up @@ -59,8 +59,8 @@ def Connection(self, conn):

def connect(
self,
ping_interval: Union[int, float] = None,
ping_timeout: Union[int, float] = None
ping_interval: t.Union[int, float] = None,
ping_timeout : t.Union[int, float] = None
):
"""
:param ping_interval: ping 간격 제한
Expand Down Expand Up @@ -90,9 +90,9 @@ async def ping(self, decode: str = "utf8"):

@staticmethod
def generate_orderbook_codes(
currencies: Union[List[str]],
counts: Union[List[int]] = None
) -> List[str]:
currencies: t.List[str],
counts : t.List[int] = None
) -> t.List[str]:
"""
:param currencies: 수신할 `orderbook` field 마켓 코드 리스트
:type currencies: list[str, ...]
Expand All @@ -111,11 +111,11 @@ def generate_orderbook_codes(

@staticmethod
def generate_type_field(
type: str,
codes: Union[List[str]],
type : str,
codes : t.List[str],
isOnlySnapshot: bool = None,
isOnlyRealtime: bool = None,
) -> dict:
) -> t.Dict[str, t.Any]:
"""
:param type: 수신할 시세 타입 (현재가: `ticker`, 체결: `trade`, 호가: `orderbook`)
:type type: str
Expand Down Expand Up @@ -151,9 +151,9 @@ def generate_type_field(

@staticmethod
def generate_payload(
type_fields: Union[List[dict]],
ticket: str = None,
format: str = 'DEFAULT'
type_fields: t.List[t.Dict[str, t.Any]],
ticket : str = None,
format : str = "DEFAULT"
) -> str:
"""
:param type_fields: Type Fields
Expand All @@ -169,13 +169,13 @@ def generate_payload(
payload = []

ticket = ticket if ticket else str(uuid.uuid4())
payload.append({"ticket": ticket})
payload.append( { "ticket": ticket } )

payload.extend(type_fields)

fmt = format.upper()
fmt = fmt if fmt in UpbitWebSocket.FIELD_FORMATS else "DEFAULT"
payload.append({"format": fmt})
payload.append( { "format": fmt } )

return json.dumps(payload)

Expand Down

0 comments on commit 13b7c93

Please sign in to comment.