ccxt 4.2.30__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.
- ccxt/__init__.py +1 -1
- ccxt/abstract/coinbase.py +10 -0
- ccxt/abstract/okx.py +12 -1
- ccxt/ace.py +4 -3
- ccxt/alpaca.py +1 -1
- ccxt/ascendex.py +6 -6
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ace.py +4 -3
- ccxt/async_support/alpaca.py +1 -1
- ccxt/async_support/ascendex.py +6 -6
- ccxt/async_support/base/exchange.py +62 -39
- ccxt/async_support/bigone.py +25 -5
- ccxt/async_support/binance.py +17 -16
- ccxt/async_support/bingx.py +10 -9
- ccxt/async_support/bit2c.py +13 -1
- ccxt/async_support/bitbank.py +2 -2
- ccxt/async_support/bitbns.py +1 -1
- ccxt/async_support/bitfinex.py +5 -5
- ccxt/async_support/bitfinex2.py +386 -40
- ccxt/async_support/bitflyer.py +5 -5
- ccxt/async_support/bitforex.py +4 -1
- ccxt/async_support/bitget.py +11 -11
- ccxt/async_support/bithumb.py +2 -2
- ccxt/async_support/bitmart.py +9 -9
- ccxt/async_support/bitmex.py +3 -3
- ccxt/async_support/bitopro.py +2 -2
- ccxt/async_support/bitrue.py +8 -8
- ccxt/async_support/bitso.py +4 -4
- ccxt/async_support/bitstamp.py +2 -2
- ccxt/async_support/bitteam.py +1 -1
- ccxt/async_support/bitvavo.py +3 -3
- ccxt/async_support/bl3p.py +1 -1
- ccxt/async_support/blockchaincom.py +3 -3
- ccxt/async_support/btcalpha.py +1 -1
- ccxt/async_support/btcbox.py +1 -1
- ccxt/async_support/btcmarkets.py +2 -2
- ccxt/async_support/btcturk.py +1 -1
- ccxt/async_support/bybit.py +9 -9
- ccxt/async_support/cex.py +1 -1
- ccxt/async_support/coinbase.py +16 -6
- ccxt/async_support/coinbasepro.py +2 -2
- ccxt/async_support/coincheck.py +1 -1
- ccxt/async_support/coinex.py +9 -9
- ccxt/async_support/coinlist.py +4 -4
- ccxt/async_support/coinmate.py +2 -2
- ccxt/async_support/coinmetro.py +2 -2
- ccxt/async_support/coinone.py +1 -1
- ccxt/async_support/coinsph.py +2 -2
- ccxt/async_support/coinspot.py +1 -1
- ccxt/async_support/cryptocom.py +14 -14
- ccxt/async_support/currencycom.py +1 -1
- ccxt/async_support/delta.py +2 -2
- ccxt/async_support/deribit.py +5 -4
- ccxt/async_support/digifinex.py +6 -6
- ccxt/async_support/exmo.py +2 -2
- ccxt/async_support/gate.py +41 -37
- ccxt/async_support/gemini.py +2 -2
- ccxt/async_support/hitbtc.py +5 -5
- ccxt/async_support/hollaex.py +2 -2
- ccxt/async_support/htx.py +11 -11
- ccxt/async_support/huobijp.py +4 -4
- ccxt/async_support/idex.py +2 -2
- ccxt/async_support/independentreserve.py +2 -2
- ccxt/async_support/indodax.py +2 -2
- ccxt/async_support/kraken.py +45 -5
- ccxt/async_support/krakenfutures.py +8 -5
- ccxt/async_support/kucoin.py +8 -8
- ccxt/async_support/kucoinfutures.py +4 -4
- ccxt/async_support/kuna.py +2 -2
- ccxt/async_support/latoken.py +3 -3
- ccxt/async_support/lbank.py +5 -4
- ccxt/async_support/luno.py +1 -1
- ccxt/async_support/lykke.py +2 -2
- ccxt/async_support/mercado.py +2 -2
- ccxt/async_support/mexc.py +7 -6
- ccxt/async_support/ndax.py +2 -2
- ccxt/async_support/novadax.py +4 -4
- ccxt/async_support/oceanex.py +1 -1
- ccxt/async_support/okcoin.py +5 -5
- ccxt/async_support/okx.py +26 -12
- ccxt/async_support/onetrading.py +2 -2
- ccxt/async_support/p2b.py +1 -1
- ccxt/async_support/paymium.py +3 -3
- ccxt/async_support/phemex.py +13 -13
- ccxt/async_support/poloniex.py +4 -4
- ccxt/async_support/poloniexfutures.py +4 -1
- ccxt/async_support/probit.py +5 -5
- ccxt/async_support/timex.py +2 -2
- ccxt/async_support/tokocrypto.py +4 -4
- ccxt/async_support/upbit.py +2 -2
- ccxt/async_support/wavesexchange.py +4 -3
- ccxt/async_support/wazirx.py +1 -1
- ccxt/async_support/whitebit.py +6 -6
- ccxt/async_support/woo.py +6 -6
- ccxt/async_support/yobit.py +41 -2
- ccxt/async_support/zaif.py +2 -2
- ccxt/async_support/zonda.py +4 -4
- ccxt/base/exchange.py +77 -44
- ccxt/base/types.py +10 -0
- ccxt/bigone.py +25 -5
- ccxt/binance.py +17 -16
- ccxt/bingx.py +10 -9
- ccxt/bit2c.py +13 -1
- ccxt/bitbank.py +2 -2
- ccxt/bitbns.py +1 -1
- ccxt/bitfinex.py +5 -5
- ccxt/bitfinex2.py +386 -40
- ccxt/bitflyer.py +5 -5
- ccxt/bitforex.py +4 -1
- ccxt/bitget.py +11 -11
- ccxt/bithumb.py +2 -2
- ccxt/bitmart.py +9 -9
- ccxt/bitmex.py +3 -3
- ccxt/bitopro.py +2 -2
- ccxt/bitrue.py +8 -8
- ccxt/bitso.py +4 -4
- ccxt/bitstamp.py +2 -2
- ccxt/bitteam.py +1 -1
- ccxt/bitvavo.py +3 -3
- ccxt/bl3p.py +1 -1
- ccxt/blockchaincom.py +3 -3
- ccxt/btcalpha.py +1 -1
- ccxt/btcbox.py +1 -1
- ccxt/btcmarkets.py +2 -2
- ccxt/btcturk.py +1 -1
- ccxt/bybit.py +9 -9
- ccxt/cex.py +1 -1
- ccxt/coinbase.py +16 -6
- ccxt/coinbasepro.py +2 -2
- ccxt/coincheck.py +1 -1
- ccxt/coinex.py +9 -9
- ccxt/coinlist.py +4 -4
- ccxt/coinmate.py +2 -2
- ccxt/coinmetro.py +2 -2
- ccxt/coinone.py +1 -1
- ccxt/coinsph.py +2 -2
- ccxt/coinspot.py +1 -1
- ccxt/cryptocom.py +14 -14
- ccxt/currencycom.py +1 -1
- ccxt/delta.py +2 -2
- ccxt/deribit.py +5 -4
- ccxt/digifinex.py +6 -6
- ccxt/exmo.py +2 -2
- ccxt/gate.py +41 -37
- ccxt/gemini.py +2 -2
- ccxt/hitbtc.py +5 -5
- ccxt/hollaex.py +2 -2
- ccxt/htx.py +11 -11
- ccxt/huobijp.py +4 -4
- ccxt/idex.py +2 -2
- ccxt/independentreserve.py +2 -2
- ccxt/indodax.py +2 -2
- ccxt/kraken.py +45 -5
- ccxt/krakenfutures.py +8 -5
- ccxt/kucoin.py +8 -8
- ccxt/kucoinfutures.py +4 -4
- ccxt/kuna.py +2 -2
- ccxt/latoken.py +3 -3
- ccxt/lbank.py +5 -4
- ccxt/luno.py +1 -1
- ccxt/lykke.py +2 -2
- ccxt/mercado.py +2 -2
- ccxt/mexc.py +7 -6
- ccxt/ndax.py +2 -2
- ccxt/novadax.py +4 -4
- ccxt/oceanex.py +1 -1
- ccxt/okcoin.py +5 -5
- ccxt/okx.py +26 -12
- ccxt/onetrading.py +2 -2
- ccxt/p2b.py +1 -1
- ccxt/paymium.py +3 -3
- ccxt/phemex.py +13 -13
- ccxt/poloniex.py +4 -4
- ccxt/poloniexfutures.py +4 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/alpaca.py +8 -4
- ccxt/pro/ascendex.py +1 -2
- ccxt/pro/binance.py +14 -10
- ccxt/pro/bingx.py +1 -1
- ccxt/pro/bitfinex.py +21 -22
- ccxt/pro/bitfinex2.py +13 -15
- ccxt/pro/bitget.py +3 -1
- ccxt/pro/bitmart.py +3 -7
- ccxt/pro/bitmex.py +4 -6
- ccxt/pro/bitopro.py +2 -4
- ccxt/pro/bitrue.py +1 -1
- ccxt/pro/bitstamp.py +2 -3
- ccxt/pro/bitvavo.py +10 -5
- ccxt/pro/blockchaincom.py +22 -22
- ccxt/pro/bybit.py +5 -5
- ccxt/pro/cex.py +7 -7
- ccxt/pro/coinbase.py +3 -2
- ccxt/pro/coinbasepro.py +1 -1
- ccxt/pro/coinex.py +15 -13
- ccxt/pro/currencycom.py +5 -6
- ccxt/pro/deribit.py +4 -4
- ccxt/pro/exmo.py +15 -13
- ccxt/pro/gate.py +1 -1
- ccxt/pro/gemini.py +4 -2
- ccxt/pro/hitbtc.py +10 -9
- ccxt/pro/hollaex.py +2 -2
- ccxt/pro/htx.py +6 -6
- ccxt/pro/huobijp.py +3 -4
- ccxt/pro/idex.py +1 -1
- ccxt/pro/independentreserve.py +14 -13
- ccxt/pro/kraken.py +10 -14
- ccxt/pro/krakenfutures.py +10 -6
- ccxt/pro/kucoin.py +10 -10
- ccxt/pro/kucoinfutures.py +11 -10
- ccxt/pro/lbank.py +10 -10
- ccxt/pro/luno.py +12 -14
- ccxt/pro/mexc.py +3 -2
- ccxt/pro/ndax.py +7 -11
- ccxt/pro/okcoin.py +7 -10
- ccxt/pro/okx.py +6 -9
- ccxt/pro/onetrading.py +16 -15
- ccxt/pro/p2b.py +5 -3
- ccxt/pro/phemex.py +16 -11
- ccxt/pro/poloniex.py +6 -4
- ccxt/pro/poloniexfutures.py +13 -9
- ccxt/pro/probit.py +15 -12
- ccxt/pro/upbit.py +8 -8
- ccxt/pro/wazirx.py +6 -3
- ccxt/pro/woo.py +9 -7
- ccxt/probit.py +5 -5
- ccxt/test/base/test_order_book.py +7 -7
- ccxt/test/base/test_shared_methods.py +1 -1
- ccxt/test/test_async.py +86 -36
- ccxt/test/test_sync.py +86 -36
- ccxt/timex.py +2 -2
- ccxt/tokocrypto.py +4 -4
- ccxt/upbit.py +2 -2
- ccxt/wavesexchange.py +4 -3
- ccxt/wazirx.py +1 -1
- ccxt/whitebit.py +6 -6
- ccxt/woo.py +6 -6
- ccxt/yobit.py +41 -2
- ccxt/zaif.py +2 -2
- ccxt/zonda.py +4 -4
- {ccxt-4.2.30.dist-info → ccxt-4.2.34.dist-info}/METADATA +10 -10
- ccxt-4.2.34.dist-info/RECORD +438 -0
- ccxt-4.2.30.dist-info/RECORD +0 -438
- {ccxt-4.2.30.dist-info → ccxt-4.2.34.dist-info}/WHEEL +0 -0
- {ccxt-4.2.30.dist-info → ccxt-4.2.34.dist-info}/top_level.txt +0 -0
ccxt/pro/kraken.py
CHANGED
@@ -641,7 +641,7 @@ class kraken(ccxt.async_support.kraken):
|
|
641
641
|
side = sides[key]
|
642
642
|
bookside = orderbook[side]
|
643
643
|
deltas = self.safe_value(message[1], key, [])
|
644
|
-
timestamp = self.
|
644
|
+
timestamp = self.custom_handle_deltas(bookside, deltas, timestamp)
|
645
645
|
orderbook['symbol'] = symbol
|
646
646
|
orderbook['timestamp'] = timestamp
|
647
647
|
orderbook['datetime'] = self.iso8601(timestamp)
|
@@ -667,10 +667,10 @@ class kraken(ccxt.async_support.kraken):
|
|
667
667
|
storedBids = orderbook['bids']
|
668
668
|
example = None
|
669
669
|
if a is not None:
|
670
|
-
timestamp = self.
|
670
|
+
timestamp = self.custom_handle_deltas(storedAsks, a, timestamp)
|
671
671
|
example = self.safe_value(a, 0)
|
672
672
|
if b is not None:
|
673
|
-
timestamp = self.
|
673
|
+
timestamp = self.custom_handle_deltas(storedBids, b, timestamp)
|
674
674
|
example = self.safe_value(b, 0)
|
675
675
|
# don't remove self line or I will poop on your face
|
676
676
|
orderbook.limit()
|
@@ -715,7 +715,7 @@ class kraken(ccxt.async_support.kraken):
|
|
715
715
|
else:
|
716
716
|
return joined
|
717
717
|
|
718
|
-
def
|
718
|
+
def custom_handle_deltas(self, bookside, deltas, timestamp=None):
|
719
719
|
for j in range(0, len(deltas)):
|
720
720
|
delta = deltas[j]
|
721
721
|
price = self.parse_number(delta[0])
|
@@ -1222,7 +1222,7 @@ class kraken(ccxt.async_support.kraken):
|
|
1222
1222
|
# "subscription": {name: "ticker"}
|
1223
1223
|
# }
|
1224
1224
|
#
|
1225
|
-
errorMessage = self.
|
1225
|
+
errorMessage = self.safe_string(message, 'errorMessage')
|
1226
1226
|
if errorMessage is not None:
|
1227
1227
|
requestId = self.safe_value(message, 'reqid')
|
1228
1228
|
if requestId is not None:
|
@@ -1230,7 +1230,7 @@ class kraken(ccxt.async_support.kraken):
|
|
1230
1230
|
broadKey = self.find_broadly_matched_key(broad, errorMessage)
|
1231
1231
|
exception = None
|
1232
1232
|
if broadKey is None:
|
1233
|
-
exception = ExchangeError(errorMessage)
|
1233
|
+
exception = ExchangeError(errorMessage) # c# requirement to convert the errorMessage to string
|
1234
1234
|
else:
|
1235
1235
|
exception = broad[broadKey](errorMessage)
|
1236
1236
|
client.reject(exception, requestId)
|
@@ -1256,10 +1256,8 @@ class kraken(ccxt.async_support.kraken):
|
|
1256
1256
|
'ownTrades': self.handle_my_trades,
|
1257
1257
|
}
|
1258
1258
|
method = self.safe_value_2(methods, name, channelName)
|
1259
|
-
if method is None:
|
1260
|
-
|
1261
|
-
else:
|
1262
|
-
return method(client, message, subscription)
|
1259
|
+
if method is not None:
|
1260
|
+
method(client, message, subscription)
|
1263
1261
|
else:
|
1264
1262
|
if self.handle_error_message(client, message):
|
1265
1263
|
event = self.safe_string(message, 'event')
|
@@ -1273,7 +1271,5 @@ class kraken(ccxt.async_support.kraken):
|
|
1273
1271
|
'cancelAllStatus': self.handle_cancel_all_orders,
|
1274
1272
|
}
|
1275
1273
|
method = self.safe_value(methods, event)
|
1276
|
-
if method is None:
|
1277
|
-
|
1278
|
-
else:
|
1279
|
-
return method(client, message)
|
1274
|
+
if method is not None:
|
1275
|
+
method(client, message)
|
ccxt/pro/krakenfutures.py
CHANGED
@@ -1008,12 +1008,14 @@ class krakenfutures(ccxt.async_support.krakenfutures):
|
|
1008
1008
|
bid = bids[i]
|
1009
1009
|
price = self.safe_number(bid, 'price')
|
1010
1010
|
qty = self.safe_number(bid, 'qty')
|
1011
|
-
orderbook['bids']
|
1011
|
+
bidsSide = orderbook['bids']
|
1012
|
+
bidsSide.store(price, qty)
|
1012
1013
|
for i in range(0, len(asks)):
|
1013
1014
|
ask = asks[i]
|
1014
1015
|
price = self.safe_number(ask, 'price')
|
1015
1016
|
qty = self.safe_number(ask, 'qty')
|
1016
|
-
orderbook['asks']
|
1017
|
+
asksSide = orderbook['asks']
|
1018
|
+
asksSide.store(price, qty)
|
1017
1019
|
orderbook['timestamp'] = timestamp
|
1018
1020
|
orderbook['datetime'] = self.iso8601(timestamp)
|
1019
1021
|
orderbook['symbol'] = symbol
|
@@ -1041,9 +1043,11 @@ class krakenfutures(ccxt.async_support.krakenfutures):
|
|
1041
1043
|
qty = self.safe_number(message, 'qty')
|
1042
1044
|
timestamp = self.safe_integer(message, 'timestamp')
|
1043
1045
|
if side == 'sell':
|
1044
|
-
orderbook['asks']
|
1046
|
+
asks = orderbook['asks']
|
1047
|
+
asks.store(price, qty)
|
1045
1048
|
else:
|
1046
|
-
orderbook['bids']
|
1049
|
+
bids = orderbook['bids']
|
1050
|
+
bids.store(price, qty)
|
1047
1051
|
orderbook['timestamp'] = timestamp
|
1048
1052
|
orderbook['datetime'] = self.iso8601(timestamp)
|
1049
1053
|
client.resolve(orderbook, messageHash)
|
@@ -1366,7 +1370,7 @@ class krakenfutures(ccxt.async_support.krakenfutures):
|
|
1366
1370
|
if event == 'challenge':
|
1367
1371
|
self.handle_authenticate(client, message)
|
1368
1372
|
elif event == 'alert':
|
1369
|
-
|
1373
|
+
self.handle_error_message(client, message)
|
1370
1374
|
elif event == 'pong':
|
1371
1375
|
client.lastPong = self.milliseconds()
|
1372
1376
|
elif event is None:
|
@@ -1391,7 +1395,7 @@ class krakenfutures(ccxt.async_support.krakenfutures):
|
|
1391
1395
|
}
|
1392
1396
|
method = self.safe_value(methods, feed)
|
1393
1397
|
if method is not None:
|
1394
|
-
|
1398
|
+
method(client, message)
|
1395
1399
|
|
1396
1400
|
def handle_authenticate(self, client: Client, message):
|
1397
1401
|
"""
|
ccxt/pro/kucoin.py
CHANGED
@@ -54,18 +54,19 @@ class kucoin(ccxt.async_support.kucoin):
|
|
54
54
|
},
|
55
55
|
})
|
56
56
|
|
57
|
-
def negotiate(self, privateChannel, params={}):
|
57
|
+
async def negotiate(self, privateChannel, params={}):
|
58
58
|
connectId = 'private' if privateChannel else 'public'
|
59
59
|
urls = self.safe_value(self.options, 'urls', {})
|
60
60
|
spawaned = self.safe_value(urls, connectId)
|
61
61
|
if spawaned is not None:
|
62
|
-
return spawaned
|
62
|
+
return await spawaned
|
63
63
|
# we store an awaitable to the url
|
64
64
|
# so that multiple calls don't asynchronously
|
65
65
|
# fetch different urls and overwrite each other
|
66
66
|
urls[connectId] = self.spawn(self.negotiate_helper, privateChannel, params)
|
67
67
|
self.options['urls'] = urls
|
68
|
-
|
68
|
+
future = urls[connectId]
|
69
|
+
return await future
|
69
70
|
|
70
71
|
async def negotiate_helper(self, privateChannel, params={}):
|
71
72
|
response = None
|
@@ -511,7 +512,7 @@ class kucoin(ccxt.async_support.kucoin):
|
|
511
512
|
limit = self.safe_integer(subscription, 'limit')
|
512
513
|
snapshotDelay = self.handle_option('watchOrderBook', 'snapshotDelay', 5)
|
513
514
|
if cacheLength == snapshotDelay:
|
514
|
-
self.spawn(self.load_order_book, client, messageHash, symbol, limit)
|
515
|
+
self.spawn(self.load_order_book, client, messageHash, symbol, limit, {})
|
515
516
|
storedOrderBook.cache.append(data)
|
516
517
|
return
|
517
518
|
elif nonce >= deltaEnd:
|
@@ -924,7 +925,8 @@ class kucoin(ccxt.async_support.kucoin):
|
|
924
925
|
#
|
925
926
|
topic = self.safe_string(message, 'topic')
|
926
927
|
if topic == '/market/ticker:all':
|
927
|
-
|
928
|
+
self.handle_ticker(client, message)
|
929
|
+
return
|
928
930
|
subject = self.safe_string(message, 'subject')
|
929
931
|
methods = {
|
930
932
|
'trade.l2update': self.handle_order_book,
|
@@ -938,10 +940,8 @@ class kucoin(ccxt.async_support.kucoin):
|
|
938
940
|
'stopOrder': self.handle_order,
|
939
941
|
}
|
940
942
|
method = self.safe_value(methods, subject)
|
941
|
-
if method is None:
|
942
|
-
|
943
|
-
else:
|
944
|
-
return method(client, message)
|
943
|
+
if method is not None:
|
944
|
+
method(client, message)
|
945
945
|
|
946
946
|
def ping(self, client):
|
947
947
|
# kucoin does not support built-in ws protocol-level ping-pong
|
@@ -986,4 +986,4 @@ class kucoin(ccxt.async_support.kucoin):
|
|
986
986
|
}
|
987
987
|
method = self.safe_value(methods, type)
|
988
988
|
if method is not None:
|
989
|
-
|
989
|
+
method(client, message)
|
ccxt/pro/kucoinfutures.py
CHANGED
@@ -64,18 +64,19 @@ class kucoinfutures(ccxt.async_support.kucoinfutures):
|
|
64
64
|
},
|
65
65
|
})
|
66
66
|
|
67
|
-
def negotiate(self, privateChannel, params={}):
|
67
|
+
async def negotiate(self, privateChannel, params={}):
|
68
68
|
connectId = 'private' if privateChannel else 'public'
|
69
69
|
urls = self.safe_value(self.options, 'urls', {})
|
70
70
|
spawaned = self.safe_value(urls, connectId)
|
71
71
|
if spawaned is not None:
|
72
|
-
return spawaned
|
72
|
+
return await spawaned
|
73
73
|
# we store an awaitable to the url
|
74
74
|
# so that multiple calls don't asynchronously
|
75
75
|
# fetch different urls and overwrite each other
|
76
|
-
urls[connectId] = self.spawn(self.negotiate_helper, privateChannel, params)
|
76
|
+
urls[connectId] = self.spawn(self.negotiate_helper, privateChannel, params) # we have to wait here otherwsie in c# will not work
|
77
77
|
self.options['urls'] = urls
|
78
|
-
|
78
|
+
future = urls[connectId]
|
79
|
+
return await future
|
79
80
|
|
80
81
|
async def negotiate_helper(self, privateChannel, params={}):
|
81
82
|
response = None
|
@@ -550,6 +551,8 @@ class kucoinfutures(ccxt.async_support.kucoinfutures):
|
|
550
551
|
messageHash = 'orderbook:' + symbol
|
551
552
|
storedOrderBook = self.safe_value(self.orderbooks, symbol)
|
552
553
|
nonce = self.safe_integer(storedOrderBook, 'nonce')
|
554
|
+
if storedOrderBook is None:
|
555
|
+
return # self shouldn't be needed, but for some reason sometimes self runs before handleOrderBookSubscription in c#
|
553
556
|
deltaEnd = self.safe_integer(data, 'sequence')
|
554
557
|
if nonce is None:
|
555
558
|
cacheLength = len(storedOrderBook.cache)
|
@@ -566,7 +569,7 @@ class kucoinfutures(ccxt.async_support.kucoinfutures):
|
|
566
569
|
limit = self.safe_integer(subscription, 'limit')
|
567
570
|
snapshotDelay = self.handle_option('watchOrderBook', 'snapshotDelay', 5)
|
568
571
|
if cacheLength == snapshotDelay:
|
569
|
-
self.spawn(self.load_order_book, client, messageHash, symbol, limit)
|
572
|
+
self.spawn(self.load_order_book, client, messageHash, symbol, limit, {})
|
570
573
|
storedOrderBook.cache.append(data)
|
571
574
|
return
|
572
575
|
elif nonce >= deltaEnd:
|
@@ -871,10 +874,8 @@ class kucoinfutures(ccxt.async_support.kucoinfutures):
|
|
871
874
|
'position.adjustRiskLimit': self.handle_position,
|
872
875
|
}
|
873
876
|
method = self.safe_value(methods, subject)
|
874
|
-
if method is None:
|
875
|
-
|
876
|
-
else:
|
877
|
-
return method(client, message)
|
877
|
+
if method is not None:
|
878
|
+
method(client, message)
|
878
879
|
|
879
880
|
def ping(self, client):
|
880
881
|
# kucoin does not support built-in ws protocol-level ping-pong
|
@@ -920,4 +921,4 @@ class kucoinfutures(ccxt.async_support.kucoinfutures):
|
|
920
921
|
}
|
921
922
|
method = self.safe_value(methods, type)
|
922
923
|
if method is not None:
|
923
|
-
|
924
|
+
method(client, message)
|
ccxt/pro/lbank.py
CHANGED
@@ -749,16 +749,16 @@ class lbank(ccxt.async_support.lbank):
|
|
749
749
|
orderBook = self.safe_value(message, 'depth', message)
|
750
750
|
datetime = self.safe_string(message, 'TS')
|
751
751
|
timestamp = self.parse8601(datetime)
|
752
|
-
|
753
|
-
if
|
754
|
-
|
755
|
-
self.orderbooks[symbol] =
|
752
|
+
orderbook = self.safe_value(self.orderbooks, symbol)
|
753
|
+
if orderbook is None:
|
754
|
+
orderbook = self.order_book({})
|
755
|
+
self.orderbooks[symbol] = orderbook
|
756
756
|
snapshot = self.parse_order_book(orderBook, symbol, timestamp, 'bids', 'asks')
|
757
|
-
|
757
|
+
orderbook.reset(snapshot)
|
758
758
|
messageHash = 'orderbook:' + symbol
|
759
|
-
client.resolve(
|
759
|
+
client.resolve(orderbook, messageHash)
|
760
760
|
messageHash = 'fetchOrderbook:' + symbol
|
761
|
-
client.resolve(
|
761
|
+
client.resolve(orderbook, messageHash)
|
762
762
|
|
763
763
|
def handle_error_message(self, client, message):
|
764
764
|
#
|
@@ -786,7 +786,8 @@ class lbank(ccxt.async_support.lbank):
|
|
786
786
|
def handle_message(self, client, message):
|
787
787
|
status = self.safe_string(message, 'status')
|
788
788
|
if status == 'error':
|
789
|
-
|
789
|
+
self.handle_error_message(client, message)
|
790
|
+
return
|
790
791
|
type = self.safe_string_2(message, 'type', 'action')
|
791
792
|
if type == 'ping':
|
792
793
|
self.spawn(self.handle_ping, client, message)
|
@@ -800,8 +801,7 @@ class lbank(ccxt.async_support.lbank):
|
|
800
801
|
}
|
801
802
|
handler = self.safe_value(handlers, type)
|
802
803
|
if handler is not None:
|
803
|
-
|
804
|
-
return message
|
804
|
+
handler(client, message)
|
805
805
|
|
806
806
|
async def authenticate(self, params={}):
|
807
807
|
# when we implement more private streams, we need to refactor the authentication
|
ccxt/pro/luno.py
CHANGED
@@ -191,21 +191,21 @@ class luno(ccxt.async_support.luno):
|
|
191
191
|
symbol = subscription['symbol']
|
192
192
|
messageHash = 'orderbook:' + symbol
|
193
193
|
timestamp = self.safe_string(message, 'timestamp')
|
194
|
-
|
195
|
-
if
|
196
|
-
|
197
|
-
self.orderbooks[symbol] =
|
194
|
+
orderbook = self.safe_value(self.orderbooks, symbol)
|
195
|
+
if orderbook is None:
|
196
|
+
orderbook = self.indexed_order_book({})
|
197
|
+
self.orderbooks[symbol] = orderbook
|
198
198
|
asks = self.safe_value(message, 'asks')
|
199
199
|
if asks is not None:
|
200
200
|
snapshot = self.custom_parse_order_book(message, symbol, timestamp, 'bids', 'asks', 'price', 'volume', 'id')
|
201
|
-
|
201
|
+
orderbook.reset(snapshot)
|
202
202
|
else:
|
203
|
-
self.handle_delta(
|
204
|
-
|
205
|
-
|
203
|
+
self.handle_delta(orderbook, message)
|
204
|
+
orderbook['timestamp'] = timestamp
|
205
|
+
orderbook['datetime'] = self.iso8601(timestamp)
|
206
206
|
nonce = self.safe_integer(message, 'sequence')
|
207
|
-
|
208
|
-
client.resolve(
|
207
|
+
orderbook['nonce'] = nonce
|
208
|
+
client.resolve(orderbook, messageHash)
|
209
209
|
|
210
210
|
def custom_parse_order_book(self, orderbook, symbol, timestamp=None, bidsKey='bids', asksKey: IndexType = 'asks', priceKey: IndexType = 'price', amountKey: IndexType = 'volume', countOrIdKey: IndexType = 2):
|
211
211
|
bids = self.parse_bids_asks(self.safe_value(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey)
|
@@ -291,9 +291,8 @@ class luno(ccxt.async_support.luno):
|
|
291
291
|
deleteUpdate = self.safe_value(message, 'delete_update')
|
292
292
|
if deleteUpdate is not None:
|
293
293
|
orderId = self.safe_string(deleteUpdate, 'order_id')
|
294
|
-
asksOrderSide.storeArray(0, 0, orderId)
|
295
|
-
bidsOrderSide.storeArray(0, 0, orderId)
|
296
|
-
return message
|
294
|
+
asksOrderSide.storeArray([0, 0, orderId])
|
295
|
+
bidsOrderSide.storeArray([0, 0, orderId])
|
297
296
|
|
298
297
|
def handle_message(self, client: Client, message):
|
299
298
|
if message == '':
|
@@ -303,4 +302,3 @@ class luno(ccxt.async_support.luno):
|
|
303
302
|
for j in range(0, len(handlers)):
|
304
303
|
handler = handlers[j]
|
305
304
|
handler(client, message, subscriptions[0])
|
306
|
-
return message
|
ccxt/pro/mexc.py
CHANGED
@@ -1048,7 +1048,7 @@ class mexc(ccxt.async_support.mexc):
|
|
1048
1048
|
#
|
1049
1049
|
msg = self.safe_string(message, 'msg')
|
1050
1050
|
if msg == 'PONG':
|
1051
|
-
|
1051
|
+
self.handle_pong(client, message)
|
1052
1052
|
elif msg.find('@') > -1:
|
1053
1053
|
parts = msg.split('@')
|
1054
1054
|
channel = self.safe_string(parts, 1)
|
@@ -1066,7 +1066,8 @@ class mexc(ccxt.async_support.mexc):
|
|
1066
1066
|
client.reject(error)
|
1067
1067
|
return
|
1068
1068
|
if 'msg' in message:
|
1069
|
-
|
1069
|
+
self.handle_subscription_status(client, message)
|
1070
|
+
return
|
1070
1071
|
c = self.safe_string(message, 'c')
|
1071
1072
|
channel = None
|
1072
1073
|
if c is None:
|
ccxt/pro/ndax.py
CHANGED
@@ -370,12 +370,12 @@ class ndax(ccxt.async_support.ndax):
|
|
370
370
|
firstBidAsk = self.safe_value(payload, 0, [])
|
371
371
|
marketId = self.safe_string(firstBidAsk, 7)
|
372
372
|
if marketId is None:
|
373
|
-
return
|
373
|
+
return
|
374
374
|
market = self.safe_market(marketId)
|
375
375
|
symbol = market['symbol']
|
376
376
|
orderbook = self.safe_value(self.orderbooks, symbol)
|
377
377
|
if orderbook is None:
|
378
|
-
return
|
378
|
+
return
|
379
379
|
timestamp = None
|
380
380
|
nonce = None
|
381
381
|
for i in range(0, len(payload)):
|
@@ -460,10 +460,8 @@ class ndax(ccxt.async_support.ndax):
|
|
460
460
|
subscription = self.safe_value(subscriptionsById, id)
|
461
461
|
if subscription is not None:
|
462
462
|
method = self.safe_value(subscription, 'method')
|
463
|
-
if method is None:
|
464
|
-
|
465
|
-
else:
|
466
|
-
return method(client, message, subscription)
|
463
|
+
if method is not None:
|
464
|
+
method(client, message, subscription)
|
467
465
|
|
468
466
|
def handle_message(self, client: Client, message):
|
469
467
|
#
|
@@ -490,7 +488,7 @@ class ndax(ccxt.async_support.ndax):
|
|
490
488
|
#
|
491
489
|
payload = self.safe_string(message, 'o')
|
492
490
|
if payload is None:
|
493
|
-
return
|
491
|
+
return
|
494
492
|
message['o'] = json.loads(payload)
|
495
493
|
methods = {
|
496
494
|
'SubscribeLevel2': self.handle_subscription_status,
|
@@ -504,7 +502,5 @@ class ndax(ccxt.async_support.ndax):
|
|
504
502
|
}
|
505
503
|
event = self.safe_string(message, 'n')
|
506
504
|
method = self.safe_value(methods, event)
|
507
|
-
if method is None:
|
508
|
-
|
509
|
-
else:
|
510
|
-
return method(client, message)
|
505
|
+
if method is not None:
|
506
|
+
method(client, message)
|
ccxt/pro/okcoin.py
CHANGED
@@ -452,7 +452,7 @@ class okcoin(ccxt.async_support.okcoin):
|
|
452
452
|
],
|
453
453
|
}
|
454
454
|
self.spawn(self.watch, url, messageHash, request, messageHash, future)
|
455
|
-
return
|
455
|
+
return future
|
456
456
|
|
457
457
|
async def watch_balance(self, params={}) -> Balances:
|
458
458
|
"""
|
@@ -662,7 +662,8 @@ class okcoin(ccxt.async_support.okcoin):
|
|
662
662
|
# }
|
663
663
|
#
|
664
664
|
if message == 'pong':
|
665
|
-
|
665
|
+
self.handle_pong(client, message)
|
666
|
+
return
|
666
667
|
table = self.safe_string(message, 'table')
|
667
668
|
if table is None:
|
668
669
|
event = self.safe_string(message, 'event')
|
@@ -674,10 +675,8 @@ class okcoin(ccxt.async_support.okcoin):
|
|
674
675
|
'subscribe': self.handle_subscription_status,
|
675
676
|
}
|
676
677
|
method = self.safe_value(methods, event)
|
677
|
-
if method is None:
|
678
|
-
|
679
|
-
else:
|
680
|
-
return method(client, message)
|
678
|
+
if method is not None:
|
679
|
+
method(client, message)
|
681
680
|
else:
|
682
681
|
parts = table.split('/')
|
683
682
|
name = self.safe_string(parts, 1)
|
@@ -695,7 +694,5 @@ class okcoin(ccxt.async_support.okcoin):
|
|
695
694
|
method = self.safe_value(methods, name)
|
696
695
|
if name.find('candle') >= 0:
|
697
696
|
method = self.handle_ohlcv
|
698
|
-
if method is None:
|
699
|
-
|
700
|
-
else:
|
701
|
-
return method(client, message)
|
697
|
+
if method is not None:
|
698
|
+
method(client, message)
|
ccxt/pro/okx.py
CHANGED
@@ -710,7 +710,7 @@ class okx(ccxt.async_support.okx):
|
|
710
710
|
}
|
711
711
|
message = self.extend(request, params)
|
712
712
|
self.watch(url, messageHash, message, messageHash)
|
713
|
-
return future
|
713
|
+
return await future
|
714
714
|
|
715
715
|
async def watch_balance(self, params={}) -> Balances:
|
716
716
|
"""
|
@@ -1453,7 +1453,8 @@ class okx(ccxt.async_support.okx):
|
|
1453
1453
|
#
|
1454
1454
|
#
|
1455
1455
|
if message == 'pong':
|
1456
|
-
|
1456
|
+
self.handle_pong(client, message)
|
1457
|
+
return
|
1457
1458
|
# table = self.safe_string(message, 'table')
|
1458
1459
|
# if table is None:
|
1459
1460
|
event = self.safe_string_2(message, 'event', 'op')
|
@@ -1471,10 +1472,8 @@ class okx(ccxt.async_support.okx):
|
|
1471
1472
|
'mass-cancel': self.handle_cancel_all_orders,
|
1472
1473
|
}
|
1473
1474
|
method = self.safe_value(methods, event)
|
1474
|
-
if method is None:
|
1475
|
-
|
1476
|
-
else:
|
1477
|
-
return method(client, message)
|
1475
|
+
if method is not None:
|
1476
|
+
method(client, message)
|
1478
1477
|
else:
|
1479
1478
|
arg = self.safe_value(message, 'arg', {})
|
1480
1479
|
channel = self.safe_string(arg, 'channel')
|
@@ -1499,7 +1498,5 @@ class okx(ccxt.async_support.okx):
|
|
1499
1498
|
if method is None:
|
1500
1499
|
if channel.find('candle') == 0:
|
1501
1500
|
self.handle_ohlcv(client, message)
|
1502
|
-
else:
|
1503
|
-
return message
|
1504
1501
|
else:
|
1505
|
-
|
1502
|
+
method(client, message)
|
ccxt/pro/onetrading.py
CHANGED
@@ -355,22 +355,22 @@ class onetrading(ccxt.async_support.onetrading):
|
|
355
355
|
dateTime = self.safe_string(message, 'time')
|
356
356
|
timestamp = self.parse8601(dateTime)
|
357
357
|
channel = 'book:' + symbol
|
358
|
-
|
359
|
-
if
|
360
|
-
|
358
|
+
orderbook = self.safe_value(self.orderbooks, symbol)
|
359
|
+
if orderbook is None:
|
360
|
+
orderbook = self.order_book({})
|
361
361
|
if type == 'ORDER_BOOK_SNAPSHOT':
|
362
362
|
snapshot = self.parse_order_book(message, symbol, timestamp, 'bids', 'asks')
|
363
|
-
|
363
|
+
orderbook.reset(snapshot)
|
364
364
|
elif type == 'ORDER_BOOK_UPDATE':
|
365
365
|
changes = self.safe_value(message, 'changes', [])
|
366
|
-
self.handle_deltas(
|
366
|
+
self.handle_deltas(orderbook, changes)
|
367
367
|
else:
|
368
368
|
raise NotSupported(self.id + ' watchOrderBook() did not recognize message type ' + type)
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
self.orderbooks[symbol] =
|
373
|
-
client.resolve(
|
369
|
+
orderbook['nonce'] = timestamp
|
370
|
+
orderbook['timestamp'] = timestamp
|
371
|
+
orderbook['datetime'] = self.iso8601(timestamp)
|
372
|
+
self.orderbooks[symbol] = orderbook
|
373
|
+
client.resolve(orderbook, channel)
|
374
374
|
|
375
375
|
def handle_delta(self, orderbook, delta):
|
376
376
|
#
|
@@ -938,13 +938,14 @@ class onetrading(ccxt.async_support.onetrading):
|
|
938
938
|
status = self.parse_ws_order_status(updateType)
|
939
939
|
if updateType == 'ORDER_CLOSED' and filled == 0:
|
940
940
|
status = 'canceled'
|
941
|
-
|
941
|
+
orderObject = {
|
942
942
|
'id': orderId,
|
943
943
|
'symbol': symbol,
|
944
944
|
'status': status,
|
945
945
|
'timestamp': self.parse8601(datetime),
|
946
946
|
'datetime': datetime,
|
947
|
-
}
|
947
|
+
}
|
948
|
+
orders.append(orderObject)
|
948
949
|
else:
|
949
950
|
parsed = self.parse_order(update)
|
950
951
|
symbol = self.safe_string(parsed, 'symbol', '')
|
@@ -1162,7 +1163,8 @@ class onetrading(ccxt.async_support.onetrading):
|
|
1162
1163
|
def handle_message(self, client: Client, message):
|
1163
1164
|
error = self.safe_value(message, 'error')
|
1164
1165
|
if error is not None:
|
1165
|
-
|
1166
|
+
self.handle_error_message(client, message)
|
1167
|
+
return
|
1166
1168
|
type = self.safe_value(message, 'type')
|
1167
1169
|
handlers = {
|
1168
1170
|
'ORDER_BOOK_UPDATE': self.handle_order_book,
|
@@ -1192,8 +1194,7 @@ class onetrading(ccxt.async_support.onetrading):
|
|
1192
1194
|
}
|
1193
1195
|
handler = self.safe_value(handlers, type)
|
1194
1196
|
if handler is not None:
|
1195
|
-
|
1196
|
-
raise NotSupported(self.id + ' no handler found for self message ' + self.json(message))
|
1197
|
+
handler(client, message)
|
1197
1198
|
|
1198
1199
|
def handle_price_point_updates(self, client: Client, message):
|
1199
1200
|
#
|
ccxt/pro/p2b.py
CHANGED
@@ -349,13 +349,15 @@ class p2b(ccxt.async_support.p2b):
|
|
349
349
|
bid = self.safe_value(bids, i)
|
350
350
|
price = self.safe_number(bid, 0)
|
351
351
|
amount = self.safe_number(bid, 1)
|
352
|
-
orderbook['bids']
|
352
|
+
bookSide = orderbook['bids']
|
353
|
+
bookSide.store(price, amount)
|
353
354
|
if asks is not None:
|
354
355
|
for i in range(0, len(asks)):
|
355
356
|
ask = self.safe_value(asks, i)
|
356
357
|
price = self.safe_number(ask, 0)
|
357
358
|
amount = self.safe_number(ask, 1)
|
358
|
-
orderbook['asks']
|
359
|
+
bookside = orderbook['asks']
|
360
|
+
bookside.store(price, amount)
|
359
361
|
orderbook['symbol'] = symbol
|
360
362
|
client.resolve(orderbook, messageHash)
|
361
363
|
|
@@ -376,7 +378,7 @@ class p2b(ccxt.async_support.p2b):
|
|
376
378
|
}
|
377
379
|
endpoint = self.safe_value(methods, method)
|
378
380
|
if endpoint is not None:
|
379
|
-
|
381
|
+
endpoint(client, message)
|
380
382
|
|
381
383
|
def handle_error_message(self, client: Client, message):
|
382
384
|
error = self.safe_string(message, 'error')
|
ccxt/pro/phemex.py
CHANGED
@@ -603,13 +603,13 @@ class phemex(ccxt.async_support.phemex):
|
|
603
603
|
limit = ohlcv.getLimit(symbol, limit)
|
604
604
|
return self.filter_by_since_limit(ohlcv, since, limit, 0, True)
|
605
605
|
|
606
|
-
def
|
606
|
+
def custom_handle_delta(self, bookside, delta, market=None):
|
607
607
|
bidAsk = self.custom_parse_bid_ask(delta, 0, 1, market)
|
608
608
|
bookside.storeArray(bidAsk)
|
609
609
|
|
610
|
-
def
|
610
|
+
def custom_handle_deltas(self, bookside, deltas, market=None):
|
611
611
|
for i in range(0, len(deltas)):
|
612
|
-
self.
|
612
|
+
self.custom_handle_delta(bookside, deltas[i], market)
|
613
613
|
|
614
614
|
def handle_order_book(self, client: Client, message):
|
615
615
|
#
|
@@ -677,8 +677,8 @@ class phemex(ccxt.async_support.phemex):
|
|
677
677
|
changes = self.safe_value_2(message, 'book', 'orderbook_p', {})
|
678
678
|
asks = self.safe_value(changes, 'asks', [])
|
679
679
|
bids = self.safe_value(changes, 'bids', [])
|
680
|
-
self.
|
681
|
-
self.
|
680
|
+
self.custom_handle_deltas(orderbook['asks'], asks, market)
|
681
|
+
self.custom_handle_deltas(orderbook['bids'], bids, market)
|
682
682
|
orderbook['nonce'] = nonce
|
683
683
|
orderbook['timestamp'] = timestamp
|
684
684
|
orderbook['datetime'] = self.iso8601(timestamp)
|
@@ -1343,16 +1343,21 @@ class phemex(ccxt.async_support.phemex):
|
|
1343
1343
|
method = client.subscriptions[id]
|
1344
1344
|
del client.subscriptions[id]
|
1345
1345
|
if method is not True:
|
1346
|
-
|
1346
|
+
method(client, message)
|
1347
|
+
return
|
1347
1348
|
methodName = self.safe_string(message, 'method', '')
|
1348
1349
|
if ('market24h' in message) or ('spot_market24h' in message) or (methodName.find('perp_market24h_pack_p') >= 0):
|
1349
|
-
|
1350
|
+
self.handle_ticker(client, message)
|
1351
|
+
return
|
1350
1352
|
elif ('trades' in message) or ('trades_p' in message):
|
1351
|
-
|
1353
|
+
self.handle_trades(client, message)
|
1354
|
+
return
|
1352
1355
|
elif ('kline' in message) or ('kline_p' in message):
|
1353
|
-
|
1356
|
+
self.handle_ohlcv(client, message)
|
1357
|
+
return
|
1354
1358
|
elif ('book' in message) or ('orderbook_p' in message):
|
1355
|
-
|
1359
|
+
self.handle_order_book(client, message)
|
1360
|
+
return
|
1356
1361
|
if ('orders' in message) or ('orders_p' in message):
|
1357
1362
|
orders = self.safe_value_2(message, 'orders', 'orders_p', {})
|
1358
1363
|
self.handle_orders(client, orders)
|
@@ -1428,4 +1433,4 @@ class phemex(ccxt.async_support.phemex):
|
|
1428
1433
|
client.subscriptions[subscriptionHash] = self.handle_authenticate
|
1429
1434
|
future = self.watch(url, messageHash, message)
|
1430
1435
|
client.subscriptions[messageHash] = future
|
1431
|
-
return
|
1436
|
+
return future
|