ccxt 4.4.82 → 4.4.85

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 (103) hide show
  1. package/README.md +5 -7
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +1 -9
  4. package/dist/cjs/src/apex.js +2 -1
  5. package/dist/cjs/src/base/Exchange.js +15 -2
  6. package/dist/cjs/src/bitget.js +1 -3
  7. package/dist/cjs/src/bitrue.js +14 -35
  8. package/dist/cjs/src/bitso.js +33 -0
  9. package/dist/cjs/src/bitstamp.js +33 -0
  10. package/dist/cjs/src/blofin.js +154 -13
  11. package/dist/cjs/src/btcbox.js +25 -5
  12. package/dist/cjs/src/bybit.js +16 -40
  13. package/dist/cjs/src/cex.js +2 -4
  14. package/dist/cjs/src/coinbase.js +56 -40
  15. package/dist/cjs/src/coinbaseexchange.js +142 -32
  16. package/dist/cjs/src/coincatch.js +14 -67
  17. package/dist/cjs/src/coinex.js +29 -32
  18. package/dist/cjs/src/coinlist.js +16 -15
  19. package/dist/cjs/src/coinmetro.js +22 -11
  20. package/dist/cjs/src/coinone.js +8 -10
  21. package/dist/cjs/src/coinsph.js +126 -1
  22. package/dist/cjs/src/cryptocom.js +111 -1
  23. package/dist/cjs/src/cryptomus.js +43 -89
  24. package/dist/cjs/src/delta.js +76 -36
  25. package/dist/cjs/src/derive.js +46 -10
  26. package/dist/cjs/src/ellipx.js +175 -79
  27. package/dist/cjs/src/gate.js +1 -1
  28. package/dist/cjs/src/gemini.js +3 -5
  29. package/dist/cjs/src/hitbtc.js +56 -69
  30. package/dist/cjs/src/hyperliquid.js +2 -2
  31. package/dist/cjs/src/kraken.js +29 -24
  32. package/dist/cjs/src/kucoinfutures.js +6 -0
  33. package/dist/cjs/src/lbank.js +1 -1
  34. package/dist/cjs/src/paradex.js +119 -3
  35. package/dist/cjs/src/pro/binance.js +31 -33
  36. package/dist/cjs/src/pro/bithumb.js +5 -3
  37. package/dist/cjs/src/pro/kraken.js +289 -79
  38. package/dist/cjs/src/pro/mexc.js +302 -8
  39. package/dist/cjs/src/pro/poloniex.js +6 -2
  40. package/examples/js/cli.js +127 -13
  41. package/js/ccxt.d.ts +2 -11
  42. package/js/ccxt.js +2 -8
  43. package/js/src/abstract/blofin.d.ts +8 -0
  44. package/js/src/abstract/btcbox.d.ts +1 -0
  45. package/js/src/apex.js +2 -1
  46. package/js/src/base/Exchange.d.ts +15 -1
  47. package/js/src/base/Exchange.js +15 -2
  48. package/js/src/base/types.d.ts +3 -0
  49. package/js/src/bitget.js +1 -3
  50. package/js/src/bitrue.js +14 -35
  51. package/js/src/bitso.js +33 -0
  52. package/js/src/bitstamp.js +33 -0
  53. package/js/src/blofin.d.ts +42 -2
  54. package/js/src/blofin.js +154 -13
  55. package/js/src/btcbox.js +25 -5
  56. package/js/src/bybit.js +16 -40
  57. package/js/src/cex.js +2 -4
  58. package/js/src/coinbase.js +56 -40
  59. package/js/src/coinbaseexchange.js +142 -32
  60. package/js/src/coincatch.js +14 -67
  61. package/js/src/coinex.js +28 -29
  62. package/js/src/coinlist.js +16 -15
  63. package/js/src/coinmetro.js +22 -11
  64. package/js/src/coinone.js +8 -10
  65. package/js/src/coinsph.d.ts +10 -1
  66. package/js/src/coinsph.js +126 -1
  67. package/js/src/cryptocom.d.ts +10 -1
  68. package/js/src/cryptocom.js +111 -1
  69. package/js/src/cryptomus.js +43 -89
  70. package/js/src/delta.js +76 -36
  71. package/js/src/derive.js +46 -10
  72. package/js/src/ellipx.d.ts +2 -3
  73. package/js/src/ellipx.js +175 -80
  74. package/js/src/gate.js +1 -1
  75. package/js/src/gemini.js +3 -5
  76. package/js/src/hitbtc.js +56 -69
  77. package/js/src/hyperliquid.js +2 -2
  78. package/js/src/kraken.js +29 -24
  79. package/js/src/kucoinfutures.d.ts +1 -0
  80. package/js/src/kucoinfutures.js +6 -0
  81. package/js/src/lbank.js +1 -1
  82. package/js/src/paradex.d.ts +12 -1
  83. package/js/src/paradex.js +119 -3
  84. package/js/src/pro/binance.d.ts +26 -26
  85. package/js/src/pro/binance.js +31 -33
  86. package/js/src/pro/bithumb.js +5 -3
  87. package/js/src/pro/kraken.d.ts +7 -6
  88. package/js/src/pro/kraken.js +290 -80
  89. package/js/src/pro/mexc.d.ts +58 -0
  90. package/js/src/pro/mexc.js +302 -8
  91. package/js/src/pro/poloniex.d.ts +1 -1
  92. package/js/src/pro/poloniex.js +6 -2
  93. package/package.json +1 -1
  94. package/js/src/abstract/bl3p.d.ts +0 -22
  95. package/js/src/abstract/bl3p.js +0 -11
  96. package/js/src/abstract/idex.d.ts +0 -29
  97. package/js/src/abstract/idex.js +0 -11
  98. package/js/src/bl3p.d.ts +0 -116
  99. package/js/src/bl3p.js +0 -552
  100. package/js/src/idex.d.ts +0 -312
  101. package/js/src/idex.js +0 -1961
  102. package/js/src/pro/idex.d.ts +0 -81
  103. package/js/src/pro/idex.js +0 -720
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import krakenRest from '../kraken.js';
9
- import { ExchangeError, BadSymbol, PermissionDenied, AccountSuspended, BadRequest, InsufficientFunds, InvalidOrder, OrderNotFound, NotSupported, RateLimitExceeded, ExchangeNotAvailable, ChecksumError, AuthenticationError } from '../base/errors.js';
9
+ import { ExchangeError, BadSymbol, PermissionDenied, AccountSuspended, BadRequest, InsufficientFunds, InvalidOrder, OrderNotFound, NotSupported, RateLimitExceeded, ExchangeNotAvailable, ChecksumError, AuthenticationError, ArgumentsRequired } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  import { Precise } from '../base/Precise.js';
12
12
  // ---------------------------------------------------------------------------
@@ -112,11 +112,172 @@ export default class kraken extends krakenRest {
112
112
  },
113
113
  });
114
114
  }
115
+ orderRequestWs(method, symbol, type, request, amount, price = undefined, params = {}) {
116
+ const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
117
+ if (isLimitOrder) {
118
+ if (price === undefined) {
119
+ throw new ArgumentsRequired(this.id + ' limit orders require a price argument');
120
+ }
121
+ request['params']['limit_price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
122
+ }
123
+ const isMarket = (type === 'market');
124
+ let postOnly = undefined;
125
+ [postOnly, params] = this.handlePostOnly(isMarket, false, params);
126
+ if (postOnly) {
127
+ request['params']['post_only'] = true;
128
+ }
129
+ const clientOrderId = this.safeString(params, 'clientOrderId');
130
+ if (clientOrderId !== undefined) {
131
+ request['params']['cl_ord_id'] = clientOrderId;
132
+ }
133
+ const cost = this.safeString(params, 'cost');
134
+ if (cost !== undefined) {
135
+ request['params']['order_qty'] = this.parseToNumeric(this.costToPrecision(symbol, cost));
136
+ }
137
+ const stopLoss = this.safeDict(params, 'stopLoss', {});
138
+ const takeProfit = this.safeDict(params, 'takeProfit', {});
139
+ const presetStopLoss = this.safeString(stopLoss, 'triggerPrice');
140
+ const presetTakeProfit = this.safeString(takeProfit, 'triggerPrice');
141
+ const presetStopLossLimit = this.safeString(stopLoss, 'price');
142
+ const presetTakeProfitLimit = this.safeString(takeProfit, 'price');
143
+ const isPresetStopLoss = presetStopLoss !== undefined;
144
+ const isPresetTakeProfit = presetTakeProfit !== undefined;
145
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
146
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
147
+ const isStopLossPriceOrder = stopLossPrice !== undefined;
148
+ const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
149
+ const trailingAmount = this.safeString(params, 'trailingAmount');
150
+ const trailingPercent = this.safeString(params, 'trailingPercent');
151
+ const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
152
+ const trailingLimitPercent = this.safeString(params, 'trailingLimitPercent');
153
+ const isTrailingAmountOrder = trailingAmount !== undefined;
154
+ const isTrailingPercentOrder = trailingPercent !== undefined;
155
+ const isTrailingLimitAmountOrder = trailingLimitAmount !== undefined;
156
+ const isTrailingLimitPercentOrder = trailingLimitPercent !== undefined;
157
+ const offset = this.safeString(params, 'offset', ''); // can set this to - for minus
158
+ const trailingAmountString = (trailingAmount !== undefined) ? offset + this.numberToString(trailingAmount) : undefined;
159
+ const trailingPercentString = (trailingPercent !== undefined) ? offset + this.numberToString(trailingPercent) : undefined;
160
+ const trailingLimitAmountString = (trailingLimitAmount !== undefined) ? offset + this.numberToString(trailingLimitAmount) : undefined;
161
+ const trailingLimitPercentString = (trailingLimitPercent !== undefined) ? offset + this.numberToString(trailingLimitPercent) : undefined;
162
+ const priceType = (isTrailingPercentOrder || isTrailingLimitPercentOrder) ? 'pct' : 'quote';
163
+ if (method === 'createOrderWs') {
164
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
165
+ if (reduceOnly) {
166
+ request['params']['reduce_only'] = true;
167
+ }
168
+ const timeInForce = this.safeStringLower(params, 'timeInForce');
169
+ if (timeInForce !== undefined) {
170
+ request['params']['time_in_force'] = timeInForce;
171
+ }
172
+ params = this.omit(params, ['reduceOnly', 'timeInForce']);
173
+ if (isStopLossPriceOrder || isTakeProfitPriceOrder || isTrailingAmountOrder || isTrailingPercentOrder || isTrailingLimitAmountOrder || isTrailingLimitPercentOrder) {
174
+ request['params']['triggers'] = {};
175
+ }
176
+ if (isPresetStopLoss || isPresetTakeProfit) {
177
+ request['params']['conditional'] = {};
178
+ if (isPresetStopLoss) {
179
+ request['params']['conditional']['order_type'] = 'stop-loss';
180
+ request['params']['conditional']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetStopLoss));
181
+ }
182
+ else if (isPresetTakeProfit) {
183
+ request['params']['conditional']['order_type'] = 'take-profit';
184
+ request['params']['conditional']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetTakeProfit));
185
+ }
186
+ if (presetStopLossLimit !== undefined) {
187
+ request['params']['conditional']['order_type'] = 'stop-loss-limit';
188
+ request['params']['conditional']['limit_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetStopLossLimit));
189
+ }
190
+ else if (presetTakeProfitLimit !== undefined) {
191
+ request['params']['conditional']['order_type'] = 'take-profit-limit';
192
+ request['params']['conditional']['limit_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetTakeProfitLimit));
193
+ }
194
+ params = this.omit(params, ['stopLoss', 'takeProfit']);
195
+ }
196
+ else if (isStopLossPriceOrder || isTakeProfitPriceOrder) {
197
+ if (isStopLossPriceOrder) {
198
+ request['params']['triggers']['price'] = this.parseToNumeric(this.priceToPrecision(symbol, stopLossPrice));
199
+ if (isLimitOrder) {
200
+ request['params']['order_type'] = 'stop-loss-limit';
201
+ }
202
+ else {
203
+ request['params']['order_type'] = 'stop-loss';
204
+ }
205
+ }
206
+ else {
207
+ request['params']['triggers']['price'] = this.parseToNumeric(this.priceToPrecision(symbol, takeProfitPrice));
208
+ if (isLimitOrder) {
209
+ request['params']['order_type'] = 'take-profit-limit';
210
+ }
211
+ else {
212
+ request['params']['order_type'] = 'take-profit';
213
+ }
214
+ }
215
+ }
216
+ else if (isTrailingAmountOrder || isTrailingPercentOrder || isTrailingLimitAmountOrder || isTrailingLimitPercentOrder) {
217
+ request['params']['triggers']['price_type'] = priceType;
218
+ if (!isLimitOrder && (isTrailingAmountOrder || isTrailingPercentOrder)) {
219
+ request['params']['order_type'] = 'trailing-stop';
220
+ if (isTrailingAmountOrder) {
221
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingAmountString);
222
+ }
223
+ else {
224
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingPercentString);
225
+ }
226
+ }
227
+ else {
228
+ // trailing limit orders are not conventionally supported because the static limit_price_type param is not available for trailing-stop-limit orders
229
+ request['params']['limit_price_type'] = priceType;
230
+ request['params']['order_type'] = 'trailing-stop-limit';
231
+ if (isTrailingLimitAmountOrder) {
232
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingLimitAmountString);
233
+ }
234
+ else {
235
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingLimitPercentString);
236
+ }
237
+ }
238
+ }
239
+ }
240
+ else if (method === 'editOrderWs') {
241
+ if (isPresetStopLoss || isPresetTakeProfit) {
242
+ throw new NotSupported(this.id + ' editing the stopLoss and takeProfit on existing orders is currently not supported');
243
+ }
244
+ if (isStopLossPriceOrder || isTakeProfitPriceOrder) {
245
+ if (isStopLossPriceOrder) {
246
+ request['params']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, stopLossPrice));
247
+ }
248
+ else {
249
+ request['params']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, takeProfitPrice));
250
+ }
251
+ }
252
+ else if (isTrailingAmountOrder || isTrailingPercentOrder || isTrailingLimitAmountOrder || isTrailingLimitPercentOrder) {
253
+ request['params']['trigger_price_type'] = priceType;
254
+ if (!isLimitOrder && (isTrailingAmountOrder || isTrailingPercentOrder)) {
255
+ if (isTrailingAmountOrder) {
256
+ request['params']['trigger_price'] = this.parseToNumeric(trailingAmountString);
257
+ }
258
+ else {
259
+ request['params']['trigger_price'] = this.parseToNumeric(trailingPercentString);
260
+ }
261
+ }
262
+ else {
263
+ request['params']['limit_price_type'] = priceType;
264
+ if (isTrailingLimitAmountOrder) {
265
+ request['params']['trigger_price'] = this.parseToNumeric(trailingLimitAmountString);
266
+ }
267
+ else {
268
+ request['params']['trigger_price'] = this.parseToNumeric(trailingLimitPercentString);
269
+ }
270
+ }
271
+ }
272
+ }
273
+ params = this.omit(params, ['clientOrderId', 'cost', 'offset', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingLimitAmount', 'trailingLimitPercent']);
274
+ return [request, params];
275
+ }
115
276
  /**
116
277
  * @method
117
278
  * @name kraken#createOrderWs
118
- * @see https://docs.kraken.com/api/docs/websocket-v1/addorder
119
279
  * @description create a trade order
280
+ * @see https://docs.kraken.com/api/docs/websocket-v2/add_order
120
281
  * @param {string} symbol unified symbol of the market to create an order in
121
282
  * @param {string} type 'market' or 'limit'
122
283
  * @param {string} side 'buy' or 'sell'
@@ -129,50 +290,60 @@ export default class kraken extends krakenRest {
129
290
  await this.loadMarkets();
130
291
  const token = await this.authenticate();
131
292
  const market = this.market(symbol);
132
- const url = this.urls['api']['ws']['private'];
293
+ const url = this.urls['api']['ws']['privateV2'];
133
294
  const requestId = this.requestId();
134
295
  const messageHash = requestId;
135
296
  let request = {
136
- 'event': 'addOrder',
137
- 'token': token,
138
- 'reqid': requestId,
139
- 'ordertype': type,
140
- 'type': side,
141
- 'pair': market['wsId'],
142
- 'volume': this.amountToPrecision(symbol, amount),
297
+ 'method': 'add_order',
298
+ 'params': {
299
+ 'order_type': type,
300
+ 'side': side,
301
+ 'order_qty': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
302
+ 'symbol': market['symbol'],
303
+ 'token': token,
304
+ },
305
+ 'req_id': requestId,
143
306
  };
144
- [request, params] = this.orderRequest('createOrderWs', symbol, type, request, amount, price, params);
307
+ [request, params] = this.orderRequestWs('createOrderWs', symbol, type, request, amount, price, params);
145
308
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
146
309
  }
147
310
  handleCreateEditOrder(client, message) {
148
311
  //
149
312
  // createOrder
150
- // {
151
- // "descr": "sell 0.00010000 XBTUSDT @ market",
152
- // "event": "addOrderStatus",
153
- // "reqid": 1,
154
- // "status": "ok",
155
- // "txid": "OAVXZH-XIE54-JCYYDG"
156
- // }
313
+ // {
314
+ // "method": "add_order",
315
+ // "req_id": 1,
316
+ // "result": {
317
+ // "order_id": "OXM2QD-EALR2-YBAVEU"
318
+ // },
319
+ // "success": true,
320
+ // "time_in": "2025-05-13T10:12:13.876173Z",
321
+ // "time_out": "2025-05-13T10:12:13.890137Z"
322
+ // }
323
+ //
157
324
  // editOrder
158
- // {
159
- // "descr": "order edited price = 9000.00000000",
160
- // "event": "editOrderStatus",
161
- // "originaltxid": "O65KZW-J4AW3-VFS74A",
162
- // "reqid": 3,
163
- // "status": "ok",
164
- // "txid": "OTI672-HJFAO-XOIPPK"
165
- // }
325
+ // {
326
+ // "method": "amend_order",
327
+ // "req_id": 1,
328
+ // "result": {
329
+ // "amend_id": "TYDLSQ-OYNYU-3MNRER",
330
+ // "order_id": "OGL7HR-SWFO4-NRQTHO"
331
+ // },
332
+ // "success": true,
333
+ // "time_in": "2025-05-14T13:54:10.840342Z",
334
+ // "time_out": "2025-05-14T13:54:10.855046Z"
335
+ // }
166
336
  //
167
- const order = this.parseOrder(message);
168
- const messageHash = this.safeValue(message, 'reqid');
337
+ const result = this.safeDict(message, 'result', {});
338
+ const order = this.parseOrder(result);
339
+ const messageHash = this.safeValue2(message, 'reqid', 'req_id');
169
340
  client.resolve(order, messageHash);
170
341
  }
171
342
  /**
172
343
  * @method
173
344
  * @name kraken#editOrderWs
174
345
  * @description edit a trade order
175
- * @see https://docs.kraken.com/api/docs/websocket-v1/editorder
346
+ * @see https://docs.kraken.com/api/docs/websocket-v2/amend_order
176
347
  * @param {string} id order id
177
348
  * @param {string} symbol unified symbol of the market to create an order in
178
349
  * @param {string} type 'market' or 'limit'
@@ -185,21 +356,19 @@ export default class kraken extends krakenRest {
185
356
  async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
186
357
  await this.loadMarkets();
187
358
  const token = await this.authenticate();
188
- const market = this.market(symbol);
189
- const url = this.urls['api']['ws']['private'];
359
+ const url = this.urls['api']['ws']['privateV2'];
190
360
  const requestId = this.requestId();
191
361
  const messageHash = requestId;
192
362
  let request = {
193
- 'event': 'editOrder',
194
- 'token': token,
195
- 'reqid': requestId,
196
- 'orderid': id,
197
- 'pair': market['wsId'],
363
+ 'method': 'amend_order',
364
+ 'params': {
365
+ 'order_id': id,
366
+ 'order_qty': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
367
+ 'token': token,
368
+ },
369
+ 'req_id': requestId,
198
370
  };
199
- if (amount !== undefined) {
200
- request['volume'] = this.amountToPrecision(symbol, amount);
201
- }
202
- [request, params] = this.orderRequest('editOrderWs', symbol, type, request, amount, price, params);
371
+ [request, params] = this.orderRequestWs('editOrderWs', symbol, type, request, amount, price, params);
203
372
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
204
373
  }
205
374
  /**
@@ -208,21 +377,26 @@ export default class kraken extends krakenRest {
208
377
  * @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
209
378
  * @description cancel multiple orders
210
379
  * @param {string[]} ids order ids
211
- * @param {string} symbol unified market symbol, default is undefined
380
+ * @param {string} [symbol] unified market symbol, default is undefined
212
381
  * @param {object} [params] extra parameters specific to the exchange API endpoint
213
382
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
214
383
  */
215
384
  async cancelOrdersWs(ids, symbol = undefined, params = {}) {
385
+ if (symbol !== undefined) {
386
+ throw new NotSupported(this.id + ' cancelOrdersWs () does not support cancelling orders for a specific symbol.');
387
+ }
216
388
  await this.loadMarkets();
217
389
  const token = await this.authenticate();
218
- const url = this.urls['api']['ws']['private'];
390
+ const url = this.urls['api']['ws']['privateV2'];
219
391
  const requestId = this.requestId();
220
392
  const messageHash = requestId;
221
393
  const request = {
222
- 'event': 'cancelOrder',
223
- 'token': token,
224
- 'reqid': requestId,
225
- 'txid': ids,
394
+ 'method': 'cancel_order',
395
+ 'params': {
396
+ 'order_id': ids,
397
+ 'token': token,
398
+ },
399
+ 'req_id': requestId,
226
400
  };
227
401
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
228
402
  }
@@ -232,36 +406,43 @@ export default class kraken extends krakenRest {
232
406
  * @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
233
407
  * @description cancels an open order
234
408
  * @param {string} id order id
235
- * @param {string} symbol unified symbol of the market the order was made in
409
+ * @param {string} [symbol] unified symbol of the market the order was made in
236
410
  * @param {object} [params] extra parameters specific to the exchange API endpoint
237
411
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
238
412
  */
239
413
  async cancelOrderWs(id, symbol = undefined, params = {}) {
414
+ if (symbol !== undefined) {
415
+ throw new NotSupported(this.id + ' cancelOrderWs () does not support cancelling orders for a specific symbol.');
416
+ }
240
417
  await this.loadMarkets();
241
418
  const token = await this.authenticate();
242
- const url = this.urls['api']['ws']['private'];
419
+ const url = this.urls['api']['ws']['privateV2'];
243
420
  const requestId = this.requestId();
244
421
  const messageHash = requestId;
245
- const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId', id);
246
- params = this.omit(params, ['userref', 'clientOrderId']);
247
422
  const request = {
248
- 'event': 'cancelOrder',
249
- 'token': token,
250
- 'reqid': requestId,
251
- 'txid': [clientOrderId],
423
+ 'method': 'cancel_order',
424
+ 'params': {
425
+ 'order_id': [id],
426
+ 'token': token,
427
+ },
428
+ 'req_id': requestId,
252
429
  };
253
430
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
254
431
  }
255
432
  handleCancelOrder(client, message) {
256
433
  //
257
- // success
258
- // {
259
- // "event": "cancelOrderStatus",
260
- // "status": "ok"
261
- // "reqid": 1,
262
- // }
434
+ // {
435
+ // "method": "cancel_order",
436
+ // "req_id": 123456789,
437
+ // "result": {
438
+ // "order_id": "OKAGJC-YHIWK-WIOZWG"
439
+ // },
440
+ // "success": true,
441
+ // "time_in": "2023-09-21T14:36:57.428972Z",
442
+ // "time_out": "2023-09-21T14:36:57.437952Z"
443
+ // }
263
444
  //
264
- const reqId = this.safeValue(message, 'reqid');
445
+ const reqId = this.safeValue(message, 'req_id');
265
446
  client.resolve(message, reqId);
266
447
  }
267
448
  /**
@@ -269,7 +450,7 @@ export default class kraken extends krakenRest {
269
450
  * @name kraken#cancelAllOrdersWs
270
451
  * @see https://docs.kraken.com/api/docs/websocket-v1/cancelall
271
452
  * @description cancel all open orders
272
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
453
+ * @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
273
454
  * @param {object} [params] extra parameters specific to the exchange API endpoint
274
455
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
275
456
  */
@@ -279,26 +460,32 @@ export default class kraken extends krakenRest {
279
460
  }
280
461
  await this.loadMarkets();
281
462
  const token = await this.authenticate();
282
- const url = this.urls['api']['ws']['private'];
463
+ const url = this.urls['api']['ws']['privateV2'];
283
464
  const requestId = this.requestId();
284
465
  const messageHash = requestId;
285
466
  const request = {
286
- 'event': 'cancelAll',
287
- 'token': token,
288
- 'reqid': requestId,
467
+ 'method': 'cancel_all',
468
+ 'params': {
469
+ 'token': token,
470
+ },
471
+ 'req_id': requestId,
289
472
  };
290
473
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
291
474
  }
292
475
  handleCancelAllOrders(client, message) {
293
476
  //
294
- // {
295
- // "count": 2,
296
- // "event": "cancelAllStatus",
297
- // "status": "ok",
298
- // "reqId": 1
299
- // }
477
+ // {
478
+ // "method": "cancel_all",
479
+ // "req_id": 123456789,
480
+ // "result": {
481
+ // "count": 1
482
+ // },
483
+ // "success": true,
484
+ // "time_in": "2023-09-21T14:36:57.428972Z",
485
+ // "time_out": "2023-09-21T14:36:57.437952Z"
486
+ // }
300
487
  //
301
- const reqId = this.safeValue(message, 'reqid');
488
+ const reqId = this.safeValue(message, 'req_id');
302
489
  client.resolve(message, reqId);
303
490
  }
304
491
  handleTicker(client, message, subscription) {
@@ -891,6 +1078,20 @@ export default class kraken extends krakenRest {
891
1078
  // "version": "0.2.0"
892
1079
  // }
893
1080
  //
1081
+ // v2
1082
+ // {
1083
+ // channel: 'status',
1084
+ // type: 'update',
1085
+ // data: [
1086
+ // {
1087
+ // version: '2.0.10',
1088
+ // system: 'online',
1089
+ // api_version: 'v2',
1090
+ // connection_id: 6447481662169813000
1091
+ // }
1092
+ // ]
1093
+ // }
1094
+ //
894
1095
  return message;
895
1096
  }
896
1097
  async authenticate(params = {}) {
@@ -1520,9 +1721,18 @@ export default class kraken extends krakenRest {
1520
1721
  // "subscription": { name: "ticker" }
1521
1722
  // }
1522
1723
  //
1523
- const errorMessage = this.safeString(message, 'errorMessage');
1724
+ // v2
1725
+ // {
1726
+ // "error": "Unsupported field: 'price' for the given msg type: add order",
1727
+ // "method": "add_order",
1728
+ // "success": false,
1729
+ // "time_in": "2025-05-13T08:59:44.803511Z",
1730
+ // "time_out": "2025-05-13T08:59:44.803542Z'
1731
+ // }
1732
+ //
1733
+ const errorMessage = this.safeString2(message, 'errorMessage', 'error');
1524
1734
  if (errorMessage !== undefined) {
1525
- const requestId = this.safeValue(message, 'reqid');
1735
+ const requestId = this.safeValue2(message, 'reqid', 'req_id');
1526
1736
  if (requestId !== undefined) {
1527
1737
  const broad = this.exceptions['ws']['broad'];
1528
1738
  const broadKey = this.findBroadlyMatchedKey(broad, errorMessage);
@@ -1575,15 +1785,15 @@ export default class kraken extends krakenRest {
1575
1785
  }
1576
1786
  }
1577
1787
  if (this.handleErrorMessage(client, message)) {
1578
- const event = this.safeString(message, 'event');
1788
+ const event = this.safeString2(message, 'event', 'method');
1579
1789
  const methods = {
1580
1790
  'heartbeat': this.handleHeartbeat,
1581
1791
  'systemStatus': this.handleSystemStatus,
1582
1792
  'subscriptionStatus': this.handleSubscriptionStatus,
1583
- 'addOrderStatus': this.handleCreateEditOrder,
1584
- 'editOrderStatus': this.handleCreateEditOrder,
1585
- 'cancelOrderStatus': this.handleCancelOrder,
1586
- 'cancelAllStatus': this.handleCancelAllOrders,
1793
+ 'add_order': this.handleCreateEditOrder,
1794
+ 'amend_order': this.handleCreateEditOrder,
1795
+ 'cancel_order': this.handleCancelOrder,
1796
+ 'cancel_all': this.handleCancelAllOrders,
1587
1797
  };
1588
1798
  const method = this.safeValue(methods, event);
1589
1799
  if (method !== undefined) {
@@ -138,6 +138,64 @@ export default class mexc extends mexcRest {
138
138
  */
139
139
  watchBalance(params?: {}): Promise<Balances>;
140
140
  handleBalance(client: Client, message: any): void;
141
+ /**
142
+ * @method
143
+ * @name mexc#unWatchTicker
144
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
145
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
146
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
147
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
148
+ */
149
+ unWatchTicker(symbol: string, params?: {}): Promise<any>;
150
+ /**
151
+ * @method
152
+ * @name mexc#unWatchTickers
153
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
154
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
155
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
156
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
157
+ */
158
+ unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
159
+ /**
160
+ * @method
161
+ * @name mexc#unWatchBidsAsks
162
+ * @description unWatches best bid & ask for symbols
163
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
164
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
165
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
166
+ */
167
+ unWatchBidsAsks(symbols?: Strings, params?: {}): Promise<any>;
168
+ /**
169
+ * @method
170
+ * @name mexc#unWatchOHLCV
171
+ * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
172
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
173
+ * @param {string} timeframe the length of time each candle represents
174
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
175
+ * @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
176
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
177
+ */
178
+ unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
179
+ /**
180
+ * @method
181
+ * @name mexc#unWatchOrderBook
182
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
183
+ * @param {string} symbol unified array of symbols
184
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
185
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
186
+ */
187
+ unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
188
+ /**
189
+ * @method
190
+ * @name mexc#unWatchTrades
191
+ * @description unsubscribes from the trades channel
192
+ * @param {string} symbol unified symbol of the market to fetch trades for
193
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
194
+ * @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
195
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
196
+ */
197
+ unWatchTrades(symbol: string, params?: {}): Promise<any>;
198
+ handleUnsubscriptions(client: Client, messageHashes: string[]): void;
141
199
  authenticate(subscriptionHash: any, params?: {}): Promise<string>;
142
200
  keepAliveListenKey(listenKey: any, params?: {}): Promise<void>;
143
201
  handlePong(client: Client, message: any): any;