ccxt 4.4.1 → 4.4.3
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 +88 -18
- package/dist/cjs/src/bitmart.js +3 -1
- package/dist/cjs/src/bitstamp.js +24 -36
- package/dist/cjs/src/bybit.js +1 -0
- package/dist/cjs/src/cryptocom.js +3 -2
- package/dist/cjs/src/currencycom.js +1 -2
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/mexc.js +88 -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 +193 -61
- package/dist/cjs/src/pro/gate.js +1 -9
- package/dist/cjs/src/pro/hyperliquid.js +4 -36
- package/dist/cjs/src/pro/kucoin.js +2 -59
- package/dist/cjs/src/pro/kucoinfutures.js +139 -1
- package/dist/cjs/src/pro/mexc.js +82 -3
- package/dist/cjs/src/pro/okx.js +14 -39
- package/dist/cjs/src/pro/oxfun.js +75 -0
- package/dist/cjs/src/pro/phemex.js +45 -1
- package/dist/cjs/src/pro/woofipro.js +67 -0
- package/dist/cjs/src/xt.js +7 -2
- package/examples/js/cli.js +8 -4
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmart.d.ts +1 -0
- 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 +88 -18
- package/js/src/bitmart.js +3 -1
- package/js/src/bitstamp.js +24 -36
- package/js/src/bybit.js +2 -1
- package/js/src/cryptocom.js +3 -2
- package/js/src/currencycom.js +1 -2
- package/js/src/htx.js +1 -1
- package/js/src/mexc.js +88 -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 +7 -2
- package/js/src/pro/cryptocom.js +194 -62
- package/js/src/pro/gate.js +2 -10
- package/js/src/pro/hyperliquid.js +5 -37
- 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/mexc.d.ts +3 -1
- package/js/src/pro/mexc.js +82 -3
- package/js/src/pro/okx.js +15 -40
- package/js/src/pro/oxfun.d.ts +3 -0
- package/js/src/pro/oxfun.js +75 -0
- package/js/src/pro/phemex.d.ts +2 -1
- package/js/src/pro/phemex.js +45 -1
- package/js/src/pro/woofipro.d.ts +3 -0
- package/js/src/pro/woofipro.js +67 -0
- package/js/src/xt.js +7 -2
- package/package.json +1 -1
package/js/src/pro/cryptocom.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import cryptocomRest from '../cryptocom.js';
|
|
9
|
-
import { AuthenticationError, ChecksumError, ExchangeError, NetworkError
|
|
9
|
+
import { AuthenticationError, ChecksumError, ExchangeError, NetworkError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -17,7 +17,8 @@ export default class cryptocom extends cryptocomRest {
|
|
|
17
17
|
'ws': true,
|
|
18
18
|
'watchBalance': true,
|
|
19
19
|
'watchTicker': true,
|
|
20
|
-
'watchTickers':
|
|
20
|
+
'watchTickers': true,
|
|
21
|
+
'watchBidsAsks': true,
|
|
21
22
|
'watchMyTrades': true,
|
|
22
23
|
'watchTrades': true,
|
|
23
24
|
'watchTradesForSymbols': true,
|
|
@@ -374,7 +375,7 @@ export default class cryptocom extends cryptocomRest {
|
|
|
374
375
|
messageHashes.push('unsubscribe:trades:' + market['symbol']);
|
|
375
376
|
topics.push(currentTopic);
|
|
376
377
|
}
|
|
377
|
-
return await this.unWatchPublicMultiple('
|
|
378
|
+
return await this.unWatchPublicMultiple('trades', symbols, messageHashes, topics, topics, params);
|
|
378
379
|
}
|
|
379
380
|
handleTrades(client, message) {
|
|
380
381
|
//
|
|
@@ -480,41 +481,210 @@ export default class cryptocom extends cryptocomRest {
|
|
|
480
481
|
const messageHash = 'unsubscribe:ticker:' + market['symbol'];
|
|
481
482
|
return await this.unWatchPublicMultiple('ticker', [market['symbol']], [messageHash], [subMessageHash], [subMessageHash], params);
|
|
482
483
|
}
|
|
484
|
+
async watchTickers(symbols = undefined, params = {}) {
|
|
485
|
+
/**
|
|
486
|
+
* @method
|
|
487
|
+
* @name cryptocom#watchTickers
|
|
488
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
489
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
|
|
490
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
491
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
492
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
493
|
+
*/
|
|
494
|
+
await this.loadMarkets();
|
|
495
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
496
|
+
const messageHashes = [];
|
|
497
|
+
const marketIds = this.marketIds(symbols);
|
|
498
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
499
|
+
const marketId = marketIds[i];
|
|
500
|
+
messageHashes.push('ticker.' + marketId);
|
|
501
|
+
}
|
|
502
|
+
const url = this.urls['api']['ws']['public'];
|
|
503
|
+
const id = this.nonce();
|
|
504
|
+
const request = {
|
|
505
|
+
'method': 'subscribe',
|
|
506
|
+
'params': {
|
|
507
|
+
'channels': messageHashes,
|
|
508
|
+
},
|
|
509
|
+
'nonce': id,
|
|
510
|
+
};
|
|
511
|
+
const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
|
|
512
|
+
if (this.newUpdates) {
|
|
513
|
+
const result = {};
|
|
514
|
+
result[ticker['symbol']] = ticker;
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
518
|
+
}
|
|
519
|
+
async unWatchTickers(symbols = undefined, params = {}) {
|
|
520
|
+
/**
|
|
521
|
+
* @method
|
|
522
|
+
* @name cryptocom#unWatchTickers
|
|
523
|
+
* @description unWatches a price ticker
|
|
524
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
|
|
525
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
526
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
527
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
528
|
+
*/
|
|
529
|
+
await this.loadMarkets();
|
|
530
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
531
|
+
const messageHashes = [];
|
|
532
|
+
const subMessageHashes = [];
|
|
533
|
+
const marketIds = this.marketIds(symbols);
|
|
534
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
535
|
+
const marketId = marketIds[i];
|
|
536
|
+
const symbol = symbols[i];
|
|
537
|
+
subMessageHashes.push('ticker.' + marketId);
|
|
538
|
+
messageHashes.push('unsubscribe:ticker:' + symbol);
|
|
539
|
+
}
|
|
540
|
+
return await this.unWatchPublicMultiple('ticker', symbols, messageHashes, subMessageHashes, subMessageHashes, params);
|
|
541
|
+
}
|
|
483
542
|
handleTicker(client, message) {
|
|
484
543
|
//
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
//
|
|
497
|
-
//
|
|
498
|
-
//
|
|
499
|
-
//
|
|
500
|
-
//
|
|
501
|
-
//
|
|
502
|
-
//
|
|
544
|
+
// {
|
|
545
|
+
// "instrument_name": "ETHUSD-PERP",
|
|
546
|
+
// "subscription": "ticker.ETHUSD-PERP",
|
|
547
|
+
// "channel": "ticker",
|
|
548
|
+
// "data": [
|
|
549
|
+
// {
|
|
550
|
+
// "h": "2400.20",
|
|
551
|
+
// "l": "2277.10",
|
|
552
|
+
// "a": "2335.25",
|
|
553
|
+
// "c": "-0.0022",
|
|
554
|
+
// "b": "2335.10",
|
|
555
|
+
// "bs": "5.4000",
|
|
556
|
+
// "k": "2335.16",
|
|
557
|
+
// "ks": "1.9970",
|
|
558
|
+
// "i": "ETHUSD-PERP",
|
|
559
|
+
// "v": "1305697.6462",
|
|
560
|
+
// "vv": "3058704939.17",
|
|
561
|
+
// "oi": "161646.3614",
|
|
562
|
+
// "t": 1726069647560
|
|
563
|
+
// }
|
|
564
|
+
// ]
|
|
503
565
|
// }
|
|
504
|
-
// }
|
|
505
566
|
//
|
|
567
|
+
this.handleBidAsk(client, message);
|
|
506
568
|
const messageHash = this.safeString(message, 'subscription');
|
|
507
569
|
const marketId = this.safeString(message, 'instrument_name');
|
|
508
570
|
const market = this.safeMarket(marketId);
|
|
509
571
|
const data = this.safeValue(message, 'data', []);
|
|
510
572
|
for (let i = 0; i < data.length; i++) {
|
|
511
573
|
const ticker = data[i];
|
|
512
|
-
const parsed = this.
|
|
574
|
+
const parsed = this.parseWsTicker(ticker, market);
|
|
513
575
|
const symbol = parsed['symbol'];
|
|
514
576
|
this.tickers[symbol] = parsed;
|
|
515
577
|
client.resolve(parsed, messageHash);
|
|
516
578
|
}
|
|
517
579
|
}
|
|
580
|
+
parseWsTicker(ticker, market = undefined) {
|
|
581
|
+
//
|
|
582
|
+
// {
|
|
583
|
+
// "h": "2400.20",
|
|
584
|
+
// "l": "2277.10",
|
|
585
|
+
// "a": "2335.25",
|
|
586
|
+
// "c": "-0.0022",
|
|
587
|
+
// "b": "2335.10",
|
|
588
|
+
// "bs": "5.4000",
|
|
589
|
+
// "k": "2335.16",
|
|
590
|
+
// "ks": "1.9970",
|
|
591
|
+
// "i": "ETHUSD-PERP",
|
|
592
|
+
// "v": "1305697.6462",
|
|
593
|
+
// "vv": "3058704939.17",
|
|
594
|
+
// "oi": "161646.3614",
|
|
595
|
+
// "t": 1726069647560
|
|
596
|
+
// }
|
|
597
|
+
//
|
|
598
|
+
const timestamp = this.safeInteger(ticker, 't');
|
|
599
|
+
const marketId = this.safeString(ticker, 'i');
|
|
600
|
+
market = this.safeMarket(marketId, market, '_');
|
|
601
|
+
const quote = this.safeString(market, 'quote');
|
|
602
|
+
const last = this.safeString(ticker, 'a');
|
|
603
|
+
return this.safeTicker({
|
|
604
|
+
'symbol': market['symbol'],
|
|
605
|
+
'timestamp': timestamp,
|
|
606
|
+
'datetime': this.iso8601(timestamp),
|
|
607
|
+
'high': this.safeNumber(ticker, 'h'),
|
|
608
|
+
'low': this.safeNumber(ticker, 'l'),
|
|
609
|
+
'bid': this.safeNumber(ticker, 'b'),
|
|
610
|
+
'bidVolume': this.safeNumber(ticker, 'bs'),
|
|
611
|
+
'ask': this.safeNumber(ticker, 'k'),
|
|
612
|
+
'askVolume': this.safeNumber(ticker, 'ks'),
|
|
613
|
+
'vwap': undefined,
|
|
614
|
+
'open': undefined,
|
|
615
|
+
'close': last,
|
|
616
|
+
'last': last,
|
|
617
|
+
'previousClose': undefined,
|
|
618
|
+
'change': undefined,
|
|
619
|
+
'percentage': this.safeString(ticker, 'c'),
|
|
620
|
+
'average': undefined,
|
|
621
|
+
'baseVolume': this.safeString(ticker, 'v'),
|
|
622
|
+
'quoteVolume': (quote === 'USD') ? this.safeString(ticker, 'vv') : undefined,
|
|
623
|
+
'info': ticker,
|
|
624
|
+
}, market);
|
|
625
|
+
}
|
|
626
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
627
|
+
/**
|
|
628
|
+
* @method
|
|
629
|
+
* @name cryptocom#watchBidsAsks
|
|
630
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
|
|
631
|
+
* @description watches best bid & ask for symbols
|
|
632
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
633
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
634
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
635
|
+
*/
|
|
636
|
+
await this.loadMarkets();
|
|
637
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
638
|
+
const messageHashes = [];
|
|
639
|
+
const topics = [];
|
|
640
|
+
const marketIds = this.marketIds(symbols);
|
|
641
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
642
|
+
const marketId = marketIds[i];
|
|
643
|
+
messageHashes.push('bidask.' + symbols[i]);
|
|
644
|
+
topics.push('ticker.' + marketId);
|
|
645
|
+
}
|
|
646
|
+
const url = this.urls['api']['ws']['public'];
|
|
647
|
+
const id = this.nonce();
|
|
648
|
+
const request = {
|
|
649
|
+
'method': 'subscribe',
|
|
650
|
+
'params': {
|
|
651
|
+
'channels': topics,
|
|
652
|
+
},
|
|
653
|
+
'nonce': id,
|
|
654
|
+
};
|
|
655
|
+
const newTickers = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
|
|
656
|
+
if (this.newUpdates) {
|
|
657
|
+
const tickers = {};
|
|
658
|
+
tickers[newTickers['symbol']] = newTickers;
|
|
659
|
+
return tickers;
|
|
660
|
+
}
|
|
661
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
662
|
+
}
|
|
663
|
+
handleBidAsk(client, message) {
|
|
664
|
+
const data = this.safeList(message, 'data', []);
|
|
665
|
+
const ticker = this.safeDict(data, 0, {});
|
|
666
|
+
const parsedTicker = this.parseWsBidAsk(ticker);
|
|
667
|
+
const symbol = parsedTicker['symbol'];
|
|
668
|
+
this.bidsasks[symbol] = parsedTicker;
|
|
669
|
+
const messageHash = 'bidask.' + symbol;
|
|
670
|
+
client.resolve(parsedTicker, messageHash);
|
|
671
|
+
}
|
|
672
|
+
parseWsBidAsk(ticker, market = undefined) {
|
|
673
|
+
const marketId = this.safeString(ticker, 'i');
|
|
674
|
+
market = this.safeMarket(marketId, market);
|
|
675
|
+
const symbol = this.safeString(market, 'symbol');
|
|
676
|
+
const timestamp = this.safeInteger(ticker, 't');
|
|
677
|
+
return this.safeTicker({
|
|
678
|
+
'symbol': symbol,
|
|
679
|
+
'timestamp': timestamp,
|
|
680
|
+
'datetime': this.iso8601(timestamp),
|
|
681
|
+
'ask': this.safeString(ticker, 'k'),
|
|
682
|
+
'askVolume': this.safeString(ticker, 'ks'),
|
|
683
|
+
'bid': this.safeString(ticker, 'b'),
|
|
684
|
+
'bidVolume': this.safeString(ticker, 'bs'),
|
|
685
|
+
'info': ticker,
|
|
686
|
+
}, market);
|
|
687
|
+
}
|
|
518
688
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
519
689
|
/**
|
|
520
690
|
* @method
|
|
@@ -1208,48 +1378,10 @@ export default class cryptocom extends cryptocomRest {
|
|
|
1208
1378
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1209
1379
|
const unsubHash = messageHashes[j];
|
|
1210
1380
|
const subHash = subMessageHashes[j];
|
|
1211
|
-
|
|
1212
|
-
delete client.subscriptions[unsubHash];
|
|
1213
|
-
}
|
|
1214
|
-
if (subHash in client.subscriptions) {
|
|
1215
|
-
delete client.subscriptions[subHash];
|
|
1216
|
-
}
|
|
1217
|
-
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
1218
|
-
client.reject(error, subHash);
|
|
1219
|
-
client.resolve(true, unsubHash);
|
|
1381
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1220
1382
|
}
|
|
1221
1383
|
this.cleanCache(subscription);
|
|
1222
1384
|
}
|
|
1223
1385
|
}
|
|
1224
1386
|
}
|
|
1225
|
-
cleanCache(subscription) {
|
|
1226
|
-
const topic = this.safeString(subscription, 'topic');
|
|
1227
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1228
|
-
const symbolsLength = symbols.length;
|
|
1229
|
-
if (topic === 'ohlcv') {
|
|
1230
|
-
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1231
|
-
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1232
|
-
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1233
|
-
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1234
|
-
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1235
|
-
if (timeframe in this.ohlcvs[symbol]) {
|
|
1236
|
-
delete this.ohlcvs[symbol][timeframe];
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
else if (symbolsLength > 0) {
|
|
1241
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
1242
|
-
const symbol = symbols[i];
|
|
1243
|
-
if (topic === 'trade') {
|
|
1244
|
-
delete this.trades[symbol];
|
|
1245
|
-
}
|
|
1246
|
-
else if (topic === 'orderbook') {
|
|
1247
|
-
delete this.orderbooks[symbol];
|
|
1248
|
-
}
|
|
1249
|
-
else if (topic === 'ticker') {
|
|
1250
|
-
delete this.tickers[symbol];
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
1387
|
}
|
package/js/src/pro/gate.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import gateRest from '../gate.js';
|
|
9
|
-
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported
|
|
9
|
+
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha512 } from '../static_dependencies/noble-hashes/sha512.js';
|
|
12
12
|
import Precise from '../base/Precise.js';
|
|
@@ -1663,15 +1663,7 @@ export default class gate extends gateRest {
|
|
|
1663
1663
|
for (let j = 0; j < messageHashes.length; j++) {
|
|
1664
1664
|
const unsubHash = messageHashes[j];
|
|
1665
1665
|
const subHash = subMessageHashes[j];
|
|
1666
|
-
|
|
1667
|
-
delete client.subscriptions[unsubHash];
|
|
1668
|
-
}
|
|
1669
|
-
if (subHash in client.subscriptions) {
|
|
1670
|
-
delete client.subscriptions[subHash];
|
|
1671
|
-
}
|
|
1672
|
-
const error = new UnsubscribeError(this.id + ' ' + messageHash);
|
|
1673
|
-
client.reject(error, subHash);
|
|
1674
|
-
client.resolve(true, unsubHash);
|
|
1666
|
+
this.cleanUnsubscription(client, subHash, unsubHash);
|
|
1675
1667
|
}
|
|
1676
1668
|
this.cleanCache(subscription);
|
|
1677
1669
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import hyperliquidRest from '../hyperliquid.js';
|
|
9
|
-
import { ExchangeError
|
|
9
|
+
import { ExchangeError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
export default class hyperliquid extends hyperliquidRest {
|
|
@@ -844,15 +844,7 @@ export default class hyperliquid extends hyperliquidRest {
|
|
|
844
844
|
const symbol = this.safeSymbol(marketId);
|
|
845
845
|
const subMessageHash = 'orderbook:' + symbol;
|
|
846
846
|
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
847
|
-
|
|
848
|
-
delete client.subscriptions[messageHash];
|
|
849
|
-
}
|
|
850
|
-
if (subMessageHash in client.subscriptions) {
|
|
851
|
-
delete client.subscriptions[subMessageHash];
|
|
852
|
-
}
|
|
853
|
-
const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
854
|
-
client.reject(error, subMessageHash);
|
|
855
|
-
client.resolve(true, messageHash);
|
|
847
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
856
848
|
if (symbol in this.orderbooks) {
|
|
857
849
|
delete this.orderbooks[symbol];
|
|
858
850
|
}
|
|
@@ -864,15 +856,7 @@ export default class hyperliquid extends hyperliquidRest {
|
|
|
864
856
|
const symbol = this.safeSymbol(marketId);
|
|
865
857
|
const subMessageHash = 'trade:' + symbol;
|
|
866
858
|
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
867
|
-
|
|
868
|
-
delete client.subscriptions[messageHash];
|
|
869
|
-
}
|
|
870
|
-
if (subMessageHash in client.subscriptions) {
|
|
871
|
-
delete client.subscriptions[subMessageHash];
|
|
872
|
-
}
|
|
873
|
-
const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
874
|
-
client.reject(error, subMessageHash);
|
|
875
|
-
client.resolve(true, messageHash);
|
|
859
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
876
860
|
if (symbol in this.trades) {
|
|
877
861
|
delete this.trades[symbol];
|
|
878
862
|
}
|
|
@@ -881,15 +865,7 @@ export default class hyperliquid extends hyperliquidRest {
|
|
|
881
865
|
//
|
|
882
866
|
const subMessageHash = 'tickers';
|
|
883
867
|
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
884
|
-
|
|
885
|
-
delete client.subscriptions[messageHash];
|
|
886
|
-
}
|
|
887
|
-
if (subMessageHash in client.subscriptions) {
|
|
888
|
-
delete client.subscriptions[subMessageHash];
|
|
889
|
-
}
|
|
890
|
-
const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
891
|
-
client.reject(error, subMessageHash);
|
|
892
|
-
client.resolve(true, messageHash);
|
|
868
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
893
869
|
const symbols = Object.keys(this.tickers);
|
|
894
870
|
for (let i = 0; i < symbols.length; i++) {
|
|
895
871
|
delete this.tickers[symbols[i]];
|
|
@@ -903,15 +879,7 @@ export default class hyperliquid extends hyperliquidRest {
|
|
|
903
879
|
const timeframe = this.findTimeframe(interval);
|
|
904
880
|
const subMessageHash = 'candles:' + timeframe + ':' + symbol;
|
|
905
881
|
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
906
|
-
|
|
907
|
-
delete client.subscriptions[messageHash];
|
|
908
|
-
}
|
|
909
|
-
if (subMessageHash in client.subscriptions) {
|
|
910
|
-
delete client.subscriptions[subMessageHash];
|
|
911
|
-
}
|
|
912
|
-
const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
913
|
-
client.reject(error, subMessageHash);
|
|
914
|
-
client.resolve(true, messageHash);
|
|
882
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
915
883
|
if (symbol in this.ohlcvs) {
|
|
916
884
|
if (timeframe in this.ohlcvs[symbol]) {
|
|
917
885
|
delete this.ohlcvs[symbol][timeframe];
|
package/js/src/pro/kucoin.d.ts
CHANGED
|
@@ -33,7 +33,6 @@ export default class kucoin extends kucoinRest {
|
|
|
33
33
|
handleBidAsks(bookSide: any, bidAsks: any): void;
|
|
34
34
|
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
35
35
|
handleSubscriptionStatus(client: Client, message: any): void;
|
|
36
|
-
cleanCache(subscription: Dict): void;
|
|
37
36
|
handleSystemStatus(client: Client, message: any): any;
|
|
38
37
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
39
38
|
parseWsOrderStatus(status: any): string;
|
package/js/src/pro/kucoin.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import kucoinRest from '../kucoin.js';
|
|
9
|
-
import { ExchangeError, ArgumentsRequired
|
|
9
|
+
import { ExchangeError, ArgumentsRequired } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
export default class kucoin extends kucoinRest {
|
|
@@ -538,8 +538,6 @@ export default class kucoin extends kucoinRest {
|
|
|
538
538
|
* @description unWatches trades stream
|
|
539
539
|
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/match-execution-data
|
|
540
540
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
541
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
542
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
543
541
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
544
542
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
545
543
|
*/
|
|
@@ -926,64 +924,9 @@ export default class kucoin extends kucoinRest {
|
|
|
926
924
|
for (let i = 0; i < messageHashes.length; i++) {
|
|
927
925
|
const messageHash = messageHashes[i];
|
|
928
926
|
const subHash = subMessageHashes[i];
|
|
929
|
-
|
|
930
|
-
delete client.subscriptions[messageHash];
|
|
931
|
-
}
|
|
932
|
-
if (subHash in client.subscriptions) {
|
|
933
|
-
delete client.subscriptions[subHash];
|
|
934
|
-
}
|
|
935
|
-
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
936
|
-
client.reject(error, subHash);
|
|
937
|
-
client.resolve(true, messageHash);
|
|
938
|
-
this.cleanCache(subscription);
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
cleanCache(subscription) {
|
|
943
|
-
const topic = this.safeString(subscription, 'topic');
|
|
944
|
-
const symbols = this.safeList(subscription, 'symbols', []);
|
|
945
|
-
const symbolsLength = symbols.length;
|
|
946
|
-
if (symbolsLength > 0) {
|
|
947
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
948
|
-
const symbol = symbols[i];
|
|
949
|
-
if (topic === 'trades') {
|
|
950
|
-
if (symbol in this.trades) {
|
|
951
|
-
delete this.trades[symbol];
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
else if (topic === 'orderbook') {
|
|
955
|
-
if (symbol in this.orderbooks) {
|
|
956
|
-
delete this.orderbooks[symbol];
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
else if (topic === 'ticker') {
|
|
960
|
-
if (symbol in this.tickers) {
|
|
961
|
-
delete this.tickers[symbol];
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
else {
|
|
967
|
-
if (topic === 'myTrades') {
|
|
968
|
-
// don't reset this.myTrades directly here
|
|
969
|
-
// because in c# we need to use a different object
|
|
970
|
-
const keys = Object.keys(this.myTrades);
|
|
971
|
-
for (let i = 0; i < keys.length; i++) {
|
|
972
|
-
delete this.myTrades[keys[i]];
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
else if (topic === 'orders') {
|
|
976
|
-
const orderSymbols = Object.keys(this.orders);
|
|
977
|
-
for (let i = 0; i < orderSymbols.length; i++) {
|
|
978
|
-
delete this.orders[orderSymbols[i]];
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
else if (topic === 'ticker') {
|
|
982
|
-
const tickerSymbols = Object.keys(this.tickers);
|
|
983
|
-
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
984
|
-
delete this.tickers[tickerSymbols[i]];
|
|
985
|
-
}
|
|
927
|
+
this.cleanUnsubscription(client, subHash, messageHash);
|
|
986
928
|
}
|
|
929
|
+
this.cleanCache(subscription);
|
|
987
930
|
}
|
|
988
931
|
}
|
|
989
932
|
handleSystemStatus(client, message) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import kucoinfuturesRest from '../kucoinfutures.js';
|
|
2
|
-
import type { Int, Str, OrderBook, Order, Trade, Ticker, Balances, Position, Strings, Tickers, OHLCV } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, OrderBook, Order, Trade, Ticker, Balances, Position, Strings, Tickers, OHLCV, Dict } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class kucoinfutures extends kucoinfuturesRest {
|
|
5
5
|
describe(): any;
|
|
@@ -8,6 +8,7 @@ export default class kucoinfutures extends kucoinfuturesRest {
|
|
|
8
8
|
requestId(): any;
|
|
9
9
|
subscribe(url: any, messageHash: any, subscriptionHash: any, subscription: any, params?: {}): Promise<any>;
|
|
10
10
|
subscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, subscriptionArgs: any, params?: {}): Promise<any>;
|
|
11
|
+
unSubscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, params?: {}, subscription?: Dict): Promise<any>;
|
|
11
12
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
12
13
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
14
|
handleTicker(client: Client, message: any): void;
|
|
@@ -22,11 +23,15 @@ export default class kucoinfutures extends kucoinfuturesRest {
|
|
|
22
23
|
handlePosition(client: Client, message: any): void;
|
|
23
24
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
24
25
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
26
|
+
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
|
27
|
+
unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
25
28
|
handleTrade(client: Client, message: any): any;
|
|
26
29
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
27
30
|
handleOHLCV(client: Client, message: any): void;
|
|
28
31
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
29
32
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
33
|
+
unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
|
|
34
|
+
unWatchOrderBookForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
30
35
|
handleDelta(orderbook: any, delta: any): void;
|
|
31
36
|
handleDeltas(bookside: any, deltas: any): void;
|
|
32
37
|
handleOrderBook(client: Client, message: any): void;
|
|
@@ -48,5 +53,6 @@ export default class kucoinfutures extends kucoinfuturesRest {
|
|
|
48
53
|
};
|
|
49
54
|
handlePong(client: Client, message: any): any;
|
|
50
55
|
handleErrorMessage(client: Client, message: any): void;
|
|
56
|
+
handleSubscriptionStatus(client: Client, message: any): void;
|
|
51
57
|
handleMessage(client: Client, message: any): void;
|
|
52
58
|
}
|