ccxt 4.3.62__py2.py3-none-any.whl → 4.3.63__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. ccxt/__init__.py +2 -1
  2. ccxt/abstract/binance.py +5 -5
  3. ccxt/abstract/binancecoinm.py +5 -5
  4. ccxt/abstract/binanceus.py +5 -5
  5. ccxt/abstract/binanceusdm.py +5 -5
  6. ccxt/abstract/cryptocom.py +11 -0
  7. ccxt/abstract/woo.py +3 -0
  8. ccxt/ace.py +33 -15
  9. ccxt/async_support/__init__.py +2 -1
  10. ccxt/async_support/ace.py +33 -15
  11. ccxt/async_support/base/exchange.py +1 -1
  12. ccxt/async_support/binance.py +6 -9
  13. ccxt/async_support/bingx.py +451 -151
  14. ccxt/async_support/coinbaseinternational.py +1 -1
  15. ccxt/async_support/cryptocom.py +17 -2
  16. ccxt/async_support/mercado.py +5 -1
  17. ccxt/async_support/woo.py +296 -81
  18. ccxt/async_support/xt.py +3 -3
  19. ccxt/base/errors.py +8 -1
  20. ccxt/base/exchange.py +8 -2
  21. ccxt/binance.py +6 -9
  22. ccxt/bingx.py +451 -151
  23. ccxt/coinbaseinternational.py +1 -1
  24. ccxt/cryptocom.py +17 -2
  25. ccxt/mercado.py +5 -1
  26. ccxt/pro/__init__.py +1 -1
  27. ccxt/pro/binance.py +56 -35
  28. ccxt/pro/bitfinex2.py +6 -4
  29. ccxt/pro/bitget.py +5 -2
  30. ccxt/pro/bitvavo.py +1 -1
  31. ccxt/pro/bybit.py +41 -18
  32. ccxt/pro/cryptocom.py +7 -2
  33. ccxt/pro/gate.py +6 -3
  34. ccxt/pro/htx.py +5 -1
  35. ccxt/pro/independentreserve.py +6 -4
  36. ccxt/pro/kraken.py +79 -6
  37. ccxt/pro/okx.py +4 -4
  38. ccxt/pro/poloniexfutures.py +5 -2
  39. ccxt/pro/woofipro.py +1 -1
  40. ccxt/woo.py +296 -81
  41. ccxt/xt.py +3 -3
  42. {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/METADATA +4 -4
  43. {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/RECORD +46 -46
  44. {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/LICENSE.txt +0 -0
  45. {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/WHEEL +0 -0
  46. {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/top_level.txt +0 -0
ccxt/pro/kraken.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import ccxt.async_support
7
7
  from ccxt.async_support.base.ws.cache import ArrayCache, ArrayCacheBySymbolById, ArrayCacheByTimestamp
8
- from ccxt.base.types import Int, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
8
+ from ccxt.base.types import Balances, Int, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
9
9
  from ccxt.async_support.base.ws.client import Client
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
@@ -20,7 +20,7 @@ from ccxt.base.errors import OrderNotFound
20
20
  from ccxt.base.errors import NotSupported
21
21
  from ccxt.base.errors import RateLimitExceeded
22
22
  from ccxt.base.errors import ExchangeNotAvailable
23
- from ccxt.base.errors import InvalidNonce
23
+ from ccxt.base.errors import ChecksumError
24
24
  from ccxt.base.precise import Precise
25
25
 
26
26
 
@@ -30,7 +30,7 @@ class kraken(ccxt.async_support.kraken):
30
30
  return self.deep_extend(super(kraken, self).describe(), {
31
31
  'has': {
32
32
  'ws': True,
33
- 'watchBalance': False, # no such type of subscription 2021-01-05
33
+ 'watchBalance': True,
34
34
  'watchMyTrades': True,
35
35
  'watchOHLCV': True,
36
36
  'watchOrderBook': True,
@@ -53,6 +53,7 @@ class kraken(ccxt.async_support.kraken):
53
53
  'ws': {
54
54
  'public': 'wss://ws.kraken.com',
55
55
  'private': 'wss://ws-auth.kraken.com',
56
+ 'privateV2': 'wss://ws-auth.kraken.com/v2',
56
57
  'beta': 'wss://beta-ws.kraken.com',
57
58
  'beta-private': 'wss://beta-ws-auth.kraken.com',
58
59
  },
@@ -66,7 +67,9 @@ class kraken(ccxt.async_support.kraken):
66
67
  'OHLCVLimit': 1000,
67
68
  'ordersLimit': 1000,
68
69
  'symbolsByOrderId': {},
69
- 'checksum': True,
70
+ 'watchOrderBook': {
71
+ 'checksum': True,
72
+ },
70
73
  },
71
74
  'exceptions': {
72
75
  'ws': {
@@ -715,7 +718,7 @@ class kraken(ccxt.async_support.kraken):
715
718
  example = self.safe_value(b, 0)
716
719
  # don't remove self line or I will poop on your face
717
720
  orderbook.limit()
718
- checksum = self.safe_bool(self.options, 'checksum', True)
721
+ checksum = self.handle_option('watchOrderBook', 'checksum', True)
719
722
  if checksum:
720
723
  priceString = self.safe_string(example, 0)
721
724
  amountString = self.safe_string(example, 1)
@@ -734,7 +737,7 @@ class kraken(ccxt.async_support.kraken):
734
737
  payload = ''.join(payloadArray)
735
738
  localChecksum = self.crc32(payload, False)
736
739
  if localChecksum != c:
737
- error = InvalidNonce(self.id + ' invalid checksum')
740
+ error = ChecksumError(self.id + ' ' + self.orderbook_checksum_message(symbol))
738
741
  del client.subscriptions[messageHash]
739
742
  del self.orderbooks[symbol]
740
743
  client.reject(error, messageHash)
@@ -1247,6 +1250,68 @@ class kraken(ccxt.async_support.kraken):
1247
1250
  url = self.urls['api']['ws']['public']
1248
1251
  return await self.watch_multiple(url, messageHashes, self.deep_extend(request, params), messageHashes, subscriptionArgs)
1249
1252
 
1253
+ async def watch_balance(self, params={}) -> Balances:
1254
+ """
1255
+ watch balance and get the amount of funds available for trading or funds locked in orders
1256
+ :see: https://docs.kraken.com/api/docs/websocket-v2/balances
1257
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1258
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1259
+ """
1260
+ await self.load_markets()
1261
+ token = await self.authenticate()
1262
+ messageHash = 'balances'
1263
+ url = self.urls['api']['ws']['privateV2']
1264
+ requestId = self.request_id()
1265
+ subscribe: dict = {
1266
+ 'method': 'subscribe',
1267
+ 'req_id': requestId,
1268
+ 'params': {
1269
+ 'channel': 'balances',
1270
+ 'token': token,
1271
+ },
1272
+ }
1273
+ request = self.deep_extend(subscribe, params)
1274
+ return await self.watch(url, messageHash, request, messageHash)
1275
+
1276
+ def handle_balance(self, client: Client, message):
1277
+ #
1278
+ # {
1279
+ # "channel": "balances",
1280
+ # "data": [
1281
+ # {
1282
+ # "asset": "BTC",
1283
+ # "asset_class": "currency",
1284
+ # "balance": 1.2,
1285
+ # "wallets": [
1286
+ # {
1287
+ # "type": "spot",
1288
+ # "id": "main",
1289
+ # "balance": 1.2
1290
+ # }
1291
+ # ]
1292
+ # }
1293
+ # ],
1294
+ # "type": "snapshot",
1295
+ # "sequence": 1
1296
+ # }
1297
+ #
1298
+ data = self.safe_list(message, 'data', [])
1299
+ result: dict = {'info': message}
1300
+ for i in range(0, len(data)):
1301
+ currencyId = self.safe_string(data[i], 'asset')
1302
+ code = self.safe_currency_code(currencyId)
1303
+ account = self.account()
1304
+ eq = self.safe_string(data[i], 'balance')
1305
+ account['total'] = eq
1306
+ result[code] = account
1307
+ type = 'spot'
1308
+ balance = self.safe_balance(result)
1309
+ oldBalance = self.safe_value(self.balance, type, {})
1310
+ newBalance = self.deep_extend(oldBalance, balance)
1311
+ self.balance[type] = self.safe_balance(newBalance)
1312
+ channel = self.safe_string(message, 'channel')
1313
+ client.resolve(self.balance[type], channel)
1314
+
1250
1315
  def get_message_hash(self, unifiedElementName: str, subChannelName: Str = None, symbol: Str = None):
1251
1316
  # unifiedElementName can be : orderbook, trade, ticker, bidask ...
1252
1317
  # subChannelName only applies to channel that needs specific variation(i.e. depth_50, depth_100..) to be selected
@@ -1340,6 +1405,14 @@ class kraken(ccxt.async_support.kraken):
1340
1405
  if method is not None:
1341
1406
  method(client, message, subscription)
1342
1407
  else:
1408
+ channel = self.safe_string(message, 'channel')
1409
+ if channel is not None:
1410
+ methods: dict = {
1411
+ 'balances': self.handle_balance,
1412
+ }
1413
+ method = self.safe_value(methods, channel)
1414
+ if method is not None:
1415
+ method(client, message)
1343
1416
  if self.handle_error_message(client, message):
1344
1417
  event = self.safe_string(message, 'event')
1345
1418
  methods: dict = {
ccxt/pro/okx.py CHANGED
@@ -13,7 +13,7 @@ from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
14
14
  from ccxt.base.errors import ArgumentsRequired
15
15
  from ccxt.base.errors import BadRequest
16
- from ccxt.base.errors import InvalidNonce
16
+ from ccxt.base.errors import ChecksumError
17
17
 
18
18
 
19
19
  class okx(ccxt.async_support.okx):
@@ -56,6 +56,7 @@ class okx(ccxt.async_support.okx):
56
56
  },
57
57
  'options': {
58
58
  'watchOrderBook': {
59
+ 'checksum': True,
59
60
  #
60
61
  # bbo-tbt
61
62
  # 1. Newly added channel that sends tick-by-tick Level 1 data
@@ -103,7 +104,6 @@ class okx(ccxt.async_support.okx):
103
104
  'ws': {
104
105
  # 'inflate': True,
105
106
  },
106
- 'checksum': True,
107
107
  },
108
108
  'streaming': {
109
109
  # okex does not support built-in ws protocol-level ping-pong
@@ -861,7 +861,7 @@ class okx(ccxt.async_support.okx):
861
861
  self.handle_deltas(storedBids, bids)
862
862
  marketId = self.safe_string(message, 'instId')
863
863
  symbol = self.safe_symbol(marketId)
864
- checksum = self.safe_bool(self.options, 'checksum', True)
864
+ checksum = self.handle_option('watchOrderBook', 'checksum', True)
865
865
  if checksum:
866
866
  asksLength = len(storedAsks)
867
867
  bidsLength = len(storedBids)
@@ -877,7 +877,7 @@ class okx(ccxt.async_support.okx):
877
877
  responseChecksum = self.safe_integer(message, 'checksum')
878
878
  localChecksum = self.crc32(payload, True)
879
879
  if responseChecksum != localChecksum:
880
- error = InvalidNonce(self.id + ' invalid checksum')
880
+ error = ChecksumError(self.id + ' ' + self.orderbook_checksum_message(symbol))
881
881
  del client.subscriptions[messageHash]
882
882
  del self.orderbooks[symbol]
883
883
  client.reject(error, messageHash)
@@ -10,7 +10,7 @@ from ccxt.async_support.base.ws.client import Client
10
10
  from typing import List
11
11
  from ccxt.base.errors import AuthenticationError
12
12
  from ccxt.base.errors import BadRequest
13
- from ccxt.base.errors import InvalidNonce
13
+ from ccxt.base.errors import ChecksumError
14
14
 
15
15
 
16
16
  class poloniexfutures(ccxt.async_support.poloniexfutures):
@@ -57,6 +57,7 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
57
57
  'method': '/contractMarket/level2', # can also be '/contractMarket/level3v2'
58
58
  'snapshotDelay': 5,
59
59
  'snapshotMaxRetries': 3,
60
+ 'checksum': True,
60
61
  },
61
62
  'streamLimit': 5, # called tunnels by poloniexfutures docs
62
63
  'streamBySubscriptionsHash': {},
@@ -822,7 +823,9 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
822
823
  if nonce > sequence:
823
824
  return
824
825
  if nonce != lastSequence:
825
- raise InvalidNonce(self.id + ' watchOrderBook received an out-of-order nonce')
826
+ checksum = self.handle_option('watchOrderBook', 'checksum', True)
827
+ if checksum:
828
+ raise ChecksumError(self.id + ' ' + self.orderbook_checksum_message(''))
826
829
  changes = self.safe_list(delta, 'changes')
827
830
  for i in range(0, len(changes)):
828
831
  change = changes[i]
ccxt/pro/woofipro.py CHANGED
@@ -363,7 +363,7 @@ class woofipro(ccxt.async_support.woofipro):
363
363
  :param int [since]: the earliest time in ms to fetch trades for
364
364
  :param int [limit]: the maximum number of trade structures to retrieve
365
365
  :param dict [params]: extra parameters specific to the exchange API endpoint
366
- :returns dict[]: a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
366
+ :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
367
367
  """
368
368
  await self.load_markets()
369
369
  market = self.market(symbol)