ccxt 4.3.96 → 4.3.98
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 +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +3 -0
- package/dist/cjs/src/bitget.js +2 -0
- package/dist/cjs/src/coinex.js +16 -3
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/pro/gate.js +179 -0
- package/dist/cjs/src/pro/kraken.js +14 -10
- package/dist/cjs/src/pro/kucoin.js +191 -0
- package/dist/cjs/src/whitebit.js +7 -8
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/binance.js +3 -0
- package/js/src/bitget.js +2 -0
- package/js/src/coinex.js +16 -3
- package/js/src/gate.js +1 -1
- package/js/src/kucoin.js +1 -1
- package/js/src/pro/gate.d.ts +7 -1
- package/js/src/pro/gate.js +180 -1
- package/js/src/pro/kraken.js +14 -10
- package/js/src/pro/kucoin.d.ts +7 -1
- package/js/src/pro/kucoin.js +192 -1
- package/js/src/whitebit.js +7 -8
- package/package.json +1 -1
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 } from '../base/errors.js';
|
|
9
|
+
import { ExchangeError, ArgumentsRequired, UnsubscribeError } 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 {
|
|
@@ -157,6 +157,27 @@ export default class kucoin extends kucoinRest {
|
|
|
157
157
|
}
|
|
158
158
|
return await this.watchMultiple(url, messageHashes, message, subscriptionHashes, subscription);
|
|
159
159
|
}
|
|
160
|
+
async unSubscribeMultiple(url, messageHashes, topic, subscriptionHashes, params = {}, subscription = undefined) {
|
|
161
|
+
const requestId = this.requestId().toString();
|
|
162
|
+
const request = {
|
|
163
|
+
'id': requestId,
|
|
164
|
+
'type': 'unsubscribe',
|
|
165
|
+
'topic': topic,
|
|
166
|
+
'response': true,
|
|
167
|
+
};
|
|
168
|
+
const message = this.extend(request, params);
|
|
169
|
+
if (subscription !== undefined) {
|
|
170
|
+
subscription[requestId] = requestId;
|
|
171
|
+
}
|
|
172
|
+
const client = this.client(url);
|
|
173
|
+
for (let i = 0; i < subscriptionHashes.length; i++) {
|
|
174
|
+
const subscriptionHash = subscriptionHashes[i];
|
|
175
|
+
if (!(subscriptionHash in client.subscriptions)) {
|
|
176
|
+
client.subscriptions[requestId] = subscriptionHash;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return await this.watchMultiple(url, messageHashes, message, subscriptionHashes, subscription);
|
|
180
|
+
}
|
|
160
181
|
async watchTicker(symbol, params = {}) {
|
|
161
182
|
/**
|
|
162
183
|
* @method
|
|
@@ -510,6 +531,51 @@ export default class kucoin extends kucoinRest {
|
|
|
510
531
|
}
|
|
511
532
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
512
533
|
}
|
|
534
|
+
async unWatchTradesForSymbols(symbols, params = {}) {
|
|
535
|
+
/**
|
|
536
|
+
* @method
|
|
537
|
+
* @name kucoin#unWatchTradesForSymbols
|
|
538
|
+
* @description unWatches trades stream
|
|
539
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/match-execution-data
|
|
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
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
544
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
545
|
+
*/
|
|
546
|
+
await this.loadMarkets();
|
|
547
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
548
|
+
const marketIds = this.marketIds(symbols);
|
|
549
|
+
const url = await this.negotiate(false);
|
|
550
|
+
const messageHashes = [];
|
|
551
|
+
const subscriptionHashes = [];
|
|
552
|
+
const topic = '/market/match:' + marketIds.join(',');
|
|
553
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
554
|
+
const symbol = symbols[i];
|
|
555
|
+
messageHashes.push('unsubscribe:trades:' + symbol);
|
|
556
|
+
subscriptionHashes.push('trades:' + symbol);
|
|
557
|
+
}
|
|
558
|
+
const subscription = {
|
|
559
|
+
'messageHashes': messageHashes,
|
|
560
|
+
'subMessageHashes': subscriptionHashes,
|
|
561
|
+
'topic': 'trades',
|
|
562
|
+
'unsubscribe': true,
|
|
563
|
+
'symbols': symbols,
|
|
564
|
+
};
|
|
565
|
+
return await this.unSubscribeMultiple(url, messageHashes, topic, messageHashes, params, subscription);
|
|
566
|
+
}
|
|
567
|
+
async unWatchTrades(symbol, params = {}) {
|
|
568
|
+
/**
|
|
569
|
+
* @method
|
|
570
|
+
* @name kucoin#unWatchTrades
|
|
571
|
+
* @description unWatches trades stream
|
|
572
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/match-execution-data
|
|
573
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
574
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
575
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
576
|
+
*/
|
|
577
|
+
return await this.unWatchTradesForSymbols([symbol], params);
|
|
578
|
+
}
|
|
513
579
|
handleTrade(client, message) {
|
|
514
580
|
//
|
|
515
581
|
// {
|
|
@@ -575,6 +641,22 @@ export default class kucoin extends kucoinRest {
|
|
|
575
641
|
//
|
|
576
642
|
return await this.watchOrderBookForSymbols([symbol], limit, params);
|
|
577
643
|
}
|
|
644
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
645
|
+
/**
|
|
646
|
+
* @method
|
|
647
|
+
* @name kucoin#unWatchOrderBook
|
|
648
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level1-bbo-market-data
|
|
649
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level2-market-data
|
|
650
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level2-5-best-ask-bid-orders
|
|
651
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level2-50-best-ask-bid-orders
|
|
652
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
653
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
654
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
655
|
+
* @param {string} [params.method] either '/market/level2' or '/spotMarket/level2Depth5' or '/spotMarket/level2Depth50' default is '/market/level2'
|
|
656
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
657
|
+
*/
|
|
658
|
+
return await this.unWatchOrderBookForSymbols([symbol], params);
|
|
659
|
+
}
|
|
578
660
|
async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
|
|
579
661
|
/**
|
|
580
662
|
* @method
|
|
@@ -628,6 +710,49 @@ export default class kucoin extends kucoinRest {
|
|
|
628
710
|
const orderbook = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, params, subscription);
|
|
629
711
|
return orderbook.limit();
|
|
630
712
|
}
|
|
713
|
+
async unWatchOrderBookForSymbols(symbols, params = {}) {
|
|
714
|
+
/**
|
|
715
|
+
* @method
|
|
716
|
+
* @name kucoin#unWatchOrderBookForSymbols
|
|
717
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level1-bbo-market-data
|
|
718
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level2-market-data
|
|
719
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level2-5-best-ask-bid-orders
|
|
720
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level2-50-best-ask-bid-orders
|
|
721
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
722
|
+
* @param {string[]} symbols unified array of symbols
|
|
723
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
724
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
725
|
+
* @param {string} [params.method] either '/market/level2' or '/spotMarket/level2Depth5' or '/spotMarket/level2Depth50' default is '/market/level2'
|
|
726
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
727
|
+
*/
|
|
728
|
+
const limit = this.safeInteger(params, 'limit');
|
|
729
|
+
params = this.omit(params, 'limit');
|
|
730
|
+
await this.loadMarkets();
|
|
731
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
732
|
+
const marketIds = this.marketIds(symbols);
|
|
733
|
+
const url = await this.negotiate(false);
|
|
734
|
+
let method = undefined;
|
|
735
|
+
[method, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'method', '/market/level2');
|
|
736
|
+
if ((limit === 5) || (limit === 50)) {
|
|
737
|
+
method = '/spotMarket/level2Depth' + limit.toString();
|
|
738
|
+
}
|
|
739
|
+
const topic = method + ':' + marketIds.join(',');
|
|
740
|
+
const messageHashes = [];
|
|
741
|
+
const subscriptionHashes = [];
|
|
742
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
743
|
+
const symbol = symbols[i];
|
|
744
|
+
messageHashes.push('unsubscribe:orderbook:' + symbol);
|
|
745
|
+
subscriptionHashes.push('orderbook:' + symbol);
|
|
746
|
+
}
|
|
747
|
+
const subscription = {
|
|
748
|
+
'messageHashes': messageHashes,
|
|
749
|
+
'symbols': symbols,
|
|
750
|
+
'unsubscribe': true,
|
|
751
|
+
'topic': 'orderbook',
|
|
752
|
+
'subMessageHashes': subscriptionHashes,
|
|
753
|
+
};
|
|
754
|
+
return await this.unSubscribeMultiple(url, messageHashes, topic, messageHashes, params, subscription);
|
|
755
|
+
}
|
|
631
756
|
handleOrderBook(client, message) {
|
|
632
757
|
//
|
|
633
758
|
// initial snapshot is fetched with ccxt's fetchOrderBook
|
|
@@ -794,6 +919,72 @@ export default class kucoin extends kucoinRest {
|
|
|
794
919
|
if (method !== undefined) {
|
|
795
920
|
method.call(this, client, message, subscription);
|
|
796
921
|
}
|
|
922
|
+
const isUnSub = this.safeBool(subscription, 'unsubscribe', false);
|
|
923
|
+
if (isUnSub) {
|
|
924
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
925
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
926
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
927
|
+
const messageHash = messageHashes[i];
|
|
928
|
+
const subHash = subMessageHashes[i];
|
|
929
|
+
if (messageHash in client.subscriptions) {
|
|
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
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
797
988
|
}
|
|
798
989
|
handleSystemStatus(client, message) {
|
|
799
990
|
//
|
package/js/src/whitebit.js
CHANGED
|
@@ -1626,20 +1626,19 @@ export default class whitebit extends Exchange {
|
|
|
1626
1626
|
* @name whitebit#fetchOpenOrders
|
|
1627
1627
|
* @description fetch all unfilled currently open orders
|
|
1628
1628
|
* @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
|
|
1629
|
-
* @param {string} symbol unified market symbol
|
|
1629
|
+
* @param {string} [symbol] unified market symbol
|
|
1630
1630
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1631
1631
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
1632
1632
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1633
1633
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1634
1634
|
*/
|
|
1635
|
-
if (symbol === undefined) {
|
|
1636
|
-
throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
|
|
1637
|
-
}
|
|
1638
1635
|
await this.loadMarkets();
|
|
1639
|
-
|
|
1640
|
-
const request = {
|
|
1641
|
-
|
|
1642
|
-
|
|
1636
|
+
let market = undefined;
|
|
1637
|
+
const request = {};
|
|
1638
|
+
if (symbol !== undefined) {
|
|
1639
|
+
market = this.market(symbol);
|
|
1640
|
+
request['market'] = market['id'];
|
|
1641
|
+
}
|
|
1643
1642
|
if (limit !== undefined) {
|
|
1644
1643
|
request['limit'] = Math.min(limit, 100);
|
|
1645
1644
|
}
|
package/package.json
CHANGED