ccxt 4.2.31__py2.py3-none-any.whl → 4.2.34__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (242) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/ace.py +4 -3
  3. ccxt/alpaca.py +1 -1
  4. ccxt/ascendex.py +6 -6
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/ace.py +4 -3
  7. ccxt/async_support/alpaca.py +1 -1
  8. ccxt/async_support/ascendex.py +6 -6
  9. ccxt/async_support/base/exchange.py +62 -39
  10. ccxt/async_support/bigone.py +25 -5
  11. ccxt/async_support/binance.py +16 -15
  12. ccxt/async_support/bingx.py +10 -9
  13. ccxt/async_support/bit2c.py +13 -1
  14. ccxt/async_support/bitbank.py +2 -2
  15. ccxt/async_support/bitbns.py +1 -1
  16. ccxt/async_support/bitfinex.py +5 -5
  17. ccxt/async_support/bitfinex2.py +6 -6
  18. ccxt/async_support/bitflyer.py +5 -5
  19. ccxt/async_support/bitforex.py +1 -1
  20. ccxt/async_support/bitget.py +11 -11
  21. ccxt/async_support/bithumb.py +2 -2
  22. ccxt/async_support/bitmart.py +9 -9
  23. ccxt/async_support/bitmex.py +3 -3
  24. ccxt/async_support/bitopro.py +2 -2
  25. ccxt/async_support/bitrue.py +8 -8
  26. ccxt/async_support/bitso.py +4 -4
  27. ccxt/async_support/bitstamp.py +2 -2
  28. ccxt/async_support/bitteam.py +1 -1
  29. ccxt/async_support/bitvavo.py +3 -3
  30. ccxt/async_support/bl3p.py +1 -1
  31. ccxt/async_support/blockchaincom.py +3 -3
  32. ccxt/async_support/btcalpha.py +1 -1
  33. ccxt/async_support/btcbox.py +1 -1
  34. ccxt/async_support/btcmarkets.py +2 -2
  35. ccxt/async_support/btcturk.py +1 -1
  36. ccxt/async_support/bybit.py +9 -9
  37. ccxt/async_support/cex.py +1 -1
  38. ccxt/async_support/coinbase.py +6 -6
  39. ccxt/async_support/coinbasepro.py +2 -2
  40. ccxt/async_support/coincheck.py +1 -1
  41. ccxt/async_support/coinex.py +9 -9
  42. ccxt/async_support/coinlist.py +4 -4
  43. ccxt/async_support/coinmate.py +2 -2
  44. ccxt/async_support/coinmetro.py +2 -2
  45. ccxt/async_support/coinone.py +1 -1
  46. ccxt/async_support/coinsph.py +2 -2
  47. ccxt/async_support/coinspot.py +1 -1
  48. ccxt/async_support/cryptocom.py +14 -14
  49. ccxt/async_support/currencycom.py +1 -1
  50. ccxt/async_support/delta.py +2 -2
  51. ccxt/async_support/deribit.py +4 -4
  52. ccxt/async_support/digifinex.py +6 -6
  53. ccxt/async_support/exmo.py +2 -2
  54. ccxt/async_support/gate.py +41 -37
  55. ccxt/async_support/gemini.py +2 -2
  56. ccxt/async_support/hitbtc.py +5 -5
  57. ccxt/async_support/hollaex.py +2 -2
  58. ccxt/async_support/htx.py +10 -10
  59. ccxt/async_support/huobijp.py +4 -4
  60. ccxt/async_support/idex.py +2 -2
  61. ccxt/async_support/independentreserve.py +2 -2
  62. ccxt/async_support/indodax.py +2 -2
  63. ccxt/async_support/kraken.py +42 -4
  64. ccxt/async_support/krakenfutures.py +5 -5
  65. ccxt/async_support/kucoin.py +8 -8
  66. ccxt/async_support/kucoinfutures.py +4 -4
  67. ccxt/async_support/kuna.py +2 -2
  68. ccxt/async_support/latoken.py +3 -3
  69. ccxt/async_support/lbank.py +2 -2
  70. ccxt/async_support/luno.py +1 -1
  71. ccxt/async_support/lykke.py +2 -2
  72. ccxt/async_support/mercado.py +2 -2
  73. ccxt/async_support/mexc.py +7 -6
  74. ccxt/async_support/ndax.py +2 -2
  75. ccxt/async_support/novadax.py +4 -4
  76. ccxt/async_support/oceanex.py +1 -1
  77. ccxt/async_support/okcoin.py +5 -5
  78. ccxt/async_support/okx.py +11 -10
  79. ccxt/async_support/onetrading.py +2 -2
  80. ccxt/async_support/p2b.py +1 -1
  81. ccxt/async_support/paymium.py +3 -3
  82. ccxt/async_support/phemex.py +13 -13
  83. ccxt/async_support/poloniex.py +4 -4
  84. ccxt/async_support/poloniexfutures.py +1 -1
  85. ccxt/async_support/probit.py +5 -5
  86. ccxt/async_support/timex.py +1 -1
  87. ccxt/async_support/tokocrypto.py +4 -4
  88. ccxt/async_support/upbit.py +2 -2
  89. ccxt/async_support/wavesexchange.py +4 -3
  90. ccxt/async_support/wazirx.py +1 -1
  91. ccxt/async_support/whitebit.py +5 -5
  92. ccxt/async_support/woo.py +6 -6
  93. ccxt/async_support/yobit.py +41 -2
  94. ccxt/async_support/zaif.py +2 -2
  95. ccxt/async_support/zonda.py +4 -4
  96. ccxt/base/exchange.py +67 -40
  97. ccxt/base/types.py +10 -0
  98. ccxt/bigone.py +25 -5
  99. ccxt/binance.py +16 -15
  100. ccxt/bingx.py +10 -9
  101. ccxt/bit2c.py +13 -1
  102. ccxt/bitbank.py +2 -2
  103. ccxt/bitbns.py +1 -1
  104. ccxt/bitfinex.py +5 -5
  105. ccxt/bitfinex2.py +6 -6
  106. ccxt/bitflyer.py +5 -5
  107. ccxt/bitforex.py +1 -1
  108. ccxt/bitget.py +11 -11
  109. ccxt/bithumb.py +2 -2
  110. ccxt/bitmart.py +9 -9
  111. ccxt/bitmex.py +3 -3
  112. ccxt/bitopro.py +2 -2
  113. ccxt/bitrue.py +8 -8
  114. ccxt/bitso.py +4 -4
  115. ccxt/bitstamp.py +2 -2
  116. ccxt/bitteam.py +1 -1
  117. ccxt/bitvavo.py +3 -3
  118. ccxt/bl3p.py +1 -1
  119. ccxt/blockchaincom.py +3 -3
  120. ccxt/btcalpha.py +1 -1
  121. ccxt/btcbox.py +1 -1
  122. ccxt/btcmarkets.py +2 -2
  123. ccxt/btcturk.py +1 -1
  124. ccxt/bybit.py +9 -9
  125. ccxt/cex.py +1 -1
  126. ccxt/coinbase.py +6 -6
  127. ccxt/coinbasepro.py +2 -2
  128. ccxt/coincheck.py +1 -1
  129. ccxt/coinex.py +9 -9
  130. ccxt/coinlist.py +4 -4
  131. ccxt/coinmate.py +2 -2
  132. ccxt/coinmetro.py +2 -2
  133. ccxt/coinone.py +1 -1
  134. ccxt/coinsph.py +2 -2
  135. ccxt/coinspot.py +1 -1
  136. ccxt/cryptocom.py +14 -14
  137. ccxt/currencycom.py +1 -1
  138. ccxt/delta.py +2 -2
  139. ccxt/deribit.py +4 -4
  140. ccxt/digifinex.py +6 -6
  141. ccxt/exmo.py +2 -2
  142. ccxt/gate.py +41 -37
  143. ccxt/gemini.py +2 -2
  144. ccxt/hitbtc.py +5 -5
  145. ccxt/hollaex.py +2 -2
  146. ccxt/htx.py +10 -10
  147. ccxt/huobijp.py +4 -4
  148. ccxt/idex.py +2 -2
  149. ccxt/independentreserve.py +2 -2
  150. ccxt/indodax.py +2 -2
  151. ccxt/kraken.py +42 -4
  152. ccxt/krakenfutures.py +5 -5
  153. ccxt/kucoin.py +8 -8
  154. ccxt/kucoinfutures.py +4 -4
  155. ccxt/kuna.py +2 -2
  156. ccxt/latoken.py +3 -3
  157. ccxt/lbank.py +2 -2
  158. ccxt/luno.py +1 -1
  159. ccxt/lykke.py +2 -2
  160. ccxt/mercado.py +2 -2
  161. ccxt/mexc.py +7 -6
  162. ccxt/ndax.py +2 -2
  163. ccxt/novadax.py +4 -4
  164. ccxt/oceanex.py +1 -1
  165. ccxt/okcoin.py +5 -5
  166. ccxt/okx.py +11 -10
  167. ccxt/onetrading.py +2 -2
  168. ccxt/p2b.py +1 -1
  169. ccxt/paymium.py +3 -3
  170. ccxt/phemex.py +13 -13
  171. ccxt/poloniex.py +4 -4
  172. ccxt/poloniexfutures.py +1 -1
  173. ccxt/pro/__init__.py +1 -1
  174. ccxt/pro/alpaca.py +8 -4
  175. ccxt/pro/ascendex.py +1 -2
  176. ccxt/pro/binance.py +14 -10
  177. ccxt/pro/bingx.py +1 -1
  178. ccxt/pro/bitfinex.py +21 -22
  179. ccxt/pro/bitfinex2.py +13 -15
  180. ccxt/pro/bitget.py +3 -1
  181. ccxt/pro/bitmart.py +3 -7
  182. ccxt/pro/bitmex.py +4 -6
  183. ccxt/pro/bitopro.py +2 -4
  184. ccxt/pro/bitrue.py +1 -1
  185. ccxt/pro/bitstamp.py +2 -3
  186. ccxt/pro/bitvavo.py +10 -5
  187. ccxt/pro/blockchaincom.py +22 -22
  188. ccxt/pro/bybit.py +5 -5
  189. ccxt/pro/cex.py +7 -7
  190. ccxt/pro/coinbase.py +3 -2
  191. ccxt/pro/coinbasepro.py +1 -1
  192. ccxt/pro/coinex.py +15 -13
  193. ccxt/pro/currencycom.py +5 -6
  194. ccxt/pro/deribit.py +4 -4
  195. ccxt/pro/exmo.py +15 -13
  196. ccxt/pro/gate.py +1 -1
  197. ccxt/pro/gemini.py +4 -2
  198. ccxt/pro/hitbtc.py +10 -9
  199. ccxt/pro/hollaex.py +2 -2
  200. ccxt/pro/htx.py +6 -6
  201. ccxt/pro/huobijp.py +3 -4
  202. ccxt/pro/idex.py +1 -1
  203. ccxt/pro/independentreserve.py +14 -13
  204. ccxt/pro/kraken.py +10 -14
  205. ccxt/pro/krakenfutures.py +10 -6
  206. ccxt/pro/kucoin.py +10 -10
  207. ccxt/pro/kucoinfutures.py +11 -10
  208. ccxt/pro/lbank.py +10 -10
  209. ccxt/pro/luno.py +12 -14
  210. ccxt/pro/mexc.py +3 -2
  211. ccxt/pro/ndax.py +7 -11
  212. ccxt/pro/okcoin.py +7 -10
  213. ccxt/pro/okx.py +6 -9
  214. ccxt/pro/onetrading.py +16 -15
  215. ccxt/pro/p2b.py +5 -3
  216. ccxt/pro/phemex.py +16 -11
  217. ccxt/pro/poloniex.py +6 -4
  218. ccxt/pro/poloniexfutures.py +13 -9
  219. ccxt/pro/probit.py +15 -12
  220. ccxt/pro/upbit.py +8 -8
  221. ccxt/pro/wazirx.py +6 -3
  222. ccxt/pro/woo.py +9 -7
  223. ccxt/probit.py +5 -5
  224. ccxt/test/base/test_order_book.py +7 -7
  225. ccxt/test/base/test_shared_methods.py +1 -1
  226. ccxt/test/test_async.py +86 -36
  227. ccxt/test/test_sync.py +86 -36
  228. ccxt/timex.py +1 -1
  229. ccxt/tokocrypto.py +4 -4
  230. ccxt/upbit.py +2 -2
  231. ccxt/wavesexchange.py +4 -3
  232. ccxt/wazirx.py +1 -1
  233. ccxt/whitebit.py +5 -5
  234. ccxt/woo.py +6 -6
  235. ccxt/yobit.py +41 -2
  236. ccxt/zaif.py +2 -2
  237. ccxt/zonda.py +4 -4
  238. {ccxt-4.2.31.dist-info → ccxt-4.2.34.dist-info}/METADATA +9 -8
  239. ccxt-4.2.34.dist-info/RECORD +438 -0
  240. ccxt-4.2.31.dist-info/RECORD +0 -438
  241. {ccxt-4.2.31.dist-info → ccxt-4.2.34.dist-info}/WHEEL +0 -0
  242. {ccxt-4.2.31.dist-info → ccxt-4.2.34.dist-info}/top_level.txt +0 -0
