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.
- package/README.md +5 -7
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -9
- package/dist/cjs/src/apex.js +2 -1
- package/dist/cjs/src/base/Exchange.js +15 -2
- package/dist/cjs/src/bitget.js +1 -3
- package/dist/cjs/src/bitrue.js +14 -35
- package/dist/cjs/src/bitso.js +33 -0
- package/dist/cjs/src/bitstamp.js +33 -0
- package/dist/cjs/src/blofin.js +154 -13
- package/dist/cjs/src/btcbox.js +25 -5
- package/dist/cjs/src/bybit.js +16 -40
- package/dist/cjs/src/cex.js +2 -4
- package/dist/cjs/src/coinbase.js +56 -40
- package/dist/cjs/src/coinbaseexchange.js +142 -32
- package/dist/cjs/src/coincatch.js +14 -67
- package/dist/cjs/src/coinex.js +29 -32
- package/dist/cjs/src/coinlist.js +16 -15
- package/dist/cjs/src/coinmetro.js +22 -11
- package/dist/cjs/src/coinone.js +8 -10
- package/dist/cjs/src/coinsph.js +126 -1
- package/dist/cjs/src/cryptocom.js +111 -1
- package/dist/cjs/src/cryptomus.js +43 -89
- package/dist/cjs/src/delta.js +76 -36
- package/dist/cjs/src/derive.js +46 -10
- package/dist/cjs/src/ellipx.js +175 -79
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/gemini.js +3 -5
- package/dist/cjs/src/hitbtc.js +56 -69
- package/dist/cjs/src/hyperliquid.js +2 -2
- package/dist/cjs/src/kraken.js +29 -24
- package/dist/cjs/src/kucoinfutures.js +6 -0
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/paradex.js +119 -3
- package/dist/cjs/src/pro/binance.js +31 -33
- package/dist/cjs/src/pro/bithumb.js +5 -3
- package/dist/cjs/src/pro/kraken.js +289 -79
- package/dist/cjs/src/pro/mexc.js +302 -8
- package/dist/cjs/src/pro/poloniex.js +6 -2
- package/examples/js/cli.js +127 -13
- package/js/ccxt.d.ts +2 -11
- package/js/ccxt.js +2 -8
- package/js/src/abstract/blofin.d.ts +8 -0
- package/js/src/abstract/btcbox.d.ts +1 -0
- package/js/src/apex.js +2 -1
- package/js/src/base/Exchange.d.ts +15 -1
- package/js/src/base/Exchange.js +15 -2
- package/js/src/base/types.d.ts +3 -0
- package/js/src/bitget.js +1 -3
- package/js/src/bitrue.js +14 -35
- package/js/src/bitso.js +33 -0
- package/js/src/bitstamp.js +33 -0
- package/js/src/blofin.d.ts +42 -2
- package/js/src/blofin.js +154 -13
- package/js/src/btcbox.js +25 -5
- package/js/src/bybit.js +16 -40
- package/js/src/cex.js +2 -4
- package/js/src/coinbase.js +56 -40
- package/js/src/coinbaseexchange.js +142 -32
- package/js/src/coincatch.js +14 -67
- package/js/src/coinex.js +28 -29
- package/js/src/coinlist.js +16 -15
- package/js/src/coinmetro.js +22 -11
- package/js/src/coinone.js +8 -10
- package/js/src/coinsph.d.ts +10 -1
- package/js/src/coinsph.js +126 -1
- package/js/src/cryptocom.d.ts +10 -1
- package/js/src/cryptocom.js +111 -1
- package/js/src/cryptomus.js +43 -89
- package/js/src/delta.js +76 -36
- package/js/src/derive.js +46 -10
- package/js/src/ellipx.d.ts +2 -3
- package/js/src/ellipx.js +175 -80
- package/js/src/gate.js +1 -1
- package/js/src/gemini.js +3 -5
- package/js/src/hitbtc.js +56 -69
- package/js/src/hyperliquid.js +2 -2
- package/js/src/kraken.js +29 -24
- package/js/src/kucoinfutures.d.ts +1 -0
- package/js/src/kucoinfutures.js +6 -0
- package/js/src/lbank.js +1 -1
- package/js/src/paradex.d.ts +12 -1
- package/js/src/paradex.js +119 -3
- package/js/src/pro/binance.d.ts +26 -26
- package/js/src/pro/binance.js +31 -33
- package/js/src/pro/bithumb.js +5 -3
- package/js/src/pro/kraken.d.ts +7 -6
- package/js/src/pro/kraken.js +290 -80
- package/js/src/pro/mexc.d.ts +58 -0
- package/js/src/pro/mexc.js +302 -8
- package/js/src/pro/poloniex.d.ts +1 -1
- package/js/src/pro/poloniex.js +6 -2
- package/package.json +1 -1
- package/js/src/abstract/bl3p.d.ts +0 -22
- package/js/src/abstract/bl3p.js +0 -11
- package/js/src/abstract/idex.d.ts +0 -29
- package/js/src/abstract/idex.js +0 -11
- package/js/src/bl3p.d.ts +0 -116
- package/js/src/bl3p.js +0 -552
- package/js/src/idex.d.ts +0 -312
- package/js/src/idex.js +0 -1961
- package/js/src/pro/idex.d.ts +0 -81
- 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']['
|
|
290
|
+
const url = this.urls['api']['ws']['privateV2'];
|
|
130
291
|
const requestId = this.requestId();
|
|
131
292
|
const messageHash = requestId;
|
|
132
293
|
let request = {
|
|
133
|
-
'
|
|
134
|
-
'
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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.
|
|
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
|
-
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
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
|
-
//
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
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
|
|
165
|
-
const
|
|
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-
|
|
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
|
|
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
|
-
'
|
|
191
|
-
'
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
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']['
|
|
387
|
+
const url = this.urls['api']['ws']['privateV2'];
|
|
216
388
|
const requestId = this.requestId();
|
|
217
389
|
const messageHash = requestId;
|
|
218
390
|
const request = {
|
|
219
|
-
'
|
|
220
|
-
'
|
|
221
|
-
|
|
222
|
-
|
|
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']['
|
|
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
|
-
'
|
|
246
|
-
'
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
//
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
//
|
|
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, '
|
|
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']['
|
|
460
|
+
const url = this.urls['api']['ws']['privateV2'];
|
|
280
461
|
const requestId = this.requestId();
|
|
281
462
|
const messageHash = requestId;
|
|
282
463
|
const request = {
|
|
283
|
-
'
|
|
284
|
-
'
|
|
285
|
-
|
|
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
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
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, '
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
-
'
|
|
1581
|
-
'
|
|
1582
|
-
'
|
|
1583
|
-
'
|
|
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) {
|