Skip to content

Commit

Permalink
Merge branch 'feature/listing' into 'main'
Browse files Browse the repository at this point in the history
fix setup.py

See merge request whitebit_exchange/python-sdk!2
  • Loading branch information
whitebit-robot committed Apr 20, 2023
2 parents fa31087 + 3a69769 commit 5d3d321
Show file tree
Hide file tree
Showing 20 changed files with 241 additions and 11 deletions.
Empty file added HISTORY.txt
Empty file.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2023 UAB Clear White Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
## A Python SDK for [whitebit](https://www.whitebit.com)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

For best compatibility, please use Python >= 1.18

Please read [whitebit API document](https://whitebit-exchange.github.io/api-docs/) before continuing.

## API List

- [Private API](https://whitebit-exchange.github.io/api-docs/docs/category/private)
- [Public API](https://whitebit-exchange.github.io/api-docs/docs/category/public)
- [Private API](https://whitebit-exchange.github.io/api-docs/private/http-trade-v4/)
- [Public API](https://whitebit-exchange.github.io/api-docs/public/http-v4/)
- [Private WS](https://whitebit-exchange.github.io/api-docs/private/websocket/)
- [Public WS](https://whitebit-exchange.github.io/api-docs/public/websocket/)

Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python_version == 3.10.*
requests==2.28.1
websockets==10.0.0
websockets==10.4
responses==0.23.1
urllib3==1.26.15
193 changes: 193 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#!/usr/bin/python3
# -*- coding:utf-8 -*-
# run via python3 setup.py upload

import io, os, sys
from shutil import rmtree

from setuptools import find_packages, setup, Command

# Package meta-data.
NAME = 'python-whitebit-sdk'
DESCRIPTION = 'Clients and methods to interact with the Whitebit exchange.'
URL = 'https://github.com/whitebit-exchange/python-sdk'
EMAIL = 'support@whitebit.com'
AUTHOR = 'UAB Clear White Technologies'
REQUIRES_PYTHON = '>=3.10.0'
VERSION = None

# What packages are required for this module to be executed?
REQUIRED = [
'websockets>=10.4.0', 'asyncio>=3.4', 'requests>=2.28.1', 'responses>=0.23.1',
'urllib3==1.26.15'
]


# What packages are optional?
EXTRAS = {
'testing': ['pytest', 'tqdm']
}

here = os.path.abspath(os.path.dirname(__file__))

# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
try:
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f'\n{f.read()}'
except FileNotFoundError:
long_description = DESCRIPTION

about = {}
if not VERSION:
project_slug = 'whitebit'
with open(os.path.join(here, project_slug, '__version__.py')) as f:
exec(f.read(), about)
else:
raise ValueError('Version not found!')

class UploadCommand(Command):
'''Support setup.py upload.'''

description = 'Build and publish the package.'
user_options = []

@staticmethod
def status(s):
print(f'\033[1m{s}\033[0m')

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
try:
self.status('Removing previous builds…')
rmtree(os.path.join(here, 'dist'))
except OSError:
pass

self.status('Building Source and Wheel (universal) distribution…')
os.system(f'{sys.executable} setup.py sdist bdist_wheel --universal')

self.status('Testing the build using flake8')
if os.system('flake8 . --select=E9,F63,F7,F82 --show-source --statistics') != 0:
self.status('Testing failed, build has some errors in it!')
exit(1)

self.status('Uploading the package to PyPI via Twine…')
os.system('twine upload dist/*')

# self.status('Pushing git tags…')
# os.system(f'git tag v{about['__version__']}')
# os.system('git push --tags')

sys.exit()

class TestUploadCommand(Command):
'''Support setup.py test upload.'''

description = 'Build and test publishing the package.'
user_options = []

@staticmethod
def status(s):
print(f'\033[1m{s}\033[0m')

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
try:
self.status('Removing previous builds…')
rmtree(os.path.join(here, 'dist'))
except OSError:
pass

self.status('Building Source and Wheel (universal) distribution…')
os.system(f'{sys.executable} setup.py sdist bdist_wheel --universal')

self.status('Testing the build using flake8')
if os.system('flake8 . --select=E9,F63,F7,F82 --show-source --statistics') != 0:
self.status('Testing failed, build has some errors in it!')
sys.exit(1)

self.status('Uploading the package to test PyPI via Twine…')
os.system('twine upload -r testpypi dist/*')#--repository-url https://test.pypi.org/legacy/ dist/*')

sys.exit()

class TestCommand(Command):

description = 'Build and test the package.'
user_options = []

@staticmethod
def status(s):
print(f'\033[1m{s}\033[0m')

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
try:
self.status('Removing previous builds…')
rmtree(os.path.join(here, 'dist'))
except OSError:
pass

self.status('Building Source and Wheel (universal) distribution…')
os.system(f'{sys.executable} setup.py sdist bdist_wheel --universal')

self.status('Testing the build')
if os.system('flake8 . --select=E9,F63,F7,F82 --show-source --statistics') != 0: exit(1)
print('Success')
sys.exit()

setup(
name=NAME,
version=about['__version__'],
description=DESCRIPTION,
long_description=long_description,
long_description_content_type='text/markdown',
author=AUTHOR,
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(exclude=['tests', '*.tests', '*.tests.*', 'tests.*', '*.env*']),
# If your package is a single module, use this instead of 'packages':
# py_modules=['mypackage'],

# entry_points={
# 'console_scripts': ['mycli=mymodule:cli'],
# },
install_requires=REQUIRED,
extras_require=EXTRAS,
include_package_data=True,
license='MIT',
classifiers=[
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3.10',
'Development Status :: 5 - Production/Stable',
'Framework :: AsyncIO',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Unix',
'Operating System :: Microsoft :: Windows'
],
cmdclass={
'upload': UploadCommand,
'test': TestCommand,
'testupload': TestUploadCommand,
},
)
4 changes: 4 additions & 0 deletions whitebit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .trade import *
from .main import *
from .collateral import *
from .stream import *
3 changes: 3 additions & 0 deletions whitebit/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'''This is the Whitebit main module version'''
VERSION = (1, 0, 5)
__version__ = '.'.join(map(str, VERSION))
3 changes: 3 additions & 0 deletions whitebit/collateral/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .account import *
from .market import *
from .order import *
1 change: 1 addition & 0 deletions whitebit/collateral/account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .account import *
1 change: 1 addition & 0 deletions whitebit/collateral/market/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .market import *
1 change: 1 addition & 0 deletions whitebit/collateral/order/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .order import *
1 change: 1 addition & 0 deletions whitebit/main/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .account import *
1 change: 1 addition & 0 deletions whitebit/main/account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .account import MainAccountClient
1 change: 1 addition & 0 deletions whitebit/stream/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .ws import ConnectWebsocket
3 changes: 1 addition & 2 deletions whitebit/stream/ws.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'''Module that implements the kraken Spot websocket clients'''
import logging
import json
import time
Expand Down Expand Up @@ -256,7 +255,7 @@ async def on_message(self, msg: dict):
await self.__callback(msg)
else:
logging.warning('Received event but no callback is defined')
print(msg)
logging.info(msg)

async def __subscribe(self, subscription: dict) -> None:
self._conn.append_subscription(subscription)
Expand Down
3 changes: 3 additions & 0 deletions whitebit/trade/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from whitebit.trade.market.market import TradeMarketClient
from whitebit.trade.account.account import TradeAccountClient
from whitebit.trade.order.order import TradeOrderClient
1 change: 1 addition & 0 deletions whitebit/trade/account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .account import TradeAccountClient
1 change: 1 addition & 0 deletions whitebit/trade/market/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .market import TradeMarketClient
3 changes: 0 additions & 3 deletions whitebit/trade/market/market.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'''Module that implements the Kraken Spot market client'''
import whitebit
from whitebit.client import Whitebit

Expand All @@ -19,8 +18,6 @@ class TradeMarketClient(Whitebit):
__TRADE_HISTORY_URL = "/api/v1/public/history"
__ASSETS_URL = "/api/v4/public/assets"

'''Class that implements the Kraken Spot market client'''

def __init__(self, api_key: str = '', api_secret: str = ''):
super().__init__(api_key, api_secret)

Expand Down
1 change: 1 addition & 0 deletions whitebit/trade/order/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .order import TradeOrderClient

0 comments on commit 5d3d321

Please sign in to comment.