ccxt 4.3.98 → 4.4.2
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.
- package/README.md +4 -4
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +69 -0
- package/dist/cjs/src/binance.js +78 -8
- package/dist/cjs/src/bitget.js +3 -2
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/currencycom.js +1 -2
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/mexc.js +69 -1
- package/dist/cjs/src/pro/binance.js +3 -63
- package/dist/cjs/src/pro/bitget.js +1 -9
- package/dist/cjs/src/pro/bitmex.js +11 -1
- package/dist/cjs/src/pro/bybit.js +2 -54
- package/dist/cjs/src/pro/cryptocom.js +2 -40
- package/dist/cjs/src/pro/gate.js +1 -9
- package/dist/cjs/src/pro/hyperliquid.js +232 -11
- package/dist/cjs/src/pro/kucoin.js +2 -59
- package/dist/cjs/src/pro/kucoinfutures.js +139 -1
- package/dist/cjs/src/pro/okx.js +8 -36
- package/dist/cjs/src/xt.js +1 -1
- package/examples/js/cli.js +9 -5
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +70 -1
- package/js/src/base/types.d.ts +5 -4
- package/js/src/binance.js +78 -8
- package/js/src/bitget.js +3 -2
- package/js/src/cryptocom.js +1 -1
- package/js/src/currencycom.js +1 -2
- package/js/src/gate.js +1 -0
- package/js/src/htx.js +1 -1
- package/js/src/mexc.js +69 -1
- package/js/src/pro/binance.d.ts +0 -1
- package/js/src/pro/binance.js +4 -64
- package/js/src/pro/bitget.js +1 -9
- package/js/src/pro/bitmex.js +11 -1
- package/js/src/pro/bybit.d.ts +1 -2
- package/js/src/pro/bybit.js +3 -55
- package/js/src/pro/cryptocom.d.ts +1 -2
- package/js/src/pro/cryptocom.js +3 -41
- package/js/src/pro/gate.js +2 -10
- package/js/src/pro/hyperliquid.d.ts +10 -1
- package/js/src/pro/hyperliquid.js +232 -11
- package/js/src/pro/kucoin.d.ts +0 -1
- package/js/src/pro/kucoin.js +3 -60
- package/js/src/pro/kucoinfutures.d.ts +7 -1
- package/js/src/pro/kucoinfutures.js +139 -1
- package/js/src/pro/okx.js +9 -37
- package/js/src/xt.js +1 -1
- package/package.json +1 -1
|
@@ -1016,7 +1016,7 @@ class bybit extends bybit$1 {
|
|
|
1016
1016
|
messageHashes.push(messageHash);
|
|
1017
1017
|
subMessageHashes.push('trade:' + symbol);
|
|
1018
1018
|
}
|
|
1019
|
-
return await this.unWatchTopics(url, '
|
|
1019
|
+
return await this.unWatchTopics(url, 'trades', symbols, messageHashes, subMessageHashes, topics, params);
|
|
1020
1020
|
}
|
|
1021
1021
|
async unWatchTrades(symbol, params = {}) {
|
|
1022
1022
|
/**
|
|
@@ -2483,65 +2483,13 @@ class bybit extends bybit$1 {
|
|
|
2483
2483
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
2484
2484
|
const unsubHash = messageHashes[j];
|
|
2485
2485
|
const subHash = subMessageHashes[j];
|
|
2486
|
-
|
|
2487
|
-
delete client.subscriptions[unsubHash];
|
|
2488
|
-
}
|
|
2489
|
-
if (subHash in client.subscriptions) {
|
|
2490
|
-
delete client.subscriptions[subHash];
|
|
2491
|
-
}
|
|
2492
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + messageHash);
|
|
2493
|
-
client.reject(error, subHash);
|
|
2494
|
-
client.resolve(true, unsubHash);
|
|
2486
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
2495
2487
|
}
|
|
2496
2488
|
this.cleanCache(subscription);
|
|
2497
2489
|
}
|
|
2498
2490
|
}
|
|
2499
2491
|
return message;
|
|
2500
2492
|
}
|
|
2501
|
-
cleanCache(subscription) {
|
|
2502
|
-
const topic = this.safeString(subscription, 'topic');
|
|
2503
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
2504
|
-
const symbolsLength = symbols.length;
|
|
2505
|
-
if (topic === 'ohlcv') {
|
|
2506
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
2507
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
2508
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
2509
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
2510
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
2511
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
else if (symbolsLength > 0) {
|
|
2515
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
2516
|
-
const symbol = symbols[i];
|
|
2517
|
-
if (topic === 'trade') {
|
|
2518
|
-
delete this.trades[symbol];
|
|
2519
|
-
}
|
|
2520
|
-
else if (topic === 'orderbook') {
|
|
2521
|
-
delete this.orderbooks[symbol];
|
|
2522
|
-
}
|
|
2523
|
-
else if (topic === 'ticker') {
|
|
2524
|
-
delete this.tickers[symbol];
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
else {
|
|
2529
|
-
if (topic === 'myTrades') {
|
|
2530
|
-
// don't reset this.myTrades directly here
|
|
2531
|
-
// because in c# we need to use a different object
|
|
2532
|
-
const keys = Object.keys(this.myTrades);
|
|
2533
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2534
|
-
delete this.myTrades[keys[i]];
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
else if (topic === 'orders') {
|
|
2538
|
-
const orderSymbols = Object.keys(this.orders);
|
|
2539
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
2540
|
-
delete this.orders[orderSymbols[i]];
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
2493
|
}
|
|
2546
2494
|
|
|
2547
2495
|
module.exports = bybit;
|
|
@@ -371,7 +371,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
371
371
|
messageHashes.push('unsubscribe:trades:' + market['symbol']);
|
|
372
372
|
topics.push(currentTopic);
|
|
373
373
|
}
|
|
374
|
-
return await this.unWatchPublicMultiple('
|
|
374
|
+
return await this.unWatchPublicMultiple('trades', symbols, messageHashes, topics, topics, params);
|
|
375
375
|
}
|
|
376
376
|
handleTrades(client, message) {
|
|
377
377
|
//
|
|
@@ -1205,50 +1205,12 @@ class cryptocom extends cryptocom$1 {
|
|
|
1205
1205
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1206
1206
|
const unsubHash = messageHashes[j];
|
|
1207
1207
|
const subHash = subMessageHashes[j];
|
|
1208
|
-
|
|
1209
|
-
delete client.subscriptions[unsubHash];
|
|
1210
|
-
}
|
|
1211
|
-
if (subHash in client.subscriptions) {
|
|
1212
|
-
delete client.subscriptions[subHash];
|
|
1213
|
-
}
|
|
1214
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
1215
|
-
client.reject(error, subHash);
|
|
1216
|
-
client.resolve(true, unsubHash);
|
|
1208
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1217
1209
|
}
|
|
1218
1210
|
this.cleanCache(subscription);
|
|
1219
1211
|
}
|
|
1220
1212
|
}
|
|
1221
1213
|
}
|
|
1222
|
-
cleanCache(subscription) {
|
|
1223
|
-
const topic = this.safeString(subscription, 'topic');
|
|
1224
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1225
|
-
const symbolsLength = symbols.length;
|
|
1226
|
-
if (topic === 'ohlcv') {
|
|
1227
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1228
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1229
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1230
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1231
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1232
|
-
if (timeframe in this.ohlcvs[symbol]) {
|
|
1233
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
else if (symbolsLength > 0) {
|
|
1238
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
1239
|
-
const symbol = symbols[i];
|
|
1240
|
-
if (topic === 'trade') {
|
|
1241
|
-
delete this.trades[symbol];
|
|
1242
|
-
}
|
|
1243
|
-
else if (topic === 'orderbook') {
|
|
1244
|
-
delete this.orderbooks[symbol];
|
|
1245
|
-
}
|
|
1246
|
-
else if (topic === 'ticker') {
|
|
1247
|
-
delete this.tickers[symbol];
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
1214
|
}
|
|
1253
1215
|
|
|
1254
1216
|
module.exports = cryptocom;
|
package/dist/cjs/src/pro/gate.js
CHANGED
|
@@ -1660,15 +1660,7 @@ class gate extends gate$1 {
|
|
|
1660
1660
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1661
1661
|
const unsubHash = messageHashes[j];
|
|
1662
1662
|
const subHash = subMessageHashes[j];
|
|
1663
|
-
|
|
1664
|
-
delete client.subscriptions[unsubHash];
|
|
1665
|
-
}
|
|
1666
|
-
if (subHash in client.subscriptions) {
|
|
1667
|
-
delete client.subscriptions[subHash];
|
|
1668
|
-
}
|
|
1669
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + messageHash);
|
|
1670
|
-
client.reject(error, subHash);
|
|
1671
|
-
client.resolve(true, unsubHash);
|
|
1663
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1672
1664
|
}
|
|
1673
1665
|
this.cleanCache(subscription);
|
|
1674
1666
|
}
|
|
@@ -160,6 +160,34 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
160
160
|
const orderbook = await this.watch(url, messageHash, message, messageHash);
|
|
161
161
|
return orderbook.limit();
|
|
162
162
|
}
|
|
163
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
164
|
+
/**
|
|
165
|
+
* @method
|
|
166
|
+
* @name hyperliquid#unWatchOrderBook
|
|
167
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
168
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
169
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
170
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
171
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
172
|
+
*/
|
|
173
|
+
await this.loadMarkets();
|
|
174
|
+
const market = this.market(symbol);
|
|
175
|
+
symbol = market['symbol'];
|
|
176
|
+
const subMessageHash = 'orderbook:' + symbol;
|
|
177
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
178
|
+
const url = this.urls['api']['ws']['public'];
|
|
179
|
+
const id = this.nonce().toString();
|
|
180
|
+
const request = {
|
|
181
|
+
'id': id,
|
|
182
|
+
'method': 'unsubscribe',
|
|
183
|
+
'subscription': {
|
|
184
|
+
'type': 'l2Book',
|
|
185
|
+
'coin': market['swap'] ? market['base'] : market['id'],
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
const message = this.extend(request, params);
|
|
189
|
+
return await this.watch(url, messageHash, message, messageHash);
|
|
190
|
+
}
|
|
163
191
|
handleOrderBook(client, message) {
|
|
164
192
|
//
|
|
165
193
|
// {
|
|
@@ -234,6 +262,30 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
234
262
|
}
|
|
235
263
|
return this.tickers;
|
|
236
264
|
}
|
|
265
|
+
async unWatchTickers(symbols = undefined, params = {}) {
|
|
266
|
+
/**
|
|
267
|
+
* @method
|
|
268
|
+
* @name hyperliquid#unWatchTickers
|
|
269
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
270
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
271
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
272
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
273
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
274
|
+
*/
|
|
275
|
+
await this.loadMarkets();
|
|
276
|
+
symbols = this.marketSymbols(symbols, undefined, true);
|
|
277
|
+
const subMessageHash = 'tickers';
|
|
278
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
279
|
+
const url = this.urls['api']['ws']['public'];
|
|
280
|
+
const request = {
|
|
281
|
+
'method': 'unsubscribe',
|
|
282
|
+
'subscription': {
|
|
283
|
+
'type': 'webData2',
|
|
284
|
+
'user': '0x0000000000000000000000000000000000000000',
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
return await this.watch(url, messageHash, this.extend(request, params), messageHash);
|
|
288
|
+
}
|
|
237
289
|
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
238
290
|
/**
|
|
239
291
|
* @method
|
|
@@ -403,17 +455,17 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
403
455
|
client.resolve(trades, messageHash);
|
|
404
456
|
}
|
|
405
457
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
458
|
+
// s
|
|
459
|
+
// @method
|
|
460
|
+
// @name hyperliquid#watchTrades
|
|
461
|
+
// @description watches information on multiple trades made in a market
|
|
462
|
+
// @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
463
|
+
// @param {string} symbol unified market symbol of the market trades were made in
|
|
464
|
+
// @param {int} [since] the earliest time in ms to fetch trades for
|
|
465
|
+
// @param {int} [limit] the maximum number of trade structures to retrieve
|
|
466
|
+
// @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
467
|
+
// @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
468
|
+
//
|
|
417
469
|
await this.loadMarkets();
|
|
418
470
|
const market = this.market(symbol);
|
|
419
471
|
symbol = market['symbol'];
|
|
@@ -433,6 +485,32 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
433
485
|
}
|
|
434
486
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
435
487
|
}
|
|
488
|
+
async unWatchTrades(symbol, params = {}) {
|
|
489
|
+
/**
|
|
490
|
+
* @method
|
|
491
|
+
* @name hyperliquid#unWatchTrades
|
|
492
|
+
* @description unWatches information on multiple trades made in a market
|
|
493
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
494
|
+
* @param {string} symbol unified market symbol of the market trades were made in
|
|
495
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
496
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
497
|
+
*/
|
|
498
|
+
await this.loadMarkets();
|
|
499
|
+
const market = this.market(symbol);
|
|
500
|
+
symbol = market['symbol'];
|
|
501
|
+
const subMessageHash = 'trade:' + symbol;
|
|
502
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
503
|
+
const url = this.urls['api']['ws']['public'];
|
|
504
|
+
const request = {
|
|
505
|
+
'method': 'unsubscribe',
|
|
506
|
+
'subscription': {
|
|
507
|
+
'type': 'trades',
|
|
508
|
+
'coin': market['swap'] ? market['base'] : market['id'],
|
|
509
|
+
},
|
|
510
|
+
};
|
|
511
|
+
const message = this.extend(request, params);
|
|
512
|
+
return await this.watch(url, messageHash, message, messageHash);
|
|
513
|
+
}
|
|
436
514
|
handleTrades(client, message) {
|
|
437
515
|
//
|
|
438
516
|
// {
|
|
@@ -566,6 +644,34 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
566
644
|
}
|
|
567
645
|
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
568
646
|
}
|
|
647
|
+
async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
|
|
648
|
+
/**
|
|
649
|
+
* @method
|
|
650
|
+
* @name hyperliquid#unWatchOHLCV
|
|
651
|
+
* @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
|
|
652
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
|
|
653
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
654
|
+
* @param {string} timeframe the length of time each candle represents
|
|
655
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
656
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
657
|
+
*/
|
|
658
|
+
await this.loadMarkets();
|
|
659
|
+
const market = this.market(symbol);
|
|
660
|
+
symbol = market['symbol'];
|
|
661
|
+
const url = this.urls['api']['ws']['public'];
|
|
662
|
+
const request = {
|
|
663
|
+
'method': 'unsubscribe',
|
|
664
|
+
'subscription': {
|
|
665
|
+
'type': 'candle',
|
|
666
|
+
'coin': market['swap'] ? market['base'] : market['id'],
|
|
667
|
+
'interval': timeframe,
|
|
668
|
+
},
|
|
669
|
+
};
|
|
670
|
+
const subMessageHash = 'candles:' + timeframe + ':' + symbol;
|
|
671
|
+
const messagehash = 'unsubscribe:' + subMessageHash;
|
|
672
|
+
const message = this.extend(request, params);
|
|
673
|
+
return await this.watch(url, messagehash, message, messagehash);
|
|
674
|
+
}
|
|
569
675
|
handleOHLCV(client, message) {
|
|
570
676
|
//
|
|
571
677
|
// {
|
|
@@ -721,7 +827,121 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
721
827
|
return false;
|
|
722
828
|
}
|
|
723
829
|
}
|
|
830
|
+
handleOrderBookUnsubscription(client, subscription) {
|
|
831
|
+
//
|
|
832
|
+
// "subscription":{
|
|
833
|
+
// "type":"l2Book",
|
|
834
|
+
// "coin":"BTC",
|
|
835
|
+
// "nSigFigs":5,
|
|
836
|
+
// "mantissa":null
|
|
837
|
+
// }
|
|
838
|
+
//
|
|
839
|
+
const coin = this.safeString(subscription, 'coin');
|
|
840
|
+
const marketId = this.coinToMarketId(coin);
|
|
841
|
+
const symbol = this.safeSymbol(marketId);
|
|
842
|
+
const subMessageHash = 'orderbook:' + symbol;
|
|
843
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
844
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
845
|
+
if (symbol in this.orderbooks) {
|
|
846
|
+
delete this.orderbooks[symbol];
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
handleTradesUnsubscription(client, subscription) {
|
|
850
|
+
//
|
|
851
|
+
const coin = this.safeString(subscription, 'coin');
|
|
852
|
+
const marketId = this.coinToMarketId(coin);
|
|
853
|
+
const symbol = this.safeSymbol(marketId);
|
|
854
|
+
const subMessageHash = 'trade:' + symbol;
|
|
855
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
856
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
857
|
+
if (symbol in this.trades) {
|
|
858
|
+
delete this.trades[symbol];
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
handleTickersUnsubscription(client, subscription) {
|
|
862
|
+
//
|
|
863
|
+
const subMessageHash = 'tickers';
|
|
864
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
865
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
866
|
+
const symbols = Object.keys(this.tickers);
|
|
867
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
868
|
+
delete this.tickers[symbols[i]];
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
handleOHLCVUnsubscription(client, subscription) {
|
|
872
|
+
const coin = this.safeString(subscription, 'coin');
|
|
873
|
+
const marketId = this.coinToMarketId(coin);
|
|
874
|
+
const symbol = this.safeSymbol(marketId);
|
|
875
|
+
const interval = this.safeString(subscription, 'interval');
|
|
876
|
+
const timeframe = this.findTimeframe(interval);
|
|
877
|
+
const subMessageHash = 'candles:' + timeframe + ':' + symbol;
|
|
878
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
879
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
880
|
+
if (symbol in this.ohlcvs) {
|
|
881
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
882
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
handleSubscriptionResponse(client, message) {
|
|
887
|
+
// {
|
|
888
|
+
// "channel":"subscriptionResponse",
|
|
889
|
+
// "data":{
|
|
890
|
+
// "method":"unsubscribe",
|
|
891
|
+
// "subscription":{
|
|
892
|
+
// "type":"l2Book",
|
|
893
|
+
// "coin":"BTC",
|
|
894
|
+
// "nSigFigs":5,
|
|
895
|
+
// "mantissa":null
|
|
896
|
+
// }
|
|
897
|
+
// }
|
|
898
|
+
// }
|
|
899
|
+
//
|
|
900
|
+
// {
|
|
901
|
+
// "channel":"subscriptionResponse",
|
|
902
|
+
// "data":{
|
|
903
|
+
// "method":"unsubscribe",
|
|
904
|
+
// "subscription":{
|
|
905
|
+
// "type":"trades",
|
|
906
|
+
// "coin":"PURR/USDC"
|
|
907
|
+
// }
|
|
908
|
+
// }
|
|
909
|
+
// }
|
|
910
|
+
//
|
|
911
|
+
const data = this.safeDict(message, 'data', {});
|
|
912
|
+
const method = this.safeString(data, 'method');
|
|
913
|
+
if (method === 'unsubscribe') {
|
|
914
|
+
const subscription = this.safeDict(data, 'subscription', {});
|
|
915
|
+
const type = this.safeString(subscription, 'type');
|
|
916
|
+
if (type === 'l2Book') {
|
|
917
|
+
this.handleOrderBookUnsubscription(client, subscription);
|
|
918
|
+
}
|
|
919
|
+
else if (type === 'trades') {
|
|
920
|
+
this.handleTradesUnsubscription(client, subscription);
|
|
921
|
+
}
|
|
922
|
+
else if (type === 'webData2') {
|
|
923
|
+
this.handleTickersUnsubscription(client, subscription);
|
|
924
|
+
}
|
|
925
|
+
else if (type === 'candle') {
|
|
926
|
+
this.handleOHLCVUnsubscription(client, subscription);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
724
930
|
handleMessage(client, message) {
|
|
931
|
+
//
|
|
932
|
+
// {
|
|
933
|
+
// "channel":"subscriptionResponse",
|
|
934
|
+
// "data":{
|
|
935
|
+
// "method":"unsubscribe",
|
|
936
|
+
// "subscription":{
|
|
937
|
+
// "type":"l2Book",
|
|
938
|
+
// "coin":"BTC",
|
|
939
|
+
// "nSigFigs":5,
|
|
940
|
+
// "mantissa":null
|
|
941
|
+
// }
|
|
942
|
+
// }
|
|
943
|
+
// }
|
|
944
|
+
//
|
|
725
945
|
if (this.handleErrorMessage(client, message)) {
|
|
726
946
|
return;
|
|
727
947
|
}
|
|
@@ -735,6 +955,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
735
955
|
'userFills': this.handleMyTrades,
|
|
736
956
|
'webData2': this.handleWsTickers,
|
|
737
957
|
'post': this.handleWsPost,
|
|
958
|
+
'subscriptionResponse': this.handleSubscriptionResponse,
|
|
738
959
|
};
|
|
739
960
|
const exacMethod = this.safeValue(methods, topic);
|
|
740
961
|
if (exacMethod !== undefined) {
|
|
@@ -535,8 +535,6 @@ class kucoin extends kucoin$1 {
|
|
|
535
535
|
* @description unWatches trades stream
|
|
536
536
|
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/match-execution-data
|
|
537
537
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
538
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
539
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
540
538
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
541
539
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
542
540
|
*/
|
|
@@ -923,64 +921,9 @@ class kucoin extends kucoin$1 {
|
|
|
923
921
|
for (let i = 0; i < messageHashes.length; i++) {
|
|
924
922
|
const messageHash = messageHashes[i];
|
|
925
923
|
const subHash = subMessageHashes[i];
|
|
926
|
-
|
|
927
|
-
delete client.subscriptions[messageHash];
|
|
928
|
-
}
|
|
929
|
-
if (subHash in client.subscriptions) {
|
|
930
|
-
delete client.subscriptions[subHash];
|
|
931
|
-
}
|
|
932
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subHash);
|
|
933
|
-
client.reject(error, subHash);
|
|
934
|
-
client.resolve(true, messageHash);
|
|
935
|
-
this.cleanCache(subscription);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
cleanCache(subscription) {
|
|
940
|
-
const topic = this.safeString(subscription, 'topic');
|
|
941
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
942
|
-
const symbolsLength = symbols.length;
|
|
943
|
-
if (symbolsLength > 0) {
|
|
944
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
945
|
-
const symbol = symbols[i];
|
|
946
|
-
if (topic === 'trades') {
|
|
947
|
-
if (symbol in this.trades) {
|
|
948
|
-
delete this.trades[symbol];
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
else if (topic === 'orderbook') {
|
|
952
|
-
if (symbol in this.orderbooks) {
|
|
953
|
-
delete this.orderbooks[symbol];
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
else if (topic === 'ticker') {
|
|
957
|
-
if (symbol in this.tickers) {
|
|
958
|
-
delete this.tickers[symbol];
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
else {
|
|
964
|
-
if (topic === 'myTrades') {
|
|
965
|
-
// don't reset this.myTrades directly here
|
|
966
|
-
// because in c# we need to use a different object
|
|
967
|
-
const keys = Object.keys(this.myTrades);
|
|
968
|
-
for (let i = 0; i < keys.length; i++) {
|
|
969
|
-
delete this.myTrades[keys[i]];
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
else if (topic === 'orders') {
|
|
973
|
-
const orderSymbols = Object.keys(this.orders);
|
|
974
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
975
|
-
delete this.orders[orderSymbols[i]];
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
else if (topic === 'ticker') {
|
|
979
|
-
const tickerSymbols = Object.keys(this.tickers);
|
|
980
|
-
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
981
|
-
delete this.tickers[tickerSymbols[i]];
|
|
982
|
-
}
|
|
924
|
+
this.cleanUnsubscription(client, subHash, messageHash);
|
|
983
925
|
}
|
|
926
|
+
this.cleanCache(subscription);
|
|
984
927
|
}
|
|
985
928
|
}
|
|
986
929
|
handleSystemStatus(client, message) {
|