Skip to content

Commit 3583387

Browse files
authored
Merge pull request #4 from uJhin/1.1.7
Update Version 1.1.7.4
2 parents 33dbdca + 4bad9cf commit 3583387

File tree

5 files changed

+93
-44
lines changed

5 files changed

+93
-44
lines changed

setup.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
from setuptools import setup
33
from setuptools import find_packages
44

5-
import upbit
5+
from upbit import pkginfo
66

77

8-
version = upbit.__version__
98
with open('README.rst') as readme:
109
long_description = readme.read()
1110

1211

1312
setup(
14-
name = 'upbit_client',
15-
version = version,
13+
name = pkginfo.PACKAGE_NAME,
14+
version = pkginfo.CURRENT_VERSION,
1615
packages = find_packages(),
1716
install_requires = [
1817
'bravado>=11.0.2',
@@ -25,12 +24,20 @@
2524
]
2625
},
2726
python_requires = '>=3.8',
27+
classifiers = [
28+
'Programming Language :: Python :: 3.8',
29+
'Programming Language :: Python :: 3.9'
30+
],
2831
keywords = [
2932
'Upbit',
3033
'upbit',
3134
'upbit-client',
3235
'Upbit-Client',
33-
'Upbit_client'
36+
'Upbit_client',
37+
'Upbit-api-connector',
38+
'upbit-api-connector',
39+
'Upbit_api_connector',
40+
'upbit_api_connector'
3441
],
3542
url = 'https://github.com/uJhin/upbit-client',
3643
download_url = 'https://github.com/uJhin/upbit-client/releases',

upbit/__init__.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11

2-
import logging
2+
from . import pkginfo
33

4-
from .utils import Version
54

6-
7-
__all__ = ['client', 'websocket']
8-
__module_name__ = 'upbit-client'
9-
10-
__open_api_version__ = '1.1.7'
11-
__version__ = __open_api_version__+'.3'
12-
__released_version__ = Version.get_versions(__module_name__)
13-
__latest_version__ = __released_version__[0]
14-
15-
16-
if __latest_version__ != __version__:
17-
logging.basicConfig(format="[%(levelname)s] %(message)s")
18-
logging.warning(
19-
f"{__module_name__} is currently a newer version: "
20-
f"{__latest_version__}\n"
21-
f"Please update to the latest version using the pip command: "
22-
f"`pip install --upgrade {__module_name__}`"
23-
)
5+
__all__ = ['client', 'websocket']
6+
__name__ = pkginfo.PACKAGE_NAME
7+
__version__ = pkginfo.CURRENT_VERSION

upbit/pkginfo.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
[Upbit Client]
3+
4+
Please read the official Upbit Client document.
5+
Documents: https://ujhin.github.io/upbit-client-docs/
6+
7+
- Upbit OPEN API Version: 1.1.7
8+
- Author: ujhin
9+
10+
- GitHub: https://github.com/uJhin
11+
- Official OPEN API Documents: https://docs.upbit.com
12+
- Official Support Email: [email protected]
13+
"""
14+
15+
import logging
16+
import requests
17+
18+
from distutils.version import LooseVersion
19+
20+
21+
def _get_versions(package_name):
22+
url = f"https://pypi.org/pypi/{package_name}/json"
23+
resp = requests.get(url)
24+
data = resp.json()
25+
versions = data["releases"].keys()
26+
return sorted(versions, key=LooseVersion, reverse=True)
27+
28+
29+
PACKAGE_NAME = 'upbit-client'
30+
31+
OPEN_API_VERSION = '1.1.7'
32+
CURRENT_VERSION = OPEN_API_VERSION+'.4'
33+
34+
RELEASED_VERSION = _get_versions(PACKAGE_NAME)
35+
LATEST_VERSION = RELEASED_VERSION[0]
36+
37+
38+
if LATEST_VERSION != CURRENT_VERSION:
39+
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+
""")

upbit/utils.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11

2-
import requests
3-
4-
from distutils.version import LooseVersion
52
from typing import Union
63

74

@@ -37,17 +34,6 @@ def future_extraction(http_future) -> dict:
3734
}
3835

3936

40-
class Version:
41-
42-
@staticmethod
43-
def get_versions(package_name):
44-
url = f"https://pypi.org/pypi/{package_name}/json"
45-
resp = requests.get(url)
46-
data = resp.json()
47-
versions = data["releases"].keys()
48-
return sorted(versions, key=LooseVersion, reverse=True)
49-
50-
5137
class Validator:
5238

5339
@staticmethod

upbit/websocket.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ class UpbitWebSocket:
2626
def __init__(
2727
self,
2828
uri: Union[str] = None,
29-
ping_inverval: Union[int, float] = None,
29+
ping_interval: Union[int, float] = None,
3030
ping_timeout: Union[int, float] = None
3131
):
32+
3233
self.__uri = uri if uri else WEBSOCKET_URI
33-
self.__conn = websockets.connect(
34-
uri=self.URI,
35-
ping_interval=ping_inverval,
34+
self.__conn = None
35+
self.connect(
36+
ping_interval=ping_interval,
3637
ping_timeout=ping_timeout
3738
)
3839

@@ -47,16 +48,35 @@ def URI(self, uri):
4748
@property
4849
def Connection(self):
4950
return self.__conn
50-
51+
5152
@Connection.setter
5253
def Connection(self, conn):
5354
self.__conn = conn
5455

56+
def connect(
57+
self,
58+
ping_interval: Union[int, float] = None,
59+
ping_timeout: Union[int, float] = None
60+
):
61+
self.Connection = websockets.connect(
62+
uri=self.URI,
63+
ping_interval=ping_interval,
64+
ping_timeout=ping_timeout
65+
)
66+
5567
@staticmethod
5668
def generate_orderbook_codes(
5769
currencies: Union[List[str]],
5870
counts: Union[List[int]] = None
5971
) -> List[str]:
72+
"""
73+
:param currencies: 수신할 `orderbook` field 마켓 코드 리스트
74+
:type currencies: list[str, ...]
75+
76+
:param counts: 각 마켓 코드 리스트의 index에 해당하는 수신할 `orderbook` 갯수
77+
:type counts: list[int, ...]
78+
"""
79+
6080
codes = [
6181
f"{currency}.{count}"
6282
for currency, count
@@ -84,6 +104,7 @@ def generate_type_field(
84104
:param isOnlyRealtime: 실시간 시세만 제공 여부
85105
:type isOnlyRealtime: bool
86106
"""
107+
87108
field = {}
88109

89110
if type in ['ticker', 'trade', 'orderbook']:
@@ -117,6 +138,7 @@ def generate_payload(
117138
:param ticket: 식별값
118139
:type ticket: str
119140
"""
141+
120142
payload = []
121143

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

136158
async def __aexit__(self, exc_type, exc_value, traceback) -> None:
137159
await self.Connection.__aexit__(exc_type, exc_value, traceback)
160+
161+
def __str__(self):
162+
return self.__repr__()
163+
164+
def __repr__(self):
165+
return f"UpbitWebSocket({self.URI})"

0 commit comments

Comments
 (0)