Skip to content

Commit

Permalink
Merge pull request #4 from uJhin/1.1.7
Browse files Browse the repository at this point in the history
Update Version 1.1.7.4
  • Loading branch information
uJhin authored Feb 25, 2021
2 parents 33dbdca + 4bad9cf commit 3583387
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 44 deletions.
17 changes: 12 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
from setuptools import setup
from setuptools import find_packages

import upbit
from upbit import pkginfo


version = upbit.__version__
with open('README.rst') as readme:
long_description = readme.read()


setup(
name = 'upbit_client',
version = version,
name = pkginfo.PACKAGE_NAME,
version = pkginfo.CURRENT_VERSION,
packages = find_packages(),
install_requires = [
'bravado>=11.0.2',
Expand All @@ -25,12 +24,20 @@
]
},
python_requires = '>=3.8',
classifiers = [
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
keywords = [
'Upbit',
'upbit',
'upbit-client',
'Upbit-Client',
'Upbit_client'
'Upbit_client',
'Upbit-api-connector',
'upbit-api-connector',
'Upbit_api_connector',
'upbit_api_connector'
],
url = 'https://github.com/uJhin/upbit-client',
download_url = 'https://github.com/uJhin/upbit-client/releases',
Expand Down
24 changes: 4 additions & 20 deletions upbit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@

import logging
from . import pkginfo

from .utils import Version


__all__ = ['client', 'websocket']
__module_name__ = 'upbit-client'

__open_api_version__ = '1.1.7'
__version__ = __open_api_version__+'.3'
__released_version__ = Version.get_versions(__module_name__)
__latest_version__ = __released_version__[0]


if __latest_version__ != __version__:
logging.basicConfig(format="[%(levelname)s] %(message)s")
logging.warning(
f"{__module_name__} is currently a newer version: "
f"{__latest_version__}\n"
f"Please update to the latest version using the pip command: "
f"`pip install --upgrade {__module_name__}`"
)
__all__ = ['client', 'websocket']
__name__ = pkginfo.PACKAGE_NAME
__version__ = pkginfo.CURRENT_VERSION
44 changes: 44 additions & 0 deletions upbit/pkginfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
[Upbit Client]
Please read the official Upbit Client document.
Documents: https://ujhin.github.io/upbit-client-docs/
- Upbit OPEN API Version: 1.1.7
- Author: ujhin
- Email: [email protected]
- GitHub: https://github.com/uJhin
- Official OPEN API Documents: https://docs.upbit.com
- Official Support Email: [email protected]
"""

import logging
import requests

from distutils.version import LooseVersion


def _get_versions(package_name):
url = f"https://pypi.org/pypi/{package_name}/json"
resp = requests.get(url)
data = resp.json()
versions = data["releases"].keys()
return sorted(versions, key=LooseVersion, reverse=True)


PACKAGE_NAME = 'upbit-client'

OPEN_API_VERSION = '1.1.7'
CURRENT_VERSION = OPEN_API_VERSION+'.4'

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}`
""")
14 changes: 0 additions & 14 deletions upbit/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

import requests

from distutils.version import LooseVersion
from typing import Union


Expand Down Expand Up @@ -37,17 +34,6 @@ def future_extraction(http_future) -> dict:
}


class Version:

@staticmethod
def get_versions(package_name):
url = f"https://pypi.org/pypi/{package_name}/json"
resp = requests.get(url)
data = resp.json()
versions = data["releases"].keys()
return sorted(versions, key=LooseVersion, reverse=True)


class Validator:

@staticmethod
Expand Down
38 changes: 33 additions & 5 deletions upbit/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ class UpbitWebSocket:
def __init__(
self,
uri: Union[str] = None,
ping_inverval: Union[int, float] = None,
ping_interval: Union[int, float] = None,
ping_timeout: Union[int, float] = None
):

self.__uri = uri if uri else WEBSOCKET_URI
self.__conn = websockets.connect(
uri=self.URI,
ping_interval=ping_inverval,
self.__conn = None
self.connect(
ping_interval=ping_interval,
ping_timeout=ping_timeout
)

Expand All @@ -47,16 +48,35 @@ def URI(self, uri):
@property
def Connection(self):
return self.__conn

@Connection.setter
def Connection(self, conn):
self.__conn = conn

def connect(
self,
ping_interval: Union[int, float] = None,
ping_timeout: Union[int, float] = None
):
self.Connection = websockets.connect(
uri=self.URI,
ping_interval=ping_interval,
ping_timeout=ping_timeout
)

@staticmethod
def generate_orderbook_codes(
currencies: Union[List[str]],
counts: Union[List[int]] = None
) -> List[str]:
"""
:param currencies: 수신할 `orderbook` field 마켓 코드 리스트
:type currencies: list[str, ...]
:param counts: 각 마켓 코드 리스트의 index에 해당하는 수신할 `orderbook` 갯수
:type counts: list[int, ...]
"""

codes = [
f"{currency}.{count}"
for currency, count
Expand Down Expand Up @@ -84,6 +104,7 @@ def generate_type_field(
:param isOnlyRealtime: 실시간 시세만 제공 여부
:type isOnlyRealtime: bool
"""

field = {}

if type in ['ticker', 'trade', 'orderbook']:
Expand Down Expand Up @@ -117,6 +138,7 @@ def generate_payload(
:param ticket: 식별값
:type ticket: str
"""

payload = []

ticket = ticket if ticket else str(uuid.uuid4())
Expand All @@ -135,3 +157,9 @@ async def __aenter__(self) -> websockets.client.WebSocketClientProtocol:

async def __aexit__(self, exc_type, exc_value, traceback) -> None:
await self.Connection.__aexit__(exc_type, exc_value, traceback)

def __str__(self):
return self.__repr__()

def __repr__(self):
return f"UpbitWebSocket({self.URI})"

0 comments on commit 3583387

Please sign in to comment.