Skip to content

Commit

Permalink
1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DogsTailFarmer committed Jun 29, 2023
1 parent ac59d9b commit d5f6c2e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 50 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a href="https://sonarcloud.io/summary/new_code?id=DogsTailFarmer_exchanges-wrapper" target="_blank"><img alt="sonarcloud" title="sonarcloud" src="https://sonarcloud.io/api/project_badges/measure?project=DogsTailFarmer_exchanges-wrapper&metric=alert_status"/></a>
<a href="https://pepy.tech/project/exchanges-wrapper" target="_blank"><img alt="Downloads" title="Downloads" src="https://pepy.tech/badge/exchanges-wrapper/month"/></a>
***
From 1.3.2 update exch_srv_cfg.toml (see CHANGELOG for details)
From 1.3.2 update exch_srv_cfg.toml (see [CHANGELOG](https://github.com/DogsTailFarmer/exchanges-wrapper/blob/master/CHANGELOG.md#added-for-new-features) for details)
***

## exchanges-wrapper vs binance.py
Expand Down Expand Up @@ -45,7 +45,7 @@ Served methods describes into ```example/exch_client.py```
- Passthrough logging
- WSS keepalive
- Reuse session for new client sessions
- Utilize Websocket API (bidirectional) for the most commonly used methods (Binance ws-api/v3, )
- Utilizing Websocket API (bidirectional) for the most commonly used methods (Binance ws-api/v3, )

## Extra exchanges implementation features
- Binance REST API and WSS are accepted as basic, connection of other exchanges wrapped their API to Binance compatible
Expand Down
2 changes: 1 addition & 1 deletion exchanges_wrapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__contact__ = "https://github.com/DogsTailFarmer"
__email__ = "[email protected]"
__credits__ = ["https://github.com/DanyaSWorlD"]
__version__ = "1.3.2b4"
__version__ = "1.3.2"

from pathlib import Path
import shutil
Expand Down
74 changes: 28 additions & 46 deletions exchanges_wrapper/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,69 +33,52 @@ def truncate(f, n):


class Client:
def __init__(
self,
exchange,
sub_account,
test_net,
api_key,
api_secret,
endpoint_api_public,
endpoint_ws_public,
endpoint_api_auth,
endpoint_ws_auth,
ws_public_mbr,
passphrase,
master_email,
master_name,
two_fa,
endpoint_ws_api
):
self.exchange = exchange
self.sub_account = sub_account
self.test_net = test_net
self.api_key = api_key
self.api_secret = api_secret
self.passphrase = passphrase
self.endpoint_api_public = endpoint_api_public
self.endpoint_ws_public = endpoint_ws_public
self.endpoint_api_auth = endpoint_api_auth
self.endpoint_ws_auth = endpoint_ws_auth
self.endpoint_ws_api = endpoint_ws_api
self.ws_public_mbr = ws_public_mbr
self.master_email = master_email
self.master_name = master_name
self.two_fa = two_fa
def __init__(self, *acc):
self.exchange = acc[0]
self.sub_account = acc[1]
self.test_net = acc[2]
self.api_key = acc[3]
self.api_secret = acc[4]
self.passphrase = acc[10]
self.endpoint_api_public = acc[5]
self.endpoint_ws_public = acc[6]
self.endpoint_api_auth = acc[7]
self.endpoint_ws_auth = acc[8]
self.endpoint_ws_api = acc[14]
self.ws_public_mbr = acc[9]
self.master_email = acc[11]
self.master_name = acc[12]
self.two_fa = acc[13]
#
self.session = aiohttp.ClientSession()
client_init_params = {
'api_key': api_key,
'api_secret': api_secret,
'passphrase': passphrase,
'endpoint': endpoint_api_auth,
'api_key': self.api_key,
'api_secret': self.api_secret,
'passphrase': self.passphrase,
'endpoint': self.endpoint_api_auth,
'session': self.session,
'exchange': exchange,
'sub_account': sub_account,
'test_net': test_net
'exchange': self.exchange,
'sub_account': self.sub_account,
'test_net': self.test_net
}

self.user_wss_session = None
if exchange == 'binance':
if self.exchange == 'binance':
self.http = ClientBinance(**client_init_params)
self.user_wss_session = UserWSSession(
self.api_key,
self.api_secret,
self.session,
self.endpoint_ws_api
)
elif exchange == 'bitfinex':
elif self.exchange == 'bitfinex':
self.http = ClientBFX(**client_init_params)
elif exchange == 'huobi':
elif self.exchange == 'huobi':
self.http = ClientHBP(**client_init_params)
elif exchange == 'okx':
elif self.exchange == 'okx':
self.http = ClientOKX(**client_init_params)
else:
raise UserWarning(f"Exchange {exchange} not yet connected")
raise UserWarning(f"Exchange {self.exchange} not yet connected")
#
self.loaded = False
self.symbols = {}
Expand All @@ -112,7 +95,6 @@ def __init__(
self.hbp_main_uid = None
self.ledgers_id = []


async def load(self):
infos = await self.fetch_exchange_info()
if infos.get('serverTime'):
Expand Down
2 changes: 1 addition & 1 deletion exchanges_wrapper/web_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def _handle_messages(self, web_socket, symbol=None, ch_type=str()):
raise aiohttp.ClientOSError
# data handling
elif isinstance(msg_data, list) and len(msg_data) == 2 and msg_data[1] == 'hb':
pass
pass # heartbeat message
elif isinstance(msg_data, list):
if ch_type == 'book' and isinstance(msg_data[1][-1], list):
order_book = bfx.OrderBook(msg_data[1], symbol)
Expand Down

0 comments on commit d5f6c2e

Please sign in to comment.