Skip to content

Commit 95d4a3e

Browse files
committed
clean repo
1 parent e41f06b commit 95d4a3e

23 files changed

+88
-290
lines changed

.gitignore

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1-
__pycache__/*
2-
*/__pycache__/*
3-
.vscode/*
4-
build/*
5-
cryptomarket_api.egg-info/*
6-
dist/*
7-
p-env/*
1+
.vscode/
2+
p-env/
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST

cryptomarket/websockets/account_client.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ def __init__(
2525
api_key,
2626
api_secret,
2727
subscription_keys={
28+
# transaction
29+
"subscribeTransactions":"transaction",
30+
"unsubscribeTransactions":"transaction",
31+
"updateTransaction":"transaction",
32+
# balance
2833
"unsubscribeBalance":"balance",
2934
"subscribeBalance":"balance",
3035
"balance":"balance",
31-
"subscribeTransactions":"transaction",
32-
"subscribeTransactions":"transaction",
33-
"updateTransaction":"transaction"
3436
},
3537
on_connect=on_connect,
3638
on_error=on_error,
@@ -211,22 +213,24 @@ def subscribe_to_balance(self, callback: callable, result_callback: callable=Non
211213
212214
https://api.exchange.cryptomkt.com/#subscription-to-the-balance
213215
214-
:param callback: A callable to call with each update of the result data. It takes one argument, the balance feed.
216+
:param callback: A callable to call with each update of the result data. It takes one argument, the balance feed, a list of balances.
215217
:param result_callback: A callable to call with the subscription result. It takes two arguments, err and result. err is None for successful calls, result is None for calls with error: callback(err, result).
216218
217-
:returns: A transaction of the account as feed for the callback.
219+
:returns: A list of balances of the account as feed for the callback.
218220
219221
.. code-block:: python
220-
{
221-
"id": "76b70d1c-3dd7-423e-976e-902e516aae0e",
222-
"index": 7173627250,
223-
"type": "bankToExchange",
224-
"status": "success",
225-
"currency": "BTG",
226-
"amount": "0.00001000",
227-
"createdAt": "2021-01-31T08:19:33.892Z",
228-
"updatedAt": "2021-01-31T08:19:33.967Z"
229-
}
222+
[
223+
{
224+
"currency": "BTC",
225+
"available": "0.00005821",
226+
"reserved": "0"
227+
},
228+
{
229+
"currency": "DOGE",
230+
"available": "11",
231+
"reserved": "0"
232+
}
233+
]
230234
"""
231235
self.send_subscription(method='subscribeBalance', callback=callback, params={}, result_callback=result_callback)
232236

cryptomarket/websockets/client_base.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from cryptomarket.exceptions import CryptomarketAPIException
44
from cryptomarket.websockets.callback_cache import CallbackCache
55
from cryptomarket.websockets.manager import WebsocketManager
6-
from types import Dict
6+
from typing import Dict
77

88

99
class ClientBase:
@@ -76,7 +76,13 @@ def handle(self, message):
7676
self.handle_response(message)
7777

7878
def handle_notification(self, message):
79-
callback = self.callback_cache.get_subscription_callback("subscription")
79+
method = message['method']
80+
if 'params' not in message:
81+
return
82+
params = message['params']
83+
key = self.build_key(method, params)
84+
85+
callback = self.callback_cache.get_subscription_callback(key)
8086
if callback is not None:
8187
if type(message["params"])==list:
8288
for feed in message["params"]:
@@ -101,4 +107,4 @@ def handle_response(self, response):
101107
def build_key(self, method, params):
102108
if not method in self.subscription_keys:
103109
return "subscription"
104-
return self.subscription_map[method]
110+
return self.subscription_keys[method]

cryptomarket/websockets/trading_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(
2525
api_key,
2626
api_secret,
2727
subscription_keys={
28+
# reports
2829
"subscribeReports":"reports",
2930
'activeOrders':'reports',
3031
'report':'reports',

cryptomarket_sdk.egg-info/PKG-INFO

Lines changed: 0 additions & 224 deletions
This file was deleted.

cryptomarket_sdk.egg-info/SOURCES.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

cryptomarket_sdk.egg-info/dependency_links.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

cryptomarket_sdk.egg-info/top_level.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests==2.22.0
2+
websocket-client==1.1.0

0 commit comments

Comments
 (0)