ccxt/pro/ascendex.py CHANGED
@@ -843,7 +843,6 @@ class ascendex(ccxt.async_support.ascendex):
843
843
  self.handle_order(client, message)
844
844
  if subject == 'order':
845
845
  self.handle_balance(client, message)
846
- return message
847
846
 
848
847
  def handle_subscription_status(self, client: Client, message):
849
848
  #
@@ -879,7 +878,7 @@ class ascendex(ccxt.async_support.ascendex):
879
878
  def handle_ping(self, client: Client, message):
880
879
  self.spawn(self.pong, client, message)
881
880
 
882
- def authenticate(self, url, params={}):
881
+ async def authenticate(self, url, params={}):
883
882
  self.check_required_credentials()
884
883
  messageHash = 'authenticated'
885
884
  client = self.client(url)
ccxt/pro/binance.py CHANGED
@@ -491,7 +491,7 @@ class binance(ccxt.async_support.binance):
491
491
  """
492
492
  return await self.watch_trades_for_symbols([symbol], since, limit, params)
493
493
 
494
- def parse_trade(self, trade, market=None) -> Trade:
494
+ def parse_ws_trade(self, trade, market=None) -> Trade:
495
495
  #
496
496
  # public watchTrades
497
497
  #
@@ -599,7 +599,7 @@ class binance(ccxt.async_support.binance):
599
599
  executionType = self.safe_string(trade, 'x')
600
600
  isTradeExecution = (executionType == 'TRADE')
601
601
  if not isTradeExecution:
602
- return super(binance, self).parse_trade(trade, market)
602
+ return self.parse_trade(trade, market)
603
603
  id = self.safe_string_2(trade, 't', 'a')
604
604
  timestamp = self.safe_integer(trade, 'T')
605
605
  price = self.safe_string_2(trade, 'L', 'p')
@@ -657,7 +657,7 @@ class binance(ccxt.async_support.binance):
657
657
  lowerCaseId = self.safe_string_lower(message, 's')
658
658
  event = self.safe_string(message, 'e')
659
659
  messageHash = lowerCaseId + '@' + event
660
- trade = self.parse_trade(message, market)
660
+ trade = self.parse_ws_trade(message, market)
661
661
  tradesArray = self.safe_value(self.trades, symbol)
662
662
  if tradesArray is None:
663
663
  limit = self.safe_integer(self.options, 'tradesLimit', 1000)
@@ -1146,11 +1146,12 @@ class binance(ccxt.async_support.binance):
1146
1146
  for j in range(0, len(subscriptionKeys)):
1147
1147
  subscribeType = subscriptionKeys[j]
1148
1148
  if subscribeType == type:
1149
- return self.delay(listenKeyRefreshRate, self.keep_alive_listen_key, params)
1149
+ self.delay(listenKeyRefreshRate, self.keep_alive_listen_key, params)
1150
+ return
1150
1151
 
1151
1152
  def set_balance_cache(self, client: Client, type):
1152
1153
  if type in client.subscriptions:
1153
- return None
1154
+ return
1154
1155
  options = self.safe_value(self.options, 'watchBalance')
1155
1156
  fetchBalanceSnapshot = self.safe_bool(options, 'fetchBalanceSnapshot', False)
1156
1157
  if fetchBalanceSnapshot:
@@ -1245,7 +1246,7 @@ class binance(ccxt.async_support.binance):
1245
1246
  #
1246
1247
  messageHash = self.safe_string(message, 'id')
1247
1248
  result = self.safe_value(message, 'result', {})
1248
- parsedBalances = self.parse_balance(result, 'spot')
1249
+ parsedBalances = self.parse_balance(result)
1249
1250
  client.resolve(parsedBalances, messageHash)
1250
1251
 
1251
1252
  async def watch_balance(self, params={}) -> Balances:
@@ -2501,12 +2502,14 @@ class binance(ccxt.async_support.binance):
2501
2502
  status = self.safe_string(message, 'status')
2502
2503
  error = self.safe_value(message, 'error')
2503
2504
  if (error is not None) or (status is not None and status != '200'):
2504
- return self.handle_ws_error(client, message)
2505
+ self.handle_ws_error(client, message)
2506
+ return
2505
2507
  id = self.safe_string(message, 'id')
2506
2508
  subscriptions = self.safe_value(client.subscriptions, id)
2507
2509
  method = self.safe_value(subscriptions, 'method')
2508
2510
  if method is not None:
2509
- return method(client, message)
2511
+ method(client, message)
2512
+ return
2510
2513
  # handle other APIs
2511
2514
  methods = {
2512
2515
  'depthUpdate': self.handle_order_book,
@@ -2534,7 +2537,8 @@ class binance(ccxt.async_support.binance):
2534
2537
  if method is None:
2535
2538
  requestId = self.safe_string(message, 'id')
2536
2539
  if requestId is not None:
2537
- return self.handle_subscription_status(client, message)
2540
+ self.handle_subscription_status(client, message)
2541
+ return
2538
2542
  # special case for the real-time bookTicker, since it comes without an event identifier
2539
2543
  #
2540
2544
  # {
@@ -2550,4 +2554,4 @@ class binance(ccxt.async_support.binance):
2550
2554
  self.handle_ticker(client, message)
2551
2555
  self.handle_tickers(client, message)
2552
2556
  else:
2553
- return method(client, message)
2557
+ method(client, message)
ccxt/pro/bingx.py CHANGED
@@ -675,7 +675,7 @@ class bingx(ccxt.async_support.bingx):
675
675
 
676
676
  def set_balance_cache(self, client: Client, type, subscriptionHash, params):
677
677
  if subscriptionHash in client.subscriptions:
678
- return None
678
+ return
679
679
  fetchBalanceSnapshot = self.handle_option_and_params(params, 'watchBalance', 'fetchBalanceSnapshot', True)
680
680
  if fetchBalanceSnapshot:
681
681
  messageHash = type + ':fetchBalanceSnapshot'
ccxt/pro/bitfinex.py CHANGED
@@ -129,7 +129,6 @@ class bitfinex(ccxt.async_support.bitfinex):
129
129
  trade = self.parse_trade(message, market)
130
130
  stored.append(trade)
131
131
  client.resolve(stored, messageHash)
132
- return message
133
132
 
134
133
  def parse_trade(self, trade, market=None) -> Trade:
135
134
  #
@@ -308,35 +307,39 @@ class bitfinex(ccxt.async_support.bitfinex):
308
307
  delta = deltas[i]
309
308
  id = self.safe_string(delta, 0)
310
309
  price = self.safe_float(delta, 1)
311
- size = -delta[2] if (delta[2] < 0) else delta[2]
312
- side = 'asks' if (delta[2] < 0) else 'bids'
310
+ delta2Value = delta[2]
311
+ size = -delta2Value if (delta2Value < 0) else delta2Value
312
+ side = 'asks' if (delta2Value < 0) else 'bids'
313
313
  bookside = orderbook[side]
314
314
  bookside.store(price, size, id)
315
315
  else:
316
316
  deltas = message[1]
317
317
  for i in range(0, len(deltas)):
318
318
  delta = deltas[i]
319
- size = -delta[2] if (delta[2] < 0) else delta[2]
320
- side = 'asks' if (delta[2] < 0) else 'bids'
321
- bookside = orderbook[side]
322
- bookside.store(delta[0], size, delta[1])
319
+ delta2 = delta[2]
320
+ size = -delta2 if (delta2 < 0) else delta2
321
+ side = 'asks' if (delta2 < 0) else 'bids'
322
+ countedBookSide = orderbook[side]
323
+ countedBookSide.store(delta[0], size, delta[1])
323
324
  client.resolve(orderbook, messageHash)
324
325
  else:
325
326
  orderbook = self.orderbooks[symbol]
326
327
  if isRaw:
327
328
  id = self.safe_string(message, 1)
328
329
  price = self.safe_string(message, 2)
329
- size = -message[3] if (message[3] < 0) else message[3]
330
- side = 'asks' if (message[3] < 0) else 'bids'
330
+ message3 = message[3]
331
+ size = -message3 if (message3 < 0) else message3
332
+ side = 'asks' if (message3 < 0) else 'bids'
331
333
  bookside = orderbook[side]
332
334
  # price = 0 means that you have to remove the order from your book
333
335
  amount = size if Precise.string_gt(price, '0') else '0'
334
336
  bookside.store(self.parse_number(price), self.parse_number(amount), id)
335
337
  else:
336
- size = -message[3] if (message[3] < 0) else message[3]
337
- side = 'asks' if (message[3] < 0) else 'bids'
338
- bookside = orderbook[side]
339
- bookside.store(message[1], size, message[2])
338
+ message3Value = message[3]
339
+ size = -message3Value if (message3Value < 0) else message3Value
340
+ side = 'asks' if (message3Value < 0) else 'bids'
341
+ countedBookSide = orderbook[side]
342
+ countedBookSide.store(message[1], size, message[2])
340
343
  client.resolve(orderbook, messageHash)
341
344
 
342
345
  def handle_heartbeat(self, client: Client, message):
@@ -579,7 +582,7 @@ class bitfinex(ccxt.async_support.bitfinex):
579
582
  # ]
580
583
  #
581
584
  if message[1] == 'hb':
582
- return message # skip heartbeats within subscription channels for now
585
+ return # skip heartbeats within subscription channels for now
583
586
  subscription = self.safe_value(client.subscriptions, channelId, {})
584
587
  channel = self.safe_string(subscription, 'channel')
585
588
  name = self.safe_string(message, 1)
@@ -593,10 +596,8 @@ class bitfinex(ccxt.async_support.bitfinex):
593
596
  'oc': self.handle_orders,
594
597
  }
595
598
  method = self.safe_value_2(methods, channel, name)
596
- if method is None:
597
- return message
598
- else:
599
- return method(client, message, subscription)
599
+ if method is not None:
600
+ method(client, message, subscription)
600
601
  else:
601
602
  # todo add bitfinex handleErrorMessage
602
603
  #
@@ -616,7 +617,5 @@ class bitfinex(ccxt.async_support.bitfinex):
616
617
  'auth': self.handle_authentication_message,
617
618
  }
618
619
  method = self.safe_value(methods, event)
619
- if method is None:
620
- return message
621
- else:
622
- return method(client, message)
620
+ if method is not None:
621
+ method(client, message)
ccxt/pro/bitfinex2.py CHANGED
@@ -324,7 +324,6 @@ class bitfinex2(ccxt.async_support.bitfinex2):
324
324
  parsed = self.parse_ws_trade(trade, market)
325
325
  stored.append(parsed)
326
326
  client.resolve(stored, messageHash)
327
- return message
328
327
 
329
328
  def parse_ws_trade(self, trade, market=None):
330
329
  #
@@ -563,8 +562,9 @@ class bitfinex2(ccxt.async_support.bitfinex2):
563
562
  deltas = message[1]
564
563
  for i in range(0, len(deltas)):
565
564
  delta = deltas[i]
566
- size = -delta[2] if (delta[2] < 0) else delta[2]
567
- side = 'asks' if (delta[2] < 0) else 'bids'
565
+ delta2 = delta[2]
566
+ size = -delta2 if (delta2 < 0) else delta2
567
+ side = 'asks' if (delta2 < 0) else 'bids'
568
568
  bookside = orderbook[side]
569
569
  idString = self.safe_string(delta, 0)
570
570
  price = self.safe_float(delta, 1)
@@ -587,8 +587,9 @@ class bitfinex2(ccxt.async_support.bitfinex2):
587
587
  orderbookItem = self.orderbooks[symbol]
588
588
  if isRaw:
589
589
  price = self.safe_string(deltas, 1)
590
- size = -deltas[2] if (deltas[2] < 0) else deltas[2]
591
- side = 'asks' if (deltas[2] < 0) else 'bids'
590
+ deltas2 = deltas[2]
591
+ size = -deltas2 if (deltas2 < 0) else deltas2
592
+ side = 'asks' if (deltas2 < 0) else 'bids'
592
593
  bookside = orderbookItem[side]
593
594
  # price = 0 means that you have to remove the order from your book
594
595
  amount = size if Precise.string_gt(price, '0') else '0'
@@ -631,7 +632,8 @@ class bitfinex2(ccxt.async_support.bitfinex2):
631
632
  stringArray.append(self.number_to_string(bids[i][1]))
632
633
  if ask is not None:
633
634
  stringArray.append(self.number_to_string(asks[i][idToCheck]))
634
- stringArray.append(self.number_to_string(-asks[i][1]))
635
+ aski1 = asks[i][1]
636
+ stringArray.append(self.number_to_string(-aski1))
635
637
  payload = ':'.join(stringArray)
636
638
  localChecksum = self.crc32(payload, True)
637
639
  responseChecksum = self.safe_integer(message, 2)
@@ -1036,7 +1038,7 @@ class bitfinex2(ccxt.async_support.bitfinex2):
1036
1038
  #
1037
1039
  if isinstance(message, list):
1038
1040
  if message[1] == 'hb':
1039
- return message # skip heartbeats within subscription channels for now
1041
+ return # skip heartbeats within subscription channels for now
1040
1042
  subscription = self.safe_value(client.subscriptions, channelId, {})
1041
1043
  channel = self.safe_string(subscription, 'channel')
1042
1044
  name = self.safe_string(message, 1)
@@ -1061,10 +1063,8 @@ class bitfinex2(ccxt.async_support.bitfinex2):
1061
1063
  method = self.safe_value(privateMethods, name)
1062
1064
  else:
1063
1065
  method = self.safe_value_2(publicMethods, name, channel)
1064
- if method is None:
1065
- return message
1066
- else:
1067
- return method(client, message, subscription)
1066
+ if method is not None:
1067
+ method(client, message, subscription)
1068
1068
  else:
1069
1069
  event = self.safe_string(message, 'event')
1070
1070
  if event is not None:
@@ -1074,7 +1074,5 @@ class bitfinex2(ccxt.async_support.bitfinex2):
1074
1074
  'auth': self.handle_authentication_message,
1075
1075
  }
1076
1076
  method = self.safe_value(methods, event)
1077
- if method is None:
1078
- return message
1079
- else:
1080
- return method(client, message)
1077
+ if method is not None:
1078
+ method(client, message)
ccxt/pro/bitget.py CHANGED
@@ -100,7 +100,9 @@ class bitget(ccxt.async_support.bitget):
100
100
  instType, params = self.handleProductTypeAndParams(market, params)
101
101
  else:
102
102
  instType = 'SPOT'
103
- instType, params = self.handle_option_and_params(params, 'getInstType', 'instType', instType)
103
+ instypeAux = None
104
+ instypeAux, params = self.handle_option_and_params(params, 'getInstType', 'instType', instType)
105
+ instType = instypeAux
104
106
  return [instType, params]
105
107
 
106
108
  async def watch_ticker(self, symbol: str, params={}) -> Ticker:
ccxt/pro/bitmart.py CHANGED
@@ -766,7 +766,6 @@ class bitmart(ccxt.async_support.bitmart):
766
766
  if isSpot:
767
767
  messageHash += ':' + self.safe_string(data[0], 'symbol')
768
768
  client.resolve(stored, messageHash)
769
- return message
770
769
 
771
770
  def parse_ws_trade(self, trade, market: Market = None):
772
771
  # spot
@@ -864,7 +863,6 @@ class bitmart(ccxt.async_support.bitmart):
864
863
  self.tickers[symbol] = ticker
865
864
  client.resolve(ticker, 'tickers::swap')
866
865
  self.resolve_message_hashes_for_symbol(client, symbol, ticker, 'tickers::')
867
- return message
868
866
 
869
867
  def resolve_message_hashes_for_symbol(self, client, symbol, result, prexif):
870
868
  prefixSeparator = '::'
@@ -1357,10 +1355,8 @@ class bitmart(ccxt.async_support.bitmart):
1357
1355
  'subscribe': self.handle_subscription_status,
1358
1356
  }
1359
1357
  method = self.safe_value(methods, event)
1360
- if method is None:
1361
- return message
1362
- else:
1363
- return method(client, message)
1358
+ if method is not None:
1359
+ method(client, message)
1364
1360
  else:
1365
1361
  methods = {
1366
1362
  'depth': self.handle_order_book,
@@ -1377,4 +1373,4 @@ class bitmart(ccxt.async_support.bitmart):
1377
1373
  key = keys[i]
1378
1374
  if channel.find(key) >= 0:
1379
1375
  method = self.safe_value(methods, key)
1380
- return method(client, message)
1376
+ method(client, message)
ccxt/pro/bitmex.py CHANGED
@@ -1462,7 +1462,7 @@ class bitmex(ccxt.async_support.bitmex):
1462
1462
  #
1463
1463
  # {"error": "Rate limit exceeded, retry in 29 seconds."}
1464
1464
  #
1465
- error = self.safe_value(message, 'error')
1465
+ error = self.safe_string(message, 'error')
1466
1466
  if error is not None:
1467
1467
  request = self.safe_value(message, 'request', {})
1468
1468
  args = self.safe_value(request, 'args', [])
@@ -1473,7 +1473,7 @@ class bitmex(ccxt.async_support.bitmex):
1473
1473
  broadKey = self.find_broadly_matched_key(broad, error)
1474
1474
  exception = None
1475
1475
  if broadKey is None:
1476
- exception = ExchangeError(error)
1476
+ exception = ExchangeError(error) # c# requirement for now
1477
1477
  else:
1478
1478
  exception = broad[broadKey](error)
1479
1479
  client.reject(exception, messageHash)
@@ -1537,8 +1537,6 @@ class bitmex(ccxt.async_support.bitmex):
1537
1537
  request = self.safe_value(message, 'request', {})
1538
1538
  op = self.safe_value(request, 'op')
1539
1539
  if op == 'authKeyExpires':
1540
- return self.handle_authentication_message(client, message)
1541
- else:
1542
- return message
1540
+ self.handle_authentication_message(client, message)
1543
1541
  else:
1544
- return method(client, message)
1542
+ method(client, message)
ccxt/pro/bitopro.py CHANGED
@@ -440,7 +440,5 @@ class bitopro(ccxt.async_support.bitopro):
440
440
  }
441
441
  event = self.safe_string(message, 'event')
442
442
  method = self.safe_value(methods, event)
443
- if method is None:
444
- return message
445
- else:
446
- return method(client, message)
443
+ if method is not None:
444
+ method(client, message)
ccxt/pro/bitrue.py CHANGED
@@ -408,7 +408,7 @@ class bitrue(ccxt.async_support.bitrue):
408
408
  except Exception as error:
409
409
  self.options['listenKey'] = None
410
410
  self.options['listenKeyUrl'] = None
411
- return
411
+ return None
412
412
  #
413
413
  # {
414
414
  # "msg": "succ",
ccxt/pro/bitstamp.py CHANGED
@@ -482,9 +482,9 @@ class bitstamp(ccxt.async_support.bitstamp):
482
482
  #
483
483
  event = self.safe_string(message, 'event')
484
484
  if event == 'bts:subscription_succeeded':
485
- return self.handle_subscription_status(client, message)
485
+ self.handle_subscription_status(client, message)
486
486
  else:
487
- return self.handle_subject(client, message)
487
+ self.handle_subject(client, message)
488
488
 
489
489
  async def authenticate(self, params={}):
490
490
  self.check_required_credentials()
@@ -506,7 +506,6 @@ class bitstamp(ccxt.async_support.bitstamp):
506
506
  self.options['expiresIn'] = self.sum(time, validity)
507
507
  self.options['userId'] = userId
508
508
  self.options['wsSessionToken'] = sessionToken
509
- return response
510
509
 
511
510
  async def subscribe_private(self, subscription, messageHash, params={}):
512
511
  url = self.urls['api']['ws']
ccxt/pro/bitvavo.py CHANGED
@@ -400,7 +400,7 @@ class bitvavo(ccxt.async_support.bitvavo):
400
400
  #
401
401
  response = self.safe_value(message, 'response')
402
402
  if response is None:
403
- return message
403
+ return
404
404
  marketId = self.safe_string(response, 'market')
405
405
  symbol = self.safe_symbol(marketId, None, '-')
406
406
  name = 'book'
@@ -502,7 +502,7 @@ class bitvavo(ccxt.async_support.bitvavo):
502
502
  limit = trades.getLimit(symbol, limit)
503
503
  return self.filter_by_symbol_since_limit(trades, symbol, since, limit, True)
504
504
 
505
- async def create_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}) -> Order:
505
+ async def create_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: float = None, params={}) -> Order:
506
506
  """
507
507
  create a trade order
508
508
  :see: https://docs.bitvavo.com/#tag/Orders/paths/~1order/post
@@ -1122,7 +1122,7 @@ class bitvavo(ccxt.async_support.bitvavo):
1122
1122
  method(client, message, subscription)
1123
1123
  return message
1124
1124
 
1125
- def authenticate(self, params={}):
1125
+ async def authenticate(self, params={}):
1126
1126
  url = self.urls['api']['ws']
1127
1127
  client = self.client(url)
1128
1128
  messageHash = 'authenticated'
@@ -1259,7 +1259,12 @@ class bitvavo(ccxt.async_support.bitvavo):
1259
1259
  'getCandles': self.handle_fetch_ohlcv,
1260
1260
  'getMarkets': self.handle_markets,
1261
1261
  }
1262
- event = self.safe_string_2(message, 'event', 'action')
1262
+ event = self.safe_string(message, 'event')
1263
1263
  method = self.safe_value(methods, event)
1264
- if method is not None:
1264
+ if method is None:
1265
+ action = self.safe_string(message, 'action')
1266
+ method = self.safe_value(methods, action)
1267
+ if method is not None:
1268
+ method(client, message)
1269
+ else:
1265
1270
  method(client, message)
ccxt/pro/blockchaincom.py CHANGED
@@ -107,7 +107,7 @@ class blockchaincom(ccxt.async_support.blockchaincom):
107
107
  #
108
108
  event = self.safe_string(message, 'event')
109
109
  if event == 'subscribed':
110
- return message
110
+ return
111
111
  result = {'info': message}
112
112
  balances = self.safe_value(message, 'balances', [])
113
113
  for i in range(0, len(balances)):
@@ -172,10 +172,9 @@ class blockchaincom(ccxt.async_support.blockchaincom):
172
172
  # }
173
173
  #
174
174
  event = self.safe_string(message, 'event')
175
- if event == 'subscribed':
176
- return message
177
- elif event == 'rejected':
178
- raise ExchangeError(self.id + ' ' + self.json(message))
175
+ if event == 'rejected':
176
+ jsonMessage = self.json(message)
177
+ raise ExchangeError(self.id + ' ' + jsonMessage)
179
178
  elif event == 'updated':
180
179
  marketId = self.safe_string(message, 'symbol')
181
180
  symbol = self.safe_symbol(marketId, None, '-')
@@ -192,7 +191,7 @@ class blockchaincom(ccxt.async_support.blockchaincom):
192
191
  self.ohlcvs[symbol][timeframe] = stored
193
192
  stored.append(ohlcv)
194
193
  client.resolve(stored, messageHash)
195
- else:
194
+ elif event != 'subscribed':
196
195
  raise NotSupported(self.id + ' ' + self.json(message))
197
196
 
198
197
  async def watch_ticker(self, symbol: str, params={}) -> Ticker:
@@ -251,7 +250,7 @@ class blockchaincom(ccxt.async_support.blockchaincom):
251
250
  symbol = market['symbol']
252
251
  ticker = None
253
252
  if event == 'subscribed':
254
- return message
253
+ return
255
254
  elif event == 'snapshot':
256
255
  ticker = self.parse_ticker(message, market)
257
256
  elif event == 'updated':
@@ -345,7 +344,7 @@ class blockchaincom(ccxt.async_support.blockchaincom):
345
344
  #
346
345
  event = self.safe_string(message, 'event')
347
346
  if event != 'updated':
348
- return message
347
+ return
349
348
  marketId = self.safe_string(message, 'symbol')
350
349
  symbol = self.safe_symbol(marketId)
351
350
  market = self.safe_market(marketId)
@@ -500,7 +499,7 @@ class blockchaincom(ccxt.async_support.blockchaincom):
500
499
  limit = self.safe_integer(self.options, 'ordersLimit', 1000)
501
500
  self.orders = ArrayCacheBySymbolById(limit)
502
501
  if event == 'subscribed':
503
- return message
502
+ return
504
503
  elif event == 'rejected':
505
504
  raise ExchangeError(self.id + ' ' + self.json(message))
506
505
  elif event == 'snapshot':
@@ -662,25 +661,25 @@ class blockchaincom(ccxt.async_support.blockchaincom):
662
661
  messageHash = 'orderbook:' + symbol + ':' + type
663
662
  datetime = self.safe_string(message, 'timestamp')
664
663
  timestamp = self.parse8601(datetime)
665
- storedOrderBook = self.safe_value(self.orderbooks, symbol)
666
- if storedOrderBook is None:
667
- storedOrderBook = self.counted_order_book({})
668
- self.orderbooks[symbol] = storedOrderBook
664
+ orderbook = self.safe_value(self.orderbooks, symbol)
665
+ if orderbook is None:
666
+ orderbook = self.counted_order_book({})
667
+ self.orderbooks[symbol] = orderbook
669
668
  if event == 'subscribed':
670
- return message
669
+ return
671
670
  elif event == 'snapshot':
672
671
  snapshot = self.parse_order_book(message, symbol, timestamp, 'bids', 'asks', 'px', 'qty', 'num')
673
- storedOrderBook.reset(snapshot)
672
+ orderbook.reset(snapshot)
674
673
  elif event == 'updated':
675
674
  asks = self.safe_value(message, 'asks', [])
676
675
  bids = self.safe_value(message, 'bids', [])
677
- self.handle_deltas(storedOrderBook['asks'], asks)
678
- self.handle_deltas(storedOrderBook['bids'], bids)
679
- storedOrderBook['timestamp'] = timestamp
680
- storedOrderBook['datetime'] = datetime
676
+ self.handle_deltas(orderbook['asks'], asks)
677
+ self.handle_deltas(orderbook['bids'], bids)
678
+ orderbook['timestamp'] = timestamp
679
+ orderbook['datetime'] = datetime
681
680
  else:
682
681
  raise NotSupported(self.id + ' watchOrderBook() does not support ' + event + ' yet')
683
- client.resolve(storedOrderBook, messageHash)
682
+ client.resolve(orderbook, messageHash)
684
683
 
685
684
  def handle_delta(self, bookside, delta):
686
685
  bookArray = self.parse_bid_ask(delta, 'px', 'qty', 'num')
@@ -717,7 +716,8 @@ class blockchaincom(ccxt.async_support.blockchaincom):
717
716
  }
718
717
  handler = self.safe_value(handlers, channel)
719
718
  if handler is not None:
720
- return handler(client, message)
719
+ handler(client, message)
720
+ return
721
721
  raise NotSupported(self.id + ' received an unsupported message: ' + self.json(message))
722
722
 
723
723
  def handle_authentication_message(self, client: Client, message):
@@ -736,7 +736,7 @@ class blockchaincom(ccxt.async_support.blockchaincom):
736
736
  if future is not None:
737
737
  future.resolve(True)
738
738
 
739
- def authenticate(self, params={}):
739
+ async def authenticate(self, params={}):
740
740
  url = self.urls['api']['ws']
741
741
  client = self.client(url)
742
742
  messageHash = 'authenticated'
ccxt/pro/bybit.py CHANGED
@@ -853,7 +853,7 @@ class bybit(ccxt.async_support.bybit):
853
853
  """
854
854
  :see: https://bybit-exchange.github.io/docs/v5/websocket/private/position
855
855
  watch all open positions
856
- :param str[]|None symbols: list of unified market symbols
856
+ :param str[] [symbols]: list of unified market symbols
857
857
  :param dict params: extra parameters specific to the exchange API endpoint
858
858
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/en/latest/manual.html#position-structure>`
859
859
  """
@@ -883,7 +883,7 @@ class bybit(ccxt.async_support.bybit):
883
883
 
884
884
  def set_positions_cache(self, client: Client, symbols: Strings = None):
885
885
  if self.positions is not None:
886
- return self.positions
886
+ return
887
887
  fetchPositionsSnapshot = self.handle_option('watchPositions', 'fetchPositionsSnapshot', True)
888
888
  if fetchPositionsSnapshot:
889
889
  messageHash = 'fetchPositionsSnapshot'
@@ -1002,7 +1002,7 @@ class bybit(ccxt.async_support.bybit):
1002
1002
  limit = orders.getLimit(symbol, limit)
1003
1003
  return self.filter_by_symbol_since_limit(orders, symbol, since, limit, True)
1004
1004
 
1005
- def handle_order(self, client: Client, message, subscription=None):
1005
+ def handle_order(self, client: Client, message):
1006
1006
  #
1007
1007
  # spot
1008
1008
  # {
@@ -1532,7 +1532,7 @@ class bybit(ccxt.async_support.bybit):
1532
1532
  authenticated = self.safe_value(client.subscriptions, messageHash)
1533
1533
  if authenticated is None:
1534
1534
  expiresInt = self.milliseconds() + 10000
1535
- expires = str(expiresInt)
1535
+ expires = self.number_to_string(expiresInt)
1536
1536
  path = 'GET/realtime'
1537
1537
  auth = path + expires
1538
1538
  signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256, 'hex')
@@ -1544,7 +1544,7 @@ class bybit(ccxt.async_support.bybit):
1544
1544
  }
1545
1545
  message = self.extend(request, params)
1546
1546
  self.watch(url, messageHash, message, messageHash)
1547
- return future
1547
+ return await future
1548
1548
 
1549
1549
  def handle_error_message(self, client: Client, message):
1550
1550
  #
ccxt/pro/cex.py CHANGED
@@ -912,15 +912,15 @@ class cex(ccxt.async_support.cex):
912
912
  messageHash = 'orderbook:' + symbol
913
913
  timestamp = self.safe_integer_2(data, 'timestamp_ms', 'timestamp')
914
914
  incrementalId = self.safe_number(data, 'id')
915
- storedOrderBook = self.order_book({})
915
+ orderbook = self.order_book({})
916
916
  snapshot = self.parse_order_book(data, symbol, timestamp, 'bids', 'asks')
917
917
  snapshot['nonce'] = incrementalId
918
- storedOrderBook.reset(snapshot)
918
+ orderbook.reset(snapshot)
919
919
  self.options['orderbook'][symbol] = {
920
920
  'incrementalId': incrementalId,
921
921
  }
922
- self.orderbooks[symbol] = storedOrderBook
923
- client.resolve(storedOrderBook, messageHash)
922
+ self.orderbooks[symbol] = orderbook
923
+ client.resolve(orderbook, messageHash)
924
924
 
925
925
  def pair_to_symbol(self, pair):
926
926
  parts = pair.split(':')
@@ -1355,7 +1355,8 @@ class cex(ccxt.async_support.cex):
1355
1355
  def handle_message(self, client: Client, message):
1356
1356
  ok = self.safe_string(message, 'ok')
1357
1357
  if ok == 'error':
1358
- return self.handle_error_message(client, message)
1358
+ self.handle_error_message(client, message)
1359
+ return
1359
1360
  event = self.safe_string(message, 'e')
1360
1361
  handlers = {
1361
1362
  'auth': self.handle_authentication_message,
@@ -1382,8 +1383,7 @@ class cex(ccxt.async_support.cex):
1382
1383
  }
1383
1384
  handler = self.safe_value(handlers, event)
1384
1385
  if handler is not None:
1385
- return handler(client, message)
1386
- return message
1386
+ handler(client, message)
1387
1387
 
1388
1388
  def handle_authentication_message(self, client: Client, message):
1389
1389
  #
ccxt/pro/coinbase.py CHANGED
@@ -437,7 +437,8 @@ class coinbase(ccxt.async_support.coinbase):
437
437
  side = self.safe_string(self.options['sides'], sideId)
438
438
  price = self.safe_number(trade, 'price_level')
439
439
  amount = self.safe_number(trade, 'new_quantity')
440
- orderbook[side].store(price, amount)
440
+ orderbookSide = orderbook[side]
441
+ orderbookSide.store(price, amount)
441
442
 
442
443
  def handle_order_book(self, client, message):
443
444
  #
@@ -525,4 +526,4 @@ class coinbase(ccxt.async_support.coinbase):
525
526
  errorMessage = self.safe_string(message, 'message')
526
527
  raise ExchangeError(errorMessage)
527
528
  method = self.safe_value(methods, channel)
528
- return method(client, message)
529
+ method(client, message)