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.
- ccxt/__init__.py +1 -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 +16 -15
- 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 +6 -6
- ccxt/async_support/bitflyer.py +5 -5
- ccxt/async_support/bitforex.py +1 -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 +6 -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 +4 -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 +10 -10
- 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 +42 -4
- ccxt/async_support/krakenfutures.py +5 -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 +2 -2
- 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 +11 -10
- 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 +1 -1
- ccxt/async_support/probit.py +5 -5
- ccxt/async_support/timex.py +1 -1
- 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 +5 -5
- 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 +67 -40
- ccxt/base/types.py +10 -0
- ccxt/bigone.py +25 -5
- ccxt/binance.py +16 -15
- 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 +6 -6
- ccxt/bitflyer.py +5 -5
- ccxt/bitforex.py +1 -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 +6 -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 +4 -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 +10 -10
- ccxt/huobijp.py +4 -4
- ccxt/idex.py +2 -2
- ccxt/independentreserve.py +2 -2
- ccxt/indodax.py +2 -2
- ccxt/kraken.py +42 -4
- ccxt/krakenfutures.py +5 -5
- ccxt/kucoin.py +8 -8
- ccxt/kucoinfutures.py +4 -4
- ccxt/kuna.py +2 -2
- ccxt/latoken.py +3 -3
- ccxt/lbank.py +2 -2
- 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 +11 -10
- 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 +1 -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 +1 -1
- ccxt/tokocrypto.py +4 -4
- ccxt/upbit.py +2 -2
- ccxt/wavesexchange.py +4 -3
- ccxt/wazirx.py +1 -1
- ccxt/whitebit.py +5 -5
- ccxt/woo.py +6 -6
- ccxt/yobit.py +41 -2
- ccxt/zaif.py +2 -2
- ccxt/zonda.py +4 -4
- {ccxt-4.2.31.dist-info → ccxt-4.2.34.dist-info}/METADATA +9 -8
- ccxt-4.2.34.dist-info/RECORD +438 -0
- ccxt-4.2.31.dist-info/RECORD +0 -438
- {ccxt-4.2.31.dist-info → ccxt-4.2.34.dist-info}/WHEEL +0 -0
- {ccxt-4.2.31.dist-info → ccxt-4.2.34.dist-info}/top_level.txt +0 -0
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
|
ccxt/pro/poloniex.py
CHANGED
@@ -974,13 +974,15 @@ class poloniex(ccxt.async_support.poloniex):
|
|
974
974
|
bid = self.safe_value(bids, j)
|
975
975
|
price = self.safe_number(bid, 0)
|
976
976
|
amount = self.safe_number(bid, 1)
|
977
|
-
orderbook['bids']
|
977
|
+
bidsSide = orderbook['bids']
|
978
|
+
bidsSide.store(price, amount)
|
978
979
|
if asks is not None:
|
979
980
|
for j in range(0, len(asks)):
|
980
981
|
ask = self.safe_value(asks, j)
|
981
982
|
price = self.safe_number(ask, 0)
|
982
983
|
amount = self.safe_number(ask, 1)
|
983
|
-
orderbook['asks']
|
984
|
+
asksSide = orderbook['asks']
|
985
|
+
asksSide.store(price, amount)
|
984
986
|
orderbook['symbol'] = symbol
|
985
987
|
orderbook['timestamp'] = timestamp
|
986
988
|
orderbook['datetime'] = self.iso8601(timestamp)
|
@@ -1104,12 +1106,12 @@ class poloniex(ccxt.async_support.poloniex):
|
|
1104
1106
|
if orderId == '0':
|
1105
1107
|
self.handle_error_message(client, item)
|
1106
1108
|
else:
|
1107
|
-
|
1109
|
+
self.handle_order_request(client, message)
|
1108
1110
|
else:
|
1109
1111
|
data = self.safe_value(message, 'data', [])
|
1110
1112
|
dataLength = len(data)
|
1111
1113
|
if dataLength > 0:
|
1112
|
-
|
1114
|
+
method(client, message)
|
1113
1115
|
|
1114
1116
|
def handle_error_message(self, client: Client, message):
|
1115
1117
|
#
|
ccxt/pro/poloniexfutures.py
CHANGED
@@ -68,17 +68,20 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
|
|
68
68
|
},
|
69
69
|
})
|
70
70
|
|
71
|
-
def negotiate(self, privateChannel, params={}):
|
71
|
+
async def negotiate(self, privateChannel, params={}):
|
72
72
|
connectId = 'private' if privateChannel else 'public'
|
73
73
|
urls = self.safe_value(self.options, 'urls', {})
|
74
74
|
if connectId in urls:
|
75
|
-
return urls[connectId]
|
75
|
+
# return urls[connectId]
|
76
|
+
storedFuture = urls[connectId]
|
77
|
+
return await storedFuture
|
76
78
|
# we store an awaitable to the url
|
77
79
|
# so that multiple calls don't asynchronously
|
78
80
|
# fetch different urls and overwrite each other
|
79
81
|
urls[connectId] = self.spawn(self.negotiate_helper, privateChannel, params)
|
80
82
|
self.options['urls'] = urls
|
81
|
-
|
83
|
+
future = urls[connectId]
|
84
|
+
return await future
|
82
85
|
|
83
86
|
async def negotiate_helper(self, privateChannel, params={}):
|
84
87
|
response = None
|
@@ -685,7 +688,7 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
|
|
685
688
|
messageHash = self.safe_string(message, 'topic')
|
686
689
|
subject = self.safe_string(message, 'subject')
|
687
690
|
if subject == 'received':
|
688
|
-
return
|
691
|
+
return
|
689
692
|
# At the time of writting self, there is no implementation to easily convert each order into the orderbook so raw messages are returned
|
690
693
|
client.resolve(message, messageHash)
|
691
694
|
|
@@ -703,8 +706,9 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
|
|
703
706
|
topic = self.safe_string(message, 'topic')
|
704
707
|
isSnapshot = topic.find('Depth') >= 0
|
705
708
|
if isSnapshot:
|
706
|
-
|
707
|
-
|
709
|
+
self.hande_l2_snapshot(client, message)
|
710
|
+
return
|
711
|
+
self.handle_l2_order_book(client, message)
|
708
712
|
|
709
713
|
def handle_l2_order_book(self, client: Client, message):
|
710
714
|
#
|
@@ -740,7 +744,7 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
|
|
740
744
|
snapshotDelay = self.handle_option('watchOrderBook', 'snapshotDelay', 5)
|
741
745
|
if cacheLength == snapshotDelay:
|
742
746
|
limit = 0
|
743
|
-
self.spawn(self.load_order_book, client, messageHash, symbol, limit)
|
747
|
+
self.spawn(self.load_order_book, client, messageHash, symbol, limit, {})
|
744
748
|
orderBook.cache.append(data)
|
745
749
|
return
|
746
750
|
try:
|
@@ -920,7 +924,7 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
|
|
920
924
|
}
|
921
925
|
method = self.safe_value(methods, subject)
|
922
926
|
if method is not None:
|
923
|
-
|
927
|
+
method(client, message)
|
924
928
|
|
925
929
|
def ping(self, client: Client):
|
926
930
|
id = str(self.request_id())
|
@@ -955,7 +959,7 @@ class poloniexfutures(ccxt.async_support.poloniexfutures):
|
|
955
959
|
}
|
956
960
|
method = self.safe_value(methods, type)
|
957
961
|
if method is not None:
|
958
|
-
|
962
|
+
method(client, message)
|
959
963
|
|
960
964
|
def handle_authenticate(self, client, message):
|
961
965
|
#
|
ccxt/pro/probit.py
CHANGED
@@ -428,17 +428,17 @@ class probit(ccxt.async_support.probit):
|
|
428
428
|
symbol = self.safe_symbol(marketId)
|
429
429
|
dataBySide = self.group_by(orderBook, 'side')
|
430
430
|
messageHash = 'orderbook:' + symbol
|
431
|
-
|
432
|
-
if
|
433
|
-
|
434
|
-
self.orderbooks[symbol] =
|
431
|
+
orderbook = self.safe_value(self.orderbooks, symbol)
|
432
|
+
if orderbook is None:
|
433
|
+
orderbook = self.order_book({})
|
434
|
+
self.orderbooks[symbol] = orderbook
|
435
435
|
reset = self.safe_bool(message, 'reset', False)
|
436
436
|
if reset:
|
437
437
|
snapshot = self.parse_order_book(dataBySide, symbol, None, 'buy', 'sell', 'price', 'quantity')
|
438
|
-
|
438
|
+
orderbook.reset(snapshot)
|
439
439
|
else:
|
440
|
-
self.handle_delta(
|
441
|
-
client.resolve(
|
440
|
+
self.handle_delta(orderbook, dataBySide)
|
441
|
+
client.resolve(orderbook, messageHash)
|
442
442
|
|
443
443
|
def handle_bid_asks(self, bookSide, bidAsks):
|
444
444
|
for i in range(0, len(bidAsks)):
|
@@ -505,10 +505,12 @@ class probit(ccxt.async_support.probit):
|
|
505
505
|
#
|
506
506
|
errorCode = self.safe_string(message, 'errorCode')
|
507
507
|
if errorCode is not None:
|
508
|
-
|
508
|
+
self.handle_error_message(client, message)
|
509
|
+
return
|
509
510
|
type = self.safe_string(message, 'type')
|
510
511
|
if type == 'authorization':
|
511
|
-
|
512
|
+
self.handle_authenticate(client, message)
|
513
|
+
return
|
512
514
|
handlers = {
|
513
515
|
'marketdata': self.handle_market_data,
|
514
516
|
'balance': self.handle_balance,
|
@@ -519,7 +521,8 @@ class probit(ccxt.async_support.probit):
|
|
519
521
|
channel = self.safe_string(message, 'channel')
|
520
522
|
handler = self.safe_value(handlers, channel)
|
521
523
|
if handler is not None:
|
522
|
-
|
524
|
+
handler(client, message)
|
525
|
+
return
|
523
526
|
error = NotSupported(self.id + ' handleMessage: unknown message: ' + self.json(message))
|
524
527
|
client.reject(error)
|
525
528
|
|
@@ -530,7 +533,7 @@ class probit(ccxt.async_support.probit):
|
|
530
533
|
expires = self.safe_integer(self.options, 'expires', 0)
|
531
534
|
future = self.safe_value(client.subscriptions, messageHash)
|
532
535
|
if (future is None) or (self.milliseconds() > expires):
|
533
|
-
response = await self.
|
536
|
+
response = await self.sign_in()
|
534
537
|
#
|
535
538
|
# {
|
536
539
|
# "access_token": "0ttDv/2hTTn3bLi8GP1gKaneiEQ6+0hOBenPrxNQt2s=",
|
@@ -545,4 +548,4 @@ class probit(ccxt.async_support.probit):
|
|
545
548
|
}
|
546
549
|
future = self.watch(url, messageHash, self.extend(request, params))
|
547
550
|
client.subscriptions[messageHash] = future
|
548
|
-
return
|
551
|
+
return future
|