ccxt 4.5.18 → 4.5.20

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.
Files changed (152) hide show
  1. package/README.md +7 -6
  2. package/dist/ccxt.browser.min.js +40 -16
  3. package/dist/cjs/_virtual/index.cjs.js +1459 -9
  4. package/dist/cjs/ccxt.js +8 -2
  5. package/dist/cjs/src/abstract/dydx.js +11 -0
  6. package/dist/cjs/src/base/Exchange.js +164 -10
  7. package/dist/cjs/src/base/ws/Client.js +3 -1
  8. package/dist/cjs/src/binance.js +8 -1
  9. package/dist/cjs/src/bingx.js +20 -0
  10. package/dist/cjs/src/bitget.js +43 -41
  11. package/dist/cjs/src/bybit.js +21 -23
  12. package/dist/cjs/src/deribit.js +6 -0
  13. package/dist/cjs/src/dydx.js +2454 -0
  14. package/dist/cjs/src/gate.js +4 -4
  15. package/dist/cjs/src/hibachi.js +1 -1
  16. package/dist/cjs/src/hyperliquid.js +207 -9
  17. package/dist/cjs/src/kucoin.js +711 -109
  18. package/dist/cjs/src/mexc.js +2 -3
  19. package/dist/cjs/src/pro/binance.js +59 -144
  20. package/dist/cjs/src/pro/dydx.js +418 -0
  21. package/dist/cjs/src/pro/kraken.js +4 -3
  22. package/dist/cjs/src/pro/xt.js +218 -4
  23. package/dist/cjs/src/protobuf/mexc/compiled.cjs.js +1 -0
  24. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +56 -0
  25. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +56 -0
  26. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +48 -0
  27. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +343 -0
  28. package/dist/cjs/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +717 -0
  29. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +60 -0
  30. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +45 -0
  31. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +380 -0
  32. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +72 -0
  33. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +211 -0
  34. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +195 -0
  35. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +49 -0
  36. package/dist/cjs/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +57 -0
  37. package/dist/cjs/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +56 -0
  38. package/dist/cjs/src/static_dependencies/dydx-v4-client/helpers.js +79 -0
  39. package/dist/cjs/src/static_dependencies/dydx-v4-client/long/index.cjs.js +9 -0
  40. package/dist/cjs/src/static_dependencies/dydx-v4-client/onboarding.js +59 -0
  41. package/dist/cjs/src/static_dependencies/dydx-v4-client/registry.js +39 -0
  42. package/dist/cjs/src/static_dependencies/noble-hashes/pbkdf2.js +69 -0
  43. package/dist/cjs/src/static_dependencies/noble-hashes/ripemd160.js +108 -0
  44. package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +50 -1
  45. package/dist/cjs/src/static_dependencies/scure-base/index.js +29 -0
  46. package/dist/cjs/src/static_dependencies/scure-bip32/index.js +278 -0
  47. package/dist/cjs/src/static_dependencies/scure-bip39/index.js +97 -0
  48. package/dist/cjs/src/static_dependencies/scure-bip39/wordlists/english.js +2060 -0
  49. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2 -0
  50. package/dist/cjs/src/toobit.js +2 -1
  51. package/js/ccxt.d.ts +8 -2
  52. package/js/ccxt.js +6 -2
  53. package/js/src/abstract/binance.d.ts +7 -0
  54. package/js/src/abstract/binancecoinm.d.ts +7 -0
  55. package/js/src/abstract/binanceus.d.ts +7 -0
  56. package/js/src/abstract/binanceusdm.d.ts +7 -0
  57. package/js/src/abstract/bitget.d.ts +1 -0
  58. package/js/src/abstract/dydx.d.ts +61 -0
  59. package/js/src/abstract/dydx.js +11 -0
  60. package/js/src/abstract/kucoin.d.ts +1 -1
  61. package/js/src/abstract/kucoinfutures.d.ts +1 -1
  62. package/js/src/base/Exchange.d.ts +7 -0
  63. package/js/src/base/Exchange.js +163 -10
  64. package/js/src/base/ws/Client.js +3 -1
  65. package/js/src/binance.js +8 -1
  66. package/js/src/bingx.js +20 -0
  67. package/js/src/bitget.d.ts +3 -3
  68. package/js/src/bitget.js +43 -41
  69. package/js/src/bybit.d.ts +3 -3
  70. package/js/src/bybit.js +21 -23
  71. package/js/src/deribit.js +6 -0
  72. package/js/src/dydx.d.ts +364 -0
  73. package/js/src/dydx.js +2453 -0
  74. package/js/src/gate.d.ts +2 -2
  75. package/js/src/gate.js +4 -4
  76. package/js/src/hibachi.js +1 -1
  77. package/js/src/hyperliquid.d.ts +17 -0
  78. package/js/src/hyperliquid.js +207 -9
  79. package/js/src/kucoin.d.ts +48 -1
  80. package/js/src/kucoin.js +711 -109
  81. package/js/src/mexc.js +2 -3
  82. package/js/src/pro/binance.d.ts +2 -2
  83. package/js/src/pro/binance.js +59 -144
  84. package/js/src/pro/dydx.d.ts +81 -0
  85. package/js/src/pro/dydx.js +417 -0
  86. package/js/src/pro/kraken.js +4 -3
  87. package/js/src/pro/xt.d.ts +85 -2
  88. package/js/src/pro/xt.js +218 -4
  89. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.d.ts +90 -0
  90. package/js/src/static_dependencies/dydx-v4-client/cosmos/base/v1beta1/coin.js +163 -0
  91. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.d.ts +26 -0
  92. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/keys.js +51 -0
  93. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.d.ts +48 -0
  94. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/multisig/v1beta1/multisig.js +85 -0
  95. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.d.ts +40 -0
  96. package/js/src/static_dependencies/dydx-v4-client/cosmos/crypto/secp256k1/keys.js +77 -0
  97. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.d.ts +162 -0
  98. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/signing/v1beta1/signing.js +329 -0
  99. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.d.ts +460 -0
  100. package/js/src/static_dependencies/dydx-v4-client/cosmos/tx/v1beta1/tx.js +698 -0
  101. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.d.ts +127 -0
  102. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/accountplus/tx.js +286 -0
  103. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.d.ts +66 -0
  104. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/block_rate_limit_config.js +109 -0
  105. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.d.ts +127 -0
  106. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/clob_pair.js +257 -0
  107. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.d.ts +48 -0
  108. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/equity_tier_limit_config.js +93 -0
  109. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.d.ts +23 -0
  110. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/finalize_block.js +43 -0
  111. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.d.ts +92 -0
  112. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations.js +164 -0
  113. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.d.ts +124 -0
  114. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/liquidations_config.js +196 -0
  115. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.d.ts +159 -0
  116. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/matches.js +324 -0
  117. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.d.ts +546 -0
  118. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order.js +872 -0
  119. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.d.ts +84 -0
  120. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/order_removals.js +181 -0
  121. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.d.ts +397 -0
  122. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/clob/tx.js +757 -0
  123. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.d.ts +120 -0
  124. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/transfer.js +246 -0
  125. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.d.ts +79 -0
  126. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/sending/tx.js +147 -0
  127. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.d.ts +32 -0
  128. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/asset_position.js +59 -0
  129. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.d.ts +34 -0
  130. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/perpetual_position.js +66 -0
  131. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.d.ts +62 -0
  132. package/js/src/static_dependencies/dydx-v4-client/dydxprotocol/subaccounts/subaccount.js +111 -0
  133. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.d.ts +207 -0
  134. package/js/src/static_dependencies/dydx-v4-client/google/protobuf/any.js +50 -0
  135. package/js/src/static_dependencies/dydx-v4-client/helpers.d.ts +82 -0
  136. package/js/src/static_dependencies/dydx-v4-client/helpers.js +172 -0
  137. package/js/src/static_dependencies/dydx-v4-client/long/index.cjs +1473 -0
  138. package/js/src/static_dependencies/dydx-v4-client/long/index.d.cts +2 -0
  139. package/js/src/static_dependencies/dydx-v4-client/onboarding.d.ts +35 -0
  140. package/js/src/static_dependencies/dydx-v4-client/onboarding.js +56 -0
  141. package/js/src/static_dependencies/dydx-v4-client/registry.d.ts +7 -0
  142. package/js/src/static_dependencies/dydx-v4-client/registry.js +36 -0
  143. package/js/src/static_dependencies/noble-hashes/utils.d.ts +1 -0
  144. package/js/src/static_dependencies/noble-hashes/utils.js +4 -0
  145. package/js/src/static_dependencies/scure-bip32/index.d.ts +49 -0
  146. package/js/src/static_dependencies/scure-bip32/index.js +295 -0
  147. package/js/src/static_dependencies/scure-bip39/index.d.ts +54 -0
  148. package/js/src/static_dependencies/scure-bip39/index.js +140 -0
  149. package/js/src/static_dependencies/scure-bip39/wordlists/english.d.ts +1 -0
  150. package/js/src/static_dependencies/scure-bip39/wordlists/english.js +2054 -0
  151. package/js/src/toobit.js +2 -1
  152. package/package.json +9 -3
package/js/src/pro/xt.js CHANGED
@@ -7,6 +7,7 @@
7
7
  // ---------------------------------------------------------------------------
8
8
  import xtRest from '../xt.js';
9
9
  import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
10
+ import { NotSupported } from '../base/errors.js';
10
11
  // ---------------------------------------------------------------------------
11
12
  export default class xt extends xtRest {
12
13
  describe() {
@@ -14,10 +15,15 @@ export default class xt extends xtRest {
14
15
  'has': {
15
16
  'ws': true,
16
17
  'watchOHLCV': true,
18
+ 'unWatchOHLCV': true,
17
19
  'watchOrderBook': true,
20
+ 'unWatchOrderBook': true,
18
21
  'watchTicker': true,
22
+ 'unWatchTicker': true,
19
23
  'watchTickers': true,
24
+ 'unWatchTickers': true,
20
25
  'watchTrades': true,
26
+ 'unWatchTrades': true,
21
27
  'watchTradesForSymbols': false,
22
28
  'watchBalance': true,
23
29
  'watchOrders': true,
@@ -162,9 +168,10 @@ export default class xt extends xtRest {
162
168
  let type = undefined;
163
169
  [type, params] = this.handleMarketTypeAndParams(methodName, market, params);
164
170
  const isContract = (type !== 'spot');
171
+ const id = this.numberToString(this.milliseconds()) + name; // call back ID
165
172
  const subscribe = {
166
173
  'method': isContract ? 'SUBSCRIBE' : 'subscribe',
167
- 'id': this.numberToString(this.milliseconds()) + name, // call back ID
174
+ 'id': id,
168
175
  };
169
176
  if (privateAccess) {
170
177
  if (!isContract) {
@@ -190,8 +197,73 @@ export default class xt extends xtRest {
190
197
  if (isContract) {
191
198
  tail = privateAccess ? 'user' : 'market';
192
199
  }
200
+ const subscription = {
201
+ 'id': id,
202
+ };
203
+ const url = this.urls['api']['ws'][tradeType] + '/' + tail;
204
+ return await this.watch(url, messageHash, request, messageHash, subscription);
205
+ }
206
+ /**
207
+ * @ignore
208
+ * @method
209
+ * @description Connects to a websocket channel
210
+ * @see https://doc.xt.com/#websocket_privaterequestFormat
211
+ * @see https://doc.xt.com/#futures_market_websocket_v2base
212
+ * @param {string} messageHash the message hash of the subscription
213
+ * @param {string} name name of the channel
214
+ * @param {string} access public or private
215
+ * @param {string} methodName the name of the CCXT class method
216
+ * @param {string} topic topic of the subscription
217
+ * @param {object} [market] CCXT market
218
+ * @param {string[]} [symbols] unified market symbols
219
+ * @param {object} params extra parameters specific to the xt api
220
+ * @param {object} subscriptionParams extra parameters specific to the subscription
221
+ * @returns {object} data from the websocket stream
222
+ */
223
+ async unSubscribe(messageHash, name, access, methodName, topic, market = undefined, symbols = undefined, params = {}, subscriptionParams = {}) {
224
+ const privateAccess = access === 'private';
225
+ let type = undefined;
226
+ [type, params] = this.handleMarketTypeAndParams(methodName, market, params);
227
+ const isContract = (type !== 'spot');
228
+ const id = this.numberToString(this.milliseconds()) + name; // call back ID
229
+ const unsubscribe = {
230
+ 'method': isContract ? 'UNSUBSCRIBE' : 'unsubscribe',
231
+ 'id': id,
232
+ };
233
+ if (privateAccess) {
234
+ if (!isContract) {
235
+ unsubscribe['params'] = [name];
236
+ unsubscribe['listenKey'] = await this.getListenKey(isContract);
237
+ }
238
+ else {
239
+ const listenKey = await this.getListenKey(isContract);
240
+ const param = name + '@' + listenKey;
241
+ unsubscribe['params'] = [param];
242
+ }
243
+ }
244
+ else {
245
+ unsubscribe['params'] = [name];
246
+ }
247
+ const tradeType = isContract ? 'contract' : 'spot';
248
+ let subMessageHash = name + '::' + tradeType;
249
+ if (symbols !== undefined) {
250
+ subMessageHash = subMessageHash + '::' + symbols.join(',');
251
+ }
252
+ const request = this.extend(unsubscribe, params);
253
+ let tail = access;
254
+ if (isContract) {
255
+ tail = privateAccess ? 'user' : 'market';
256
+ }
193
257
  const url = this.urls['api']['ws'][tradeType] + '/' + tail;
194
- return await this.watch(url, messageHash, request, messageHash);
258
+ const subscription = {
259
+ 'unsubscribe': true,
260
+ 'id': id,
261
+ 'subMessageHashes': [subMessageHash],
262
+ 'messageHashes': [messageHash],
263
+ 'symbols': symbols,
264
+ 'topic': topic,
265
+ };
266
+ return await this.watch(url, messageHash, this.extend(request, params), messageHash, this.extend(subscription, subscriptionParams));
195
267
  }
196
268
  /**
197
269
  * @method
@@ -216,7 +288,29 @@ export default class xt extends xtRest {
216
288
  }
217
289
  /**
218
290
  * @method
219
- * @name xt#watchTicker
291
+ * @name xt#unWatchTicker
292
+ * @description stops watching a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
293
+ * @see https://doc.xt.com/#websocket_publictickerRealTime
294
+ * @see https://doc.xt.com/#futures_market_websocket_v2tickerRealTime
295
+ * @see https://doc.xt.com/#futures_market_websocket_v2aggTickerRealTime
296
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
297
+ * @param {object} params extra parameters specific to the xt api endpoint
298
+ * @param {string} [params.method] 'agg_ticker' (contract only) or 'ticker', default = 'ticker' - the endpoint that will be streamed
299
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
300
+ */
301
+ async unWatchTicker(symbol, params = {}) {
302
+ await this.loadMarkets();
303
+ const market = this.market(symbol);
304
+ const options = this.safeDict(this.options, 'unWatchTicker');
305
+ const defaultMethod = this.safeString(options, 'method', 'ticker');
306
+ const method = this.safeString(params, 'method', defaultMethod);
307
+ const name = method + '@' + market['id'];
308
+ const messageHash = 'unsubscribe::' + name;
309
+ return await this.unSubscribe(messageHash, name, 'public', 'unWatchTicker', defaultMethod, market, undefined, params);
310
+ }
311
+ /**
312
+ * @method
313
+ * @name xt#watchTickers
220
314
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
221
315
  * @see https://doc.xt.com/#websocket_publicallTicker
222
316
  * @see https://doc.xt.com/#futures_market_websocket_v2allTicker
@@ -231,6 +325,7 @@ export default class xt extends xtRest {
231
325
  const options = this.safeDict(this.options, 'watchTickers');
232
326
  const defaultMethod = this.safeString(options, 'method', 'tickers');
233
327
  const name = this.safeString(params, 'method', defaultMethod);
328
+ symbols = this.marketSymbols(symbols);
234
329
  let market = undefined;
235
330
  if (symbols !== undefined) {
236
331
  market = this.market(symbols[0]);
@@ -243,7 +338,34 @@ export default class xt extends xtRest {
243
338
  }
244
339
  /**
245
340
  * @method
246
- * @name hitbtc#watchOHLCV
341
+ * @name xt#unWatchTickers
342
+ * @description stops watching a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
343
+ * @see https://doc.xt.com/#websocket_publicallTicker
344
+ * @see https://doc.xt.com/#futures_market_websocket_v2allTicker
345
+ * @see https://doc.xt.com/#futures_market_websocket_v2allAggTicker
346
+ * @param {string} [symbols] unified market symbols
347
+ * @param {object} params extra parameters specific to the xt api endpoint
348
+ * @param {string} [params.method] 'agg_tickers' (contract only) or 'tickers', default = 'tickers' - the endpoint that will be streamed
349
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
350
+ */
351
+ async unWatchTickers(symbols = undefined, params = {}) {
352
+ await this.loadMarkets();
353
+ const options = this.safeDict(this.options, 'unWatchTickers');
354
+ const defaultMethod = this.safeString(options, 'method', 'tickers');
355
+ const name = this.safeString(params, 'method', defaultMethod);
356
+ if (symbols !== undefined) {
357
+ throw new NotSupported(this.id + ' unWatchTickers() does not support symbols argument, unsubscribtion is for all tickers at once only');
358
+ }
359
+ const messageHash = 'unsubscribe::' + name;
360
+ const tickers = await this.unSubscribe(messageHash, name, 'public', 'unWatchTickers', 'ticker', undefined, symbols, params);
361
+ if (this.newUpdates) {
362
+ return tickers;
363
+ }
364
+ return this.filterByArray(this.tickers, 'symbol', symbols);
365
+ }
366
+ /**
367
+ * @method
368
+ * @name xt#watchOHLCV
247
369
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
248
370
  * @see https://doc.xt.com/#websocket_publicsymbolKline
249
371
  * @see https://doc.xt.com/#futures_market_websocket_v2symbolKline
@@ -264,6 +386,25 @@ export default class xt extends xtRest {
264
386
  }
265
387
  return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
266
388
  }
389
+ /**
390
+ * @method
391
+ * @name xt#unWatchOHLCV
392
+ * @description stops watching historical candlestick data containing the open, high, low, and close price, and the volume of a market
393
+ * @see https://doc.xt.com/#websocket_publicsymbolKline
394
+ * @see https://doc.xt.com/#futures_market_websocket_v2symbolKline
395
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
396
+ * @param {string} timeframe 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, or 1M
397
+ * @param {object} params extra parameters specific to the xt api endpoint
398
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
399
+ */
400
+ async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
401
+ await this.loadMarkets();
402
+ const market = this.market(symbol);
403
+ const name = 'kline@' + market['id'] + ',' + timeframe;
404
+ const messageHash = 'unsubscribe::' + name;
405
+ params['symbolsAndTimeframes'] = [[market['symbol'], timeframe]];
406
+ return await this.unSubscribe(messageHash, name, 'public', 'unWatchOHLCV', 'kline', market, undefined, params);
407
+ }
267
408
  /**
268
409
  * @method
269
410
  * @name xt#watchTrades
@@ -286,6 +427,23 @@ export default class xt extends xtRest {
286
427
  }
287
428
  return this.filterBySinceLimit(trades, since, limit, 'timestamp');
288
429
  }
430
+ /**
431
+ * @method
432
+ * @name xt#unWatchTrades
433
+ * @description stops watching the list of most recent trades for a particular symbol
434
+ * @see https://doc.xt.com/#websocket_publicdealRecord
435
+ * @see https://doc.xt.com/#futures_market_websocket_v2dealRecord
436
+ * @param {string} symbol unified symbol of the market to fetch trades for
437
+ * @param {object} params extra parameters specific to the xt api endpoint
438
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
439
+ */
440
+ async unWatchTrades(symbol, params = {}) {
441
+ await this.loadMarkets();
442
+ const market = this.market(symbol);
443
+ const name = 'trade@' + market['id'];
444
+ const messageHash = 'unsubscribe::' + name;
445
+ return await this.unSubscribe(messageHash, name, 'public', 'unWatchTrades', 'trade', market, undefined, params);
446
+ }
289
447
  /**
290
448
  * @method
291
449
  * @name xt#watchOrderBook
@@ -312,6 +470,31 @@ export default class xt extends xtRest {
312
470
  const orderbook = await this.subscribe(name, 'public', 'watchOrderBook', market, undefined, params);
313
471
  return orderbook.limit();
314
472
  }
473
+ /**
474
+ * @method
475
+ * @name xt#unWatchOrderBook
476
+ * @description stops watching information on open orders with bid (buy) and ask (sell) prices, volumes and other data
477
+ * @see https://doc.xt.com/#websocket_publiclimitDepth
478
+ * @see https://doc.xt.com/#websocket_publicincreDepth
479
+ * @see https://doc.xt.com/#futures_market_websocket_v2limitDepth
480
+ * @see https://doc.xt.com/#futures_market_websocket_v2increDepth
481
+ * @param {string} symbol unified symbol of the market to fetch the order book for
482
+ * @param {object} params extra parameters specific to the xt api endpoint
483
+ * @param {int} [params.levels] 5, 10, 20, or 50
484
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-book-structure} indexed by market symbols
485
+ */
486
+ async unWatchOrderBook(symbol, params = {}) {
487
+ await this.loadMarkets();
488
+ const market = this.market(symbol);
489
+ const levels = this.safeString(params, 'levels');
490
+ params = this.omit(params, 'levels');
491
+ let name = 'depth_update@' + market['id'];
492
+ if (levels !== undefined) {
493
+ name = 'depth@' + market['id'] + ',' + levels;
494
+ }
495
+ const messageHash = 'unsubscribe::' + name;
496
+ return await this.unSubscribe(messageHash, name, 'public', 'unWatchOrderBook', 'depth', market, undefined, params);
497
+ }
315
498
  /**
316
499
  * @method
317
500
  * @name xt#watchOrders
@@ -1206,11 +1389,42 @@ export default class xt extends xtRest {
1206
1389
  method.call(this, client, message);
1207
1390
  }
1208
1391
  }
1392
+ else {
1393
+ this.handleSubscriptionStatus(client, message);
1394
+ }
1209
1395
  }
1210
1396
  ping(client) {
1211
1397
  client.lastPong = this.milliseconds();
1212
1398
  return 'ping';
1213
1399
  }
1400
+ handleSubscriptionStatus(client, message) {
1401
+ //
1402
+ // {
1403
+ // id: '1763045665228ticker@eth_usdt',
1404
+ // code: 0,
1405
+ // msg: 'SUCCESS',
1406
+ // method: 'unsubscribe'
1407
+ // }
1408
+ //
1409
+ const method = this.safeStringLower(message, 'method');
1410
+ if (method === 'unsubscribe') {
1411
+ const id = this.safeString(message, 'id');
1412
+ const subscriptionsById = this.indexBy(client.subscriptions, 'id');
1413
+ const subscription = this.safeValue(subscriptionsById, id, {});
1414
+ this.handleUnSubscription(client, subscription);
1415
+ }
1416
+ return message;
1417
+ }
1418
+ handleUnSubscription(client, subscription) {
1419
+ const messageHashes = this.safeList(subscription, 'messageHashes', []);
1420
+ const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
1421
+ for (let j = 0; j < messageHashes.length; j++) {
1422
+ const unsubHash = messageHashes[j];
1423
+ const subHash = subMessageHashes[j];
1424
+ this.cleanUnsubscription(client, subHash, unsubHash);
1425
+ }
1426
+ this.cleanCache(subscription);
1427
+ }
1214
1428
  handleErrorMessage(client, message) {
1215
1429
  //
1216
1430
  // {
@@ -0,0 +1,90 @@
1
+ import _m0 from "protobufjs/minimal.js";
2
+ import { DeepPartial } from "../../../helpers.js";
3
+ /**
4
+ * Coin defines a token with a denomination and an amount.
5
+ *
6
+ * NOTE: The amount field is an Int which implements the custom method
7
+ * signatures required by gogoproto.
8
+ */
9
+ export interface Coin {
10
+ denom: string;
11
+ amount: string;
12
+ }
13
+ /**
14
+ * Coin defines a token with a denomination and an amount.
15
+ *
16
+ * NOTE: The amount field is an Int which implements the custom method
17
+ * signatures required by gogoproto.
18
+ */
19
+ export interface CoinSDKType {
20
+ denom: string;
21
+ amount: string;
22
+ }
23
+ /**
24
+ * DecCoin defines a token with a denomination and a decimal amount.
25
+ *
26
+ * NOTE: The amount field is an Dec which implements the custom method
27
+ * signatures required by gogoproto.
28
+ */
29
+ export interface DecCoin {
30
+ denom: string;
31
+ amount: string;
32
+ }
33
+ /**
34
+ * DecCoin defines a token with a denomination and a decimal amount.
35
+ *
36
+ * NOTE: The amount field is an Dec which implements the custom method
37
+ * signatures required by gogoproto.
38
+ */
39
+ export interface DecCoinSDKType {
40
+ denom: string;
41
+ amount: string;
42
+ }
43
+ /**
44
+ * IntProto defines a Protobuf wrapper around an Int object.
45
+ * Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
46
+ */
47
+ export interface IntProto {
48
+ int: string;
49
+ }
50
+ /**
51
+ * IntProto defines a Protobuf wrapper around an Int object.
52
+ * Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
53
+ */
54
+ export interface IntProtoSDKType {
55
+ int: string;
56
+ }
57
+ /**
58
+ * DecProto defines a Protobuf wrapper around a Dec object.
59
+ * Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
60
+ */
61
+ export interface DecProto {
62
+ dec: string;
63
+ }
64
+ /**
65
+ * DecProto defines a Protobuf wrapper around a Dec object.
66
+ * Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
67
+ */
68
+ export interface DecProtoSDKType {
69
+ dec: string;
70
+ }
71
+ export declare const Coin: {
72
+ encode(message: Coin, writer?: _m0.Writer): _m0.Writer;
73
+ decode(input: _m0.Reader | Uint8Array, length?: number): Coin;
74
+ fromPartial(object: DeepPartial<Coin>): Coin;
75
+ };
76
+ export declare const DecCoin: {
77
+ encode(message: DecCoin, writer?: _m0.Writer): _m0.Writer;
78
+ decode(input: _m0.Reader | Uint8Array, length?: number): DecCoin;
79
+ fromPartial(object: DeepPartial<DecCoin>): DecCoin;
80
+ };
81
+ export declare const IntProto: {
82
+ encode(message: IntProto, writer?: _m0.Writer): _m0.Writer;
83
+ decode(input: _m0.Reader | Uint8Array, length?: number): IntProto;
84
+ fromPartial(object: DeepPartial<IntProto>): IntProto;
85
+ };
86
+ export declare const DecProto: {
87
+ encode(message: DecProto, writer?: _m0.Writer): _m0.Writer;
88
+ decode(input: _m0.Reader | Uint8Array, length?: number): DecProto;
89
+ fromPartial(object: DeepPartial<DecProto>): DecProto;
90
+ };
@@ -0,0 +1,163 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import _m0 from "protobufjs/minimal.js";
8
+ function createBaseCoin() {
9
+ return {
10
+ denom: "",
11
+ amount: ""
12
+ };
13
+ }
14
+ export const Coin = {
15
+ encode(message, writer = _m0.Writer.create()) {
16
+ if (message.denom !== "") {
17
+ writer.uint32(10).string(message.denom);
18
+ }
19
+ if (message.amount !== "") {
20
+ writer.uint32(18).string(message.amount);
21
+ }
22
+ return writer;
23
+ },
24
+ decode(input, length) {
25
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
26
+ let end = length === undefined ? reader.len : reader.pos + length;
27
+ const message = createBaseCoin();
28
+ while (reader.pos < end) {
29
+ const tag = reader.uint32();
30
+ switch (tag >>> 3) {
31
+ case 1:
32
+ message.denom = reader.string();
33
+ break;
34
+ case 2:
35
+ message.amount = reader.string();
36
+ break;
37
+ default:
38
+ reader.skipType(tag & 7);
39
+ break;
40
+ }
41
+ }
42
+ return message;
43
+ },
44
+ fromPartial(object) {
45
+ const message = createBaseCoin();
46
+ message.denom = object.denom ?? "";
47
+ message.amount = object.amount ?? "";
48
+ return message;
49
+ }
50
+ };
51
+ function createBaseDecCoin() {
52
+ return {
53
+ denom: "",
54
+ amount: ""
55
+ };
56
+ }
57
+ export const DecCoin = {
58
+ encode(message, writer = _m0.Writer.create()) {
59
+ if (message.denom !== "") {
60
+ writer.uint32(10).string(message.denom);
61
+ }
62
+ if (message.amount !== "") {
63
+ writer.uint32(18).string(message.amount);
64
+ }
65
+ return writer;
66
+ },
67
+ decode(input, length) {
68
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
69
+ let end = length === undefined ? reader.len : reader.pos + length;
70
+ const message = createBaseDecCoin();
71
+ while (reader.pos < end) {
72
+ const tag = reader.uint32();
73
+ switch (tag >>> 3) {
74
+ case 1:
75
+ message.denom = reader.string();
76
+ break;
77
+ case 2:
78
+ message.amount = reader.string();
79
+ break;
80
+ default:
81
+ reader.skipType(tag & 7);
82
+ break;
83
+ }
84
+ }
85
+ return message;
86
+ },
87
+ fromPartial(object) {
88
+ const message = createBaseDecCoin();
89
+ message.denom = object.denom ?? "";
90
+ message.amount = object.amount ?? "";
91
+ return message;
92
+ }
93
+ };
94
+ function createBaseIntProto() {
95
+ return {
96
+ int: ""
97
+ };
98
+ }
99
+ export const IntProto = {
100
+ encode(message, writer = _m0.Writer.create()) {
101
+ if (message.int !== "") {
102
+ writer.uint32(10).string(message.int);
103
+ }
104
+ return writer;
105
+ },
106
+ decode(input, length) {
107
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
108
+ let end = length === undefined ? reader.len : reader.pos + length;
109
+ const message = createBaseIntProto();
110
+ while (reader.pos < end) {
111
+ const tag = reader.uint32();
112
+ switch (tag >>> 3) {
113
+ case 1:
114
+ message.int = reader.string();
115
+ break;
116
+ default:
117
+ reader.skipType(tag & 7);
118
+ break;
119
+ }
120
+ }
121
+ return message;
122
+ },
123
+ fromPartial(object) {
124
+ const message = createBaseIntProto();
125
+ message.int = object.int ?? "";
126
+ return message;
127
+ }
128
+ };
129
+ function createBaseDecProto() {
130
+ return {
131
+ dec: ""
132
+ };
133
+ }
134
+ export const DecProto = {
135
+ encode(message, writer = _m0.Writer.create()) {
136
+ if (message.dec !== "") {
137
+ writer.uint32(10).string(message.dec);
138
+ }
139
+ return writer;
140
+ },
141
+ decode(input, length) {
142
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
143
+ let end = length === undefined ? reader.len : reader.pos + length;
144
+ const message = createBaseDecProto();
145
+ while (reader.pos < end) {
146
+ const tag = reader.uint32();
147
+ switch (tag >>> 3) {
148
+ case 1:
149
+ message.dec = reader.string();
150
+ break;
151
+ default:
152
+ reader.skipType(tag & 7);
153
+ break;
154
+ }
155
+ }
156
+ return message;
157
+ },
158
+ fromPartial(object) {
159
+ const message = createBaseDecProto();
160
+ message.dec = object.dec ?? "";
161
+ return message;
162
+ }
163
+ };
@@ -0,0 +1,26 @@
1
+ import { Any, AnySDKType } from "../../../google/protobuf/any.js";
2
+ import _m0 from "protobufjs/minimal.js";
3
+ import { DeepPartial } from "../../../helpers.js";
4
+ /**
5
+ * LegacyAminoPubKey specifies a public key type
6
+ * which nests multiple public keys and a threshold,
7
+ * it uses legacy amino address rules.
8
+ */
9
+ export interface LegacyAminoPubKey {
10
+ threshold: number;
11
+ publicKeys: Any[];
12
+ }
13
+ /**
14
+ * LegacyAminoPubKey specifies a public key type
15
+ * which nests multiple public keys and a threshold,
16
+ * it uses legacy amino address rules.
17
+ */
18
+ export interface LegacyAminoPubKeySDKType {
19
+ threshold: number;
20
+ public_keys: AnySDKType[];
21
+ }
22
+ export declare const LegacyAminoPubKey: {
23
+ encode(message: LegacyAminoPubKey, writer?: _m0.Writer): _m0.Writer;
24
+ decode(input: _m0.Reader | Uint8Array, length?: number): LegacyAminoPubKey;
25
+ fromPartial(object: DeepPartial<LegacyAminoPubKey>): LegacyAminoPubKey;
26
+ };
@@ -0,0 +1,51 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { Any } from "../../../google/protobuf/any.js";
8
+ import _m0 from "protobufjs/minimal.js";
9
+ function createBaseLegacyAminoPubKey() {
10
+ return {
11
+ threshold: 0,
12
+ publicKeys: []
13
+ };
14
+ }
15
+ export const LegacyAminoPubKey = {
16
+ encode(message, writer = _m0.Writer.create()) {
17
+ if (message.threshold !== 0) {
18
+ writer.uint32(8).uint32(message.threshold);
19
+ }
20
+ for (const v of message.publicKeys) {
21
+ Any.encode(v, writer.uint32(18).fork()).ldelim();
22
+ }
23
+ return writer;
24
+ },
25
+ decode(input, length) {
26
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
27
+ let end = length === undefined ? reader.len : reader.pos + length;
28
+ const message = createBaseLegacyAminoPubKey();
29
+ while (reader.pos < end) {
30
+ const tag = reader.uint32();
31
+ switch (tag >>> 3) {
32
+ case 1:
33
+ message.threshold = reader.uint32();
34
+ break;
35
+ case 2:
36
+ message.publicKeys.push(Any.decode(reader, reader.uint32()));
37
+ break;
38
+ default:
39
+ reader.skipType(tag & 7);
40
+ break;
41
+ }
42
+ }
43
+ return message;
44
+ },
45
+ fromPartial(object) {
46
+ const message = createBaseLegacyAminoPubKey();
47
+ message.threshold = object.threshold ?? 0;
48
+ message.publicKeys = object.publicKeys?.map(e => Any.fromPartial(e)) || [];
49
+ return message;
50
+ }
51
+ };
@@ -0,0 +1,48 @@
1
+ import _m0 from "protobufjs/minimal.js";
2
+ import { DeepPartial } from "../../../../helpers.js";
3
+ /**
4
+ * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey.
5
+ * See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
6
+ * signed and with which modes.
7
+ */
8
+ export interface MultiSignature {
9
+ signatures: Uint8Array[];
10
+ }
11
+ /**
12
+ * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey.
13
+ * See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
14
+ * signed and with which modes.
15
+ */
16
+ export interface MultiSignatureSDKType {
17
+ signatures: Uint8Array[];
18
+ }
19
+ /**
20
+ * CompactBitArray is an implementation of a space efficient bit array.
21
+ * This is used to ensure that the encoded data takes up a minimal amount of
22
+ * space after proto encoding.
23
+ * This is not thread safe, and is not intended for concurrent usage.
24
+ */
25
+ export interface CompactBitArray {
26
+ extraBitsStored: number;
27
+ elems: Uint8Array;
28
+ }
29
+ /**
30
+ * CompactBitArray is an implementation of a space efficient bit array.
31
+ * This is used to ensure that the encoded data takes up a minimal amount of
32
+ * space after proto encoding.
33
+ * This is not thread safe, and is not intended for concurrent usage.
34
+ */
35
+ export interface CompactBitArraySDKType {
36
+ extra_bits_stored: number;
37
+ elems: Uint8Array;
38
+ }
39
+ export declare const MultiSignature: {
40
+ encode(message: MultiSignature, writer?: _m0.Writer): _m0.Writer;
41
+ decode(input: _m0.Reader | Uint8Array, length?: number): MultiSignature;
42
+ fromPartial(object: DeepPartial<MultiSignature>): MultiSignature;
43
+ };
44
+ export declare const CompactBitArray: {
45
+ encode(message: CompactBitArray, writer?: _m0.Writer): _m0.Writer;
46
+ decode(input: _m0.Reader | Uint8Array, length?: number): CompactBitArray;
47
+ fromPartial(object: DeepPartial<CompactBitArray>): CompactBitArray;
48
+ };