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
@@ -109,11 +109,172 @@ class kraken extends kraken$1 {
109
109
  },
110
110
  });
111
111
  }
112
+ orderRequestWs(method, symbol, type, request, amount, price = undefined, params = {}) {
113
+ const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
114
+ if (isLimitOrder) {
115
+ if (price === undefined) {
116
+ throw new errors.ArgumentsRequired(this.id + ' limit orders require a price argument');
117
+ }
118
+ request['params']['limit_price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
119
+ }
120
+ const isMarket = (type === 'market');
121
+ let postOnly = undefined;
122
+ [postOnly, params] = this.handlePostOnly(isMarket, false, params);
123
+ if (postOnly) {
124
+ request['params']['post_only'] = true;
125
+ }
126
+ const clientOrderId = this.safeString(params, 'clientOrderId');
127
+ if (clientOrderId !== undefined) {
128
+ request['params']['cl_ord_id'] = clientOrderId;
129
+ }
130
+ const cost = this.safeString(params, 'cost');
131
+ if (cost !== undefined) {
132
+ request['params']['order_qty'] = this.parseToNumeric(this.costToPrecision(symbol, cost));
133
+ }
134
+ const stopLoss = this.safeDict(params, 'stopLoss', {});
135
+ const takeProfit = this.safeDict(params, 'takeProfit', {});
136
+ const presetStopLoss = this.safeString(stopLoss, 'triggerPrice');
137
+ const presetTakeProfit = this.safeString(takeProfit, 'triggerPrice');
138
+ const presetStopLossLimit = this.safeString(stopLoss, 'price');
139
+ const presetTakeProfitLimit = this.safeString(takeProfit, 'price');
140
+ const isPresetStopLoss = presetStopLoss !== undefined;
141
+ const isPresetTakeProfit = presetTakeProfit !== undefined;
142
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
143
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
144
+ const isStopLossPriceOrder = stopLossPrice !== undefined;
145
+ const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
146
+ const trailingAmount = this.safeString(params, 'trailingAmount');
147
+ const trailingPercent = this.safeString(params, 'trailingPercent');
148
+ const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
149
+ const trailingLimitPercent = this.safeString(params, 'trailingLimitPercent');
150
+ const isTrailingAmountOrder = trailingAmount !== undefined;
151
+ const isTrailingPercentOrder = trailingPercent !== undefined;
152
+ const isTrailingLimitAmountOrder = trailingLimitAmount !== undefined;
153
+ const isTrailingLimitPercentOrder = trailingLimitPercent !== undefined;
154
+ const offset = this.safeString(params, 'offset', ''); // can set this to - for minus
155
+ const trailingAmountString = (trailingAmount !== undefined) ? offset + this.numberToString(trailingAmount) : undefined;
156
+ const trailingPercentString = (trailingPercent !== undefined) ? offset + this.numberToString(trailingPercent) : undefined;
157
+ const trailingLimitAmountString = (trailingLimitAmount !== undefined) ? offset + this.numberToString(trailingLimitAmount) : undefined;
158
+ const trailingLimitPercentString = (trailingLimitPercent !== undefined) ? offset + this.numberToString(trailingLimitPercent) : undefined;
159
+ const priceType = (isTrailingPercentOrder || isTrailingLimitPercentOrder) ? 'pct' : 'quote';
160
+ if (method === 'createOrderWs') {
161
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
162
+ if (reduceOnly) {
163
+ request['params']['reduce_only'] = true;
164
+ }
165
+ const timeInForce = this.safeStringLower(params, 'timeInForce');
166
+ if (timeInForce !== undefined) {
167
+ request['params']['time_in_force'] = timeInForce;
168
+ }
169
+ params = this.omit(params, ['reduceOnly', 'timeInForce']);
170
+ if (isStopLossPriceOrder || isTakeProfitPriceOrder || isTrailingAmountOrder || isTrailingPercentOrder || isTrailingLimitAmountOrder || isTrailingLimitPercentOrder) {
171
+ request['params']['triggers'] = {};
172
+ }
173
+ if (isPresetStopLoss || isPresetTakeProfit) {
174
+ request['params']['conditional'] = {};
175
+ if (isPresetStopLoss) {
176
+ request['params']['conditional']['order_type'] = 'stop-loss';
177
+ request['params']['conditional']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetStopLoss));
178
+ }
179
+ else if (isPresetTakeProfit) {
180
+ request['params']['conditional']['order_type'] = 'take-profit';
181
+ request['params']['conditional']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetTakeProfit));
182
+ }
183
+ if (presetStopLossLimit !== undefined) {
184
+ request['params']['conditional']['order_type'] = 'stop-loss-limit';
185
+ request['params']['conditional']['limit_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetStopLossLimit));
186
+ }
187
+ else if (presetTakeProfitLimit !== undefined) {
188
+ request['params']['conditional']['order_type'] = 'take-profit-limit';
189
+ request['params']['conditional']['limit_price'] = this.parseToNumeric(this.priceToPrecision(symbol, presetTakeProfitLimit));
190
+ }
191
+ params = this.omit(params, ['stopLoss', 'takeProfit']);
192
+ }
193
+ else if (isStopLossPriceOrder || isTakeProfitPriceOrder) {
194
+ if (isStopLossPriceOrder) {
195
+ request['params']['triggers']['price'] = this.parseToNumeric(this.priceToPrecision(symbol, stopLossPrice));
196
+ if (isLimitOrder) {
197
+ request['params']['order_type'] = 'stop-loss-limit';
198
+ }
199
+ else {
200
+ request['params']['order_type'] = 'stop-loss';
201
+ }
202
+ }
203
+ else {
204
+ request['params']['triggers']['price'] = this.parseToNumeric(this.priceToPrecision(symbol, takeProfitPrice));
205
+ if (isLimitOrder) {
206
+ request['params']['order_type'] = 'take-profit-limit';
207
+ }
208
+ else {
209
+ request['params']['order_type'] = 'take-profit';
210
+ }
211
+ }
212
+ }
213
+ else if (isTrailingAmountOrder || isTrailingPercentOrder || isTrailingLimitAmountOrder || isTrailingLimitPercentOrder) {
214
+ request['params']['triggers']['price_type'] = priceType;
215
+ if (!isLimitOrder && (isTrailingAmountOrder || isTrailingPercentOrder)) {
216
+ request['params']['order_type'] = 'trailing-stop';
217
+ if (isTrailingAmountOrder) {
218
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingAmountString);
219
+ }
220
+ else {
221
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingPercentString);
222
+ }
223
+ }
224
+ else {
225
+ // trailing limit orders are not conventionally supported because the static limit_price_type param is not available for trailing-stop-limit orders
226
+ request['params']['limit_price_type'] = priceType;
227
+ request['params']['order_type'] = 'trailing-stop-limit';
228
+ if (isTrailingLimitAmountOrder) {
229
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingLimitAmountString);
230
+ }
231
+ else {
232
+ request['params']['triggers']['price'] = this.parseToNumeric(trailingLimitPercentString);
233
+ }
234
+ }
235
+ }
236
+ }
237
+ else if (method === 'editOrderWs') {
238
+ if (isPresetStopLoss || isPresetTakeProfit) {
239
+ throw new errors.NotSupported(this.id + ' editing the stopLoss and takeProfit on existing orders is currently not supported');
240
+ }
241
+ if (isStopLossPriceOrder || isTakeProfitPriceOrder) {
242
+ if (isStopLossPriceOrder) {
243
+ request['params']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, stopLossPrice));
244
+ }
245
+ else {
246
+ request['params']['trigger_price'] = this.parseToNumeric(this.priceToPrecision(symbol, takeProfitPrice));
247
+ }
248
+ }
249
+ else if (isTrailingAmountOrder || isTrailingPercentOrder || isTrailingLimitAmountOrder || isTrailingLimitPercentOrder) {
250
+ request['params']['trigger_price_type'] = priceType;
251
+ if (!isLimitOrder && (isTrailingAmountOrder || isTrailingPercentOrder)) {
252
+ if (isTrailingAmountOrder) {
253
+ request['params']['trigger_price'] = this.parseToNumeric(trailingAmountString);
254
+ }
255
+ else {
256
+ request['params']['trigger_price'] = this.parseToNumeric(trailingPercentString);
257
+ }
258
+ }
259
+ else {
260
+ request['params']['limit_price_type'] = priceType;
261
+ if (isTrailingLimitAmountOrder) {
262
+ request['params']['trigger_price'] = this.parseToNumeric(trailingLimitAmountString);
263
+ }
264
+ else {
265
+ request['params']['trigger_price'] = this.parseToNumeric(trailingLimitPercentString);
266
+ }
267
+ }
268
+ }
269
+ }
270
+ params = this.omit(params, ['clientOrderId', 'cost', 'offset', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingLimitAmount', 'trailingLimitPercent']);
271
+ return [request, params];
272
+ }
112
273
  /**
113
274
  * @method
114
275
  * @name kraken#createOrderWs
115
- * @see https://docs.kraken.com/api/docs/websocket-v1/addorder
116
276
  * @description create a trade order
277
+ * @see https://docs.kraken.com/api/docs/websocket-v2/add_order
117
278
  * @param {string} symbol unified symbol of the market to create an order in
118
279
  * @param {string} type 'market' or 'limit'
119
280
  * @param {string} side 'buy' or 'sell'
@@ -126,50 +287,60 @@ class kraken extends kraken$1 {
126
287
  await this.loadMarkets();
127
288
  const token = await this.authenticate();
128
289
  const market = this.market(symbol);
129
- const url = this.urls['api']['ws']['private'];
290
+ const url = this.urls['api']['ws']['privateV2'];
130
291
  const requestId = this.requestId();
131
292
  const messageHash = requestId;
132
293
  let request = {
133
- 'event': 'addOrder',
134
- 'token': token,
135
- 'reqid': requestId,
136
- 'ordertype': type,
137
- 'type': side,
138
- 'pair': market['wsId'],
139
- 'volume': this.amountToPrecision(symbol, amount),
294
+ 'method': 'add_order',
295
+ 'params': {
296
+ 'order_type': type,
297
+ 'side': side,
298
+ 'order_qty': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
299
+ 'symbol': market['symbol'],
300
+ 'token': token,
301
+ },
302
+ 'req_id': requestId,
140
303
  };
141
- [request, params] = this.orderRequest('createOrderWs', symbol, type, request, amount, price, params);
304
+ [request, params] = this.orderRequestWs('createOrderWs', symbol, type, request, amount, price, params);
142
305
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
143
306
  }
144
307
  handleCreateEditOrder(client, message) {
145
308
  //
146
309
  // createOrder
147
- // {
148
- // "descr": "sell 0.00010000 XBTUSDT @ market",
149
- // "event": "addOrderStatus",
150
- // "reqid": 1,
151
- // "status": "ok",
152
- // "txid": "OAVXZH-XIE54-JCYYDG"
153
- // }
310
+ // {
311
+ // "method": "add_order",
312
+ // "req_id": 1,
313
+ // "result": {
314
+ // "order_id": "OXM2QD-EALR2-YBAVEU"
315
+ // },
316
+ // "success": true,
317
+ // "time_in": "2025-05-13T10:12:13.876173Z",
318
+ // "time_out": "2025-05-13T10:12:13.890137Z"
319
+ // }
320
+ //
154
321
  // editOrder
155
- // {
156
- // "descr": "order edited price = 9000.00000000",
157
- // "event": "editOrderStatus",
158
- // "originaltxid": "O65KZW-J4AW3-VFS74A",
159
- // "reqid": 3,
160
- // "status": "ok",
161
- // "txid": "OTI672-HJFAO-XOIPPK"
162
- // }
322
+ // {
323
+ // "method": "amend_order",
324
+ // "req_id": 1,
325
+ // "result": {
326
+ // "amend_id": "TYDLSQ-OYNYU-3MNRER",
327
+ // "order_id": "OGL7HR-SWFO4-NRQTHO"
328
+ // },
329
+ // "success": true,
330
+ // "time_in": "2025-05-14T13:54:10.840342Z",
331
+ // "time_out": "2025-05-14T13:54:10.855046Z"
332
+ // }
163
333
  //
164
- const order = this.parseOrder(message);
165
- const messageHash = this.safeValue(message, 'reqid');
334
+ const result = this.safeDict(message, 'result', {});
335
+ const order = this.parseOrder(result);
336
+ const messageHash = this.safeValue2(message, 'reqid', 'req_id');
166
337
  client.resolve(order, messageHash);
167
338
  }
168
339
  /**
169
340
  * @method
170
341
  * @name kraken#editOrderWs
171
342
  * @description edit a trade order
172
- * @see https://docs.kraken.com/api/docs/websocket-v1/editorder
343
+ * @see https://docs.kraken.com/api/docs/websocket-v2/amend_order
173
344
  * @param {string} id order id
174
345
  * @param {string} symbol unified symbol of the market to create an order in
175
346
  * @param {string} type 'market' or 'limit'
@@ -182,21 +353,19 @@ class kraken extends kraken$1 {
182
353
  async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
183
354
  await this.loadMarkets();
184
355
  const token = await this.authenticate();
185
- const market = this.market(symbol);
186
- const url = this.urls['api']['ws']['private'];
356
+ const url = this.urls['api']['ws']['privateV2'];
187
357
  const requestId = this.requestId();
188
358
  const messageHash = requestId;
189
359
  let request = {
190
- 'event': 'editOrder',
191
- 'token': token,
192
- 'reqid': requestId,
193
- 'orderid': id,
194
- 'pair': market['wsId'],
360
+ 'method': 'amend_order',
361
+ 'params': {
362
+ 'order_id': id,
363
+ 'order_qty': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
364
+ 'token': token,
365
+ },
366
+ 'req_id': requestId,
195
367
  };
196
- if (amount !== undefined) {
197
- request['volume'] = this.amountToPrecision(symbol, amount);
198
- }
199
- [request, params] = this.orderRequest('editOrderWs', symbol, type, request, amount, price, params);
368
+ [request, params] = this.orderRequestWs('editOrderWs', symbol, type, request, amount, price, params);
200
369
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
201
370
  }
202
371
  /**
@@ -205,21 +374,26 @@ class kraken extends kraken$1 {
205
374
  * @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
206
375
  * @description cancel multiple orders
207
376
  * @param {string[]} ids order ids
208
- * @param {string} symbol unified market symbol, default is undefined
377
+ * @param {string} [symbol] unified market symbol, default is undefined
209
378
  * @param {object} [params] extra parameters specific to the exchange API endpoint
210
379
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
211
380
  */
212
381
  async cancelOrdersWs(ids, symbol = undefined, params = {}) {
382
+ if (symbol !== undefined) {
383
+ throw new errors.NotSupported(this.id + ' cancelOrdersWs () does not support cancelling orders for a specific symbol.');
384
+ }
213
385
  await this.loadMarkets();
214
386
  const token = await this.authenticate();
215
- const url = this.urls['api']['ws']['private'];
387
+ const url = this.urls['api']['ws']['privateV2'];
216
388
  const requestId = this.requestId();
217
389
  const messageHash = requestId;
218
390
  const request = {
219
- 'event': 'cancelOrder',
220
- 'token': token,
221
- 'reqid': requestId,
222
- 'txid': ids,
391
+ 'method': 'cancel_order',
392
+ 'params': {
393
+ 'order_id': ids,
394
+ 'token': token,
395
+ },
396
+ 'req_id': requestId,
223
397
  };
224
398
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
225
399
  }
@@ -229,36 +403,43 @@ class kraken extends kraken$1 {
229
403
  * @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
230
404
  * @description cancels an open order
231
405
  * @param {string} id order id
232
- * @param {string} symbol unified symbol of the market the order was made in
406
+ * @param {string} [symbol] unified symbol of the market the order was made in
233
407
  * @param {object} [params] extra parameters specific to the exchange API endpoint
234
408
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
235
409
  */
236
410
  async cancelOrderWs(id, symbol = undefined, params = {}) {
411
+ if (symbol !== undefined) {
412
+ throw new errors.NotSupported(this.id + ' cancelOrderWs () does not support cancelling orders for a specific symbol.');
413
+ }
237
414
  await this.loadMarkets();
238
415
  const token = await this.authenticate();
239
- const url = this.urls['api']['ws']['private'];
416
+ const url = this.urls['api']['ws']['privateV2'];
240
417
  const requestId = this.requestId();
241
418
  const messageHash = requestId;
242
- const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId', id);
243
- params = this.omit(params, ['userref', 'clientOrderId']);
244
419
  const request = {
245
- 'event': 'cancelOrder',
246
- 'token': token,
247
- 'reqid': requestId,
248
- 'txid': [clientOrderId],
420
+ 'method': 'cancel_order',
421
+ 'params': {
422
+ 'order_id': [id],
423
+ 'token': token,
424
+ },
425
+ 'req_id': requestId,
249
426
  };
250
427
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
251
428
  }
252
429
  handleCancelOrder(client, message) {
253
430
  //
254
- // success
255
- // {
256
- // "event": "cancelOrderStatus",
257
- // "status": "ok"
258
- // "reqid": 1,
259
- // }
431
+ // {
432
+ // "method": "cancel_order",
433
+ // "req_id": 123456789,
434
+ // "result": {
435
+ // "order_id": "OKAGJC-YHIWK-WIOZWG"
436
+ // },
437
+ // "success": true,
438
+ // "time_in": "2023-09-21T14:36:57.428972Z",
439
+ // "time_out": "2023-09-21T14:36:57.437952Z"
440
+ // }
260
441
  //
261
- const reqId = this.safeValue(message, 'reqid');
442
+ const reqId = this.safeValue(message, 'req_id');
262
443
  client.resolve(message, reqId);
263
444
  }
264
445
  /**
@@ -266,7 +447,7 @@ class kraken extends kraken$1 {
266
447
  * @name kraken#cancelAllOrdersWs
267
448
  * @see https://docs.kraken.com/api/docs/websocket-v1/cancelall
268
449
  * @description cancel all open orders
269
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
450
+ * @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
270
451
  * @param {object} [params] extra parameters specific to the exchange API endpoint
271
452
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
272
453
  */
@@ -276,26 +457,32 @@ class kraken extends kraken$1 {
276
457
  }
277
458
  await this.loadMarkets();
278
459
  const token = await this.authenticate();
279
- const url = this.urls['api']['ws']['private'];
460
+ const url = this.urls['api']['ws']['privateV2'];
280
461
  const requestId = this.requestId();
281
462
  const messageHash = requestId;
282
463
  const request = {
283
- 'event': 'cancelAll',
284
- 'token': token,
285
- 'reqid': requestId,
464
+ 'method': 'cancel_all',
465
+ 'params': {
466
+ 'token': token,
467
+ },
468
+ 'req_id': requestId,
286
469
  };
287
470
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
288
471
  }
289
472
  handleCancelAllOrders(client, message) {
290
473
  //
291
- // {
292
- // "count": 2,
293
- // "event": "cancelAllStatus",
294
- // "status": "ok",
295
- // "reqId": 1
296
- // }
474
+ // {
475
+ // "method": "cancel_all",
476
+ // "req_id": 123456789,
477
+ // "result": {
478
+ // "count": 1
479
+ // },
480
+ // "success": true,
481
+ // "time_in": "2023-09-21T14:36:57.428972Z",
482
+ // "time_out": "2023-09-21T14:36:57.437952Z"
483
+ // }
297
484
  //
298
- const reqId = this.safeValue(message, 'reqid');
485
+ const reqId = this.safeValue(message, 'req_id');
299
486
  client.resolve(message, reqId);
300
487
  }
301
488
  handleTicker(client, message, subscription) {
@@ -888,6 +1075,20 @@ class kraken extends kraken$1 {
888
1075
  // "version": "0.2.0"
889
1076
  // }
890
1077
  //
1078
+ // v2
1079
+ // {
1080
+ // channel: 'status',
1081
+ // type: 'update',
1082
+ // data: [
1083
+ // {
1084
+ // version: '2.0.10',
1085
+ // system: 'online',
1086
+ // api_version: 'v2',
1087
+ // connection_id: 6447481662169813000
1088
+ // }
1089
+ // ]
1090
+ // }
1091
+ //
891
1092
  return message;
892
1093
  }
893
1094
  async authenticate(params = {}) {
@@ -1517,9 +1718,18 @@ class kraken extends kraken$1 {
1517
1718
  // "subscription": { name: "ticker" }
1518
1719
  // }
1519
1720
  //
1520
- const errorMessage = this.safeString(message, 'errorMessage');
1721
+ // v2
1722
+ // {
1723
+ // "error": "Unsupported field: 'price' for the given msg type: add order",
1724
+ // "method": "add_order",
1725
+ // "success": false,
1726
+ // "time_in": "2025-05-13T08:59:44.803511Z",
1727
+ // "time_out": "2025-05-13T08:59:44.803542Z'
1728
+ // }
1729
+ //
1730
+ const errorMessage = this.safeString2(message, 'errorMessage', 'error');
1521
1731
  if (errorMessage !== undefined) {
1522
- const requestId = this.safeValue(message, 'reqid');
1732
+ const requestId = this.safeValue2(message, 'reqid', 'req_id');
1523
1733
  if (requestId !== undefined) {
1524
1734
  const broad = this.exceptions['ws']['broad'];
1525
1735
  const broadKey = this.findBroadlyMatchedKey(broad, errorMessage);
@@ -1572,15 +1782,15 @@ class kraken extends kraken$1 {
1572
1782
  }
1573
1783
  }
1574
1784
  if (this.handleErrorMessage(client, message)) {
1575
- const event = this.safeString(message, 'event');
1785
+ const event = this.safeString2(message, 'event', 'method');
1576
1786
  const methods = {
1577
1787
  'heartbeat': this.handleHeartbeat,
1578
1788
  'systemStatus': this.handleSystemStatus,
1579
1789
  'subscriptionStatus': this.handleSubscriptionStatus,
1580
- 'addOrderStatus': this.handleCreateEditOrder,
1581
- 'editOrderStatus': this.handleCreateEditOrder,
1582
- 'cancelOrderStatus': this.handleCancelOrder,
1583
- 'cancelAllStatus': this.handleCancelAllOrders,
1790
+ 'add_order': this.handleCreateEditOrder,
1791
+ 'amend_order': this.handleCreateEditOrder,
1792
+ 'cancel_order': this.handleCancelOrder,
1793
+ 'cancel_all': this.handleCancelAllOrders,
1584
1794
  };
1585
1795
  const method = this.safeValue(methods, event);
1586
1796
  if (method !== undefined) {