ccxt 4.3.5 → 4.3.6

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 (58) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +3 -0
  4. package/dist/cjs/src/binance.js +2 -0
  5. package/dist/cjs/src/bingx.js +45 -0
  6. package/dist/cjs/src/bitmex.js +24 -0
  7. package/dist/cjs/src/bybit.js +86 -0
  8. package/dist/cjs/src/coinbase.js +5 -4
  9. package/dist/cjs/src/coinex.js +30 -32
  10. package/dist/cjs/src/cryptocom.js +32 -0
  11. package/dist/cjs/src/htx.js +28 -0
  12. package/dist/cjs/src/hyperliquid.js +40 -0
  13. package/dist/cjs/src/kraken.js +30 -0
  14. package/dist/cjs/src/krakenfutures.js +28 -0
  15. package/dist/cjs/src/kucoinfutures.js +2 -2
  16. package/dist/cjs/src/okx.js +113 -0
  17. package/dist/cjs/src/pro/bitget.js +1 -1
  18. package/dist/cjs/src/whitebit.js +42 -0
  19. package/dist/cjs/src/woo.js +29 -0
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/binance.d.ts +1 -0
  23. package/js/src/abstract/binancecoinm.d.ts +1 -0
  24. package/js/src/abstract/binanceus.d.ts +1 -0
  25. package/js/src/abstract/binanceusdm.d.ts +1 -0
  26. package/js/src/abstract/bingx.d.ts +1 -0
  27. package/js/src/abstract/woo.d.ts +1 -0
  28. package/js/src/base/Exchange.d.ts +1 -0
  29. package/js/src/base/Exchange.js +3 -0
  30. package/js/src/binance.js +2 -0
  31. package/js/src/bingx.d.ts +1 -0
  32. package/js/src/bingx.js +45 -0
  33. package/js/src/bitmex.d.ts +1 -0
  34. package/js/src/bitmex.js +24 -0
  35. package/js/src/bybit.d.ts +2 -1
  36. package/js/src/bybit.js +86 -0
  37. package/js/src/coinbase.js +5 -4
  38. package/js/src/coinex.js +30 -32
  39. package/js/src/cryptocom.d.ts +2 -1
  40. package/js/src/cryptocom.js +32 -0
  41. package/js/src/htx.d.ts +1 -0
  42. package/js/src/htx.js +28 -0
  43. package/js/src/hyperliquid.d.ts +1 -0
  44. package/js/src/hyperliquid.js +40 -0
  45. package/js/src/kraken.d.ts +1 -0
  46. package/js/src/kraken.js +30 -0
  47. package/js/src/krakenfutures.d.ts +1 -0
  48. package/js/src/krakenfutures.js +28 -0
  49. package/js/src/kucoinfutures.js +2 -2
  50. package/js/src/okx.d.ts +3 -1
  51. package/js/src/okx.js +113 -0
  52. package/js/src/pro/bitget.d.ts +1 -1
  53. package/js/src/pro/bitget.js +1 -1
  54. package/js/src/whitebit.d.ts +1 -0
  55. package/js/src/whitebit.js +42 -0
  56. package/js/src/woo.d.ts +2 -1
  57. package/js/src/woo.js +29 -0
  58. package/package.json +1 -1
@@ -31,8 +31,10 @@ class okx extends okx$1 {
31
31
  'option': true,
32
32
  'addMargin': true,
33
33
  'cancelAllOrders': false,
34
+ 'cancelAllOrdersAfter': true,
34
35
  'cancelOrder': true,
35
36
  'cancelOrders': true,
37
+ 'cancelOrdersForSymbols': true,
36
38
  'closeAllPositions': false,
37
39
  'closePosition': true,
38
40
  'createConvertTrade': true,
@@ -3282,6 +3284,117 @@ class okx extends okx$1 {
3282
3284
  const ordersData = this.safeList(response, 'data', []);
3283
3285
  return this.parseOrders(ordersData, market, undefined, undefined, params);
3284
3286
  }
3287
+ async cancelOrdersForSymbols(orders, params = {}) {
3288
+ /**
3289
+ * @method
3290
+ * @name okx#cancelOrdersForSymbols
3291
+ * @description cancel multiple orders for multiple symbols
3292
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
3293
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
3294
+ * @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol
3295
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3296
+ * @param {boolean} [params.trigger] whether the order is a stop/trigger order
3297
+ * @param {boolean} [params.trailing] set to true if you want to cancel trailing orders
3298
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3299
+ */
3300
+ await this.loadMarkets();
3301
+ const request = [];
3302
+ const options = this.safeDict(this.options, 'cancelOrders', {});
3303
+ const defaultMethod = this.safeString(options, 'method', 'privatePostTradeCancelBatchOrders');
3304
+ let method = this.safeString(params, 'method', defaultMethod);
3305
+ const stop = this.safeBool2(params, 'stop', 'trigger');
3306
+ const trailing = this.safeBool(params, 'trailing', false);
3307
+ const isStopOrTrailing = stop || trailing;
3308
+ if (isStopOrTrailing) {
3309
+ method = 'privatePostTradeCancelAlgos';
3310
+ }
3311
+ for (let i = 0; i < orders.length; i++) {
3312
+ const order = orders[i];
3313
+ const id = this.safeString(order, 'id');
3314
+ const clientOrderId = this.safeString2(order, 'clOrdId', 'clientOrderId');
3315
+ const symbol = this.safeString(order, 'symbol');
3316
+ const market = this.market(symbol);
3317
+ let idKey = 'ordId';
3318
+ if (isStopOrTrailing) {
3319
+ idKey = 'algoId';
3320
+ }
3321
+ else if (clientOrderId !== undefined) {
3322
+ idKey = 'clOrdId';
3323
+ }
3324
+ const requestItem = {
3325
+ 'instId': market['id'],
3326
+ };
3327
+ requestItem[idKey] = (clientOrderId !== undefined) ? clientOrderId : id;
3328
+ request.push(requestItem);
3329
+ }
3330
+ let response = undefined;
3331
+ if (method === 'privatePostTradeCancelAlgos') {
3332
+ response = await this.privatePostTradeCancelAlgos(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
3333
+ }
3334
+ else {
3335
+ response = await this.privatePostTradeCancelBatchOrders(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
3336
+ }
3337
+ //
3338
+ // {
3339
+ // "code": "0",
3340
+ // "data": [
3341
+ // {
3342
+ // "clOrdId": "e123456789ec4dBC1123456ba123b45e",
3343
+ // "ordId": "405071912345641543",
3344
+ // "sCode": "0",
3345
+ // "sMsg": ""
3346
+ // },
3347
+ // ...
3348
+ // ],
3349
+ // "msg": ""
3350
+ // }
3351
+ //
3352
+ // Algo order
3353
+ //
3354
+ // {
3355
+ // "code": "0",
3356
+ // "data": [
3357
+ // {
3358
+ // "algoId": "431375349042380800",
3359
+ // "sCode": "0",
3360
+ // "sMsg": ""
3361
+ // }
3362
+ // ],
3363
+ // "msg": ""
3364
+ // }
3365
+ //
3366
+ const ordersData = this.safeList(response, 'data', []);
3367
+ return this.parseOrders(ordersData, undefined, undefined, undefined, params);
3368
+ }
3369
+ async cancelAllOrdersAfter(timeout, params = {}) {
3370
+ /**
3371
+ * @method
3372
+ * @name okx#cancelAllOrdersAfter
3373
+ * @description dead man's switch, cancel all orders after the given timeout
3374
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
3375
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
3376
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3377
+ * @returns {object} the api result
3378
+ */
3379
+ await this.loadMarkets();
3380
+ const request = {
3381
+ 'timeOut': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
3382
+ };
3383
+ const response = await this.privatePostTradeCancelAllAfter(this.extend(request, params));
3384
+ //
3385
+ // {
3386
+ // "code":"0",
3387
+ // "msg":"",
3388
+ // "data":[
3389
+ // {
3390
+ // "triggerTime":"1587971460",
3391
+ // "ts":"1587971400"
3392
+ // }
3393
+ // ]
3394
+ // }
3395
+ //
3396
+ return response;
3397
+ }
3285
3398
  parseOrderStatus(status) {
3286
3399
  const statuses = {
3287
3400
  'canceled': 'canceled',
@@ -1004,7 +1004,7 @@ class bitget extends bitget$1 {
1004
1004
  }
1005
1005
  return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
1006
1006
  }
1007
- handleOrder(client, message, subscription = undefined) {
1007
+ handleOrder(client, message) {
1008
1008
  //
1009
1009
  // spot
1010
1010
  //
@@ -29,6 +29,7 @@ class whitebit extends whitebit$1 {
29
29
  'future': false,
30
30
  'option': false,
31
31
  'cancelAllOrders': true,
32
+ 'cancelAllOrdersAfter': true,
32
33
  'cancelOrder': true,
33
34
  'cancelOrders': false,
34
35
  'createOrder': true,
@@ -1409,6 +1410,47 @@ class whitebit extends whitebit$1 {
1409
1410
  //
1410
1411
  return response;
1411
1412
  }
1413
+ async cancelAllOrdersAfter(timeout, params = {}) {
1414
+ /**
1415
+ * @method
1416
+ * @name whitebit#cancelAllOrdersAfter
1417
+ * @description dead man's switch, cancel all orders after the given timeout
1418
+ * @see https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
1419
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1420
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1421
+ * @param {string} [params.types] Order types value. Example: "spot", "margin", "futures" or null
1422
+ * @param {string} [params.symbol] symbol unified symbol of the market the order was made in
1423
+ * @returns {object} the api result
1424
+ */
1425
+ await this.loadMarkets();
1426
+ const symbol = this.safeString(params, 'symbol');
1427
+ if (symbol === undefined) {
1428
+ throw new errors.ArgumentsRequired(this.id + ' cancelAllOrdersAfter() requires a symbol argument in params');
1429
+ }
1430
+ const market = this.market(symbol);
1431
+ params = this.omit(params, 'symbol');
1432
+ const isBiggerThanZero = (timeout > 0);
1433
+ const request = {
1434
+ 'market': market['id'],
1435
+ // 'timeout': (timeout > 0) ? this.numberToString (timeout / 1000) : null,
1436
+ };
1437
+ if (isBiggerThanZero) {
1438
+ request['timeout'] = this.numberToString(timeout / 1000);
1439
+ }
1440
+ else {
1441
+ request['timeout'] = 'null';
1442
+ }
1443
+ const response = await this.v4PrivatePostOrderKillSwitch(this.extend(request, params));
1444
+ //
1445
+ // {
1446
+ // "market": "BTC_USDT", // currency market,
1447
+ // "startTime": 1662478154, // now timestamp,
1448
+ // "cancellationTime": 1662478154, // now + timer_value,
1449
+ // "types": ["spot", "margin"]
1450
+ // }
1451
+ //
1452
+ return response;
1453
+ }
1412
1454
  parseBalance(response) {
1413
1455
  const balanceKeys = Object.keys(response);
1414
1456
  const result = {};
@@ -32,6 +32,7 @@ class woo extends woo$1 {
32
32
  'option': false,
33
33
  'addMargin': false,
34
34
  'cancelAllOrders': true,
35
+ 'cancelAllOrdersAfter': true,
35
36
  'cancelOrder': true,
36
37
  'cancelWithdraw': false,
37
38
  'closeAllPositions': false,
@@ -199,6 +200,7 @@ class woo extends woo$1 {
199
200
  },
200
201
  'post': {
201
202
  'order': 5,
203
+ 'order/cancel_all_after': 1,
202
204
  'asset/main_sub_transfer': 30,
203
205
  'asset/ltv': 30,
204
206
  'asset/withdraw': 30,
@@ -1289,6 +1291,33 @@ class woo extends woo$1 {
1289
1291
  //
1290
1292
  return response;
1291
1293
  }
1294
+ async cancelAllOrdersAfter(timeout, params = {}) {
1295
+ /**
1296
+ * @method
1297
+ * @name woo#cancelAllOrdersAfter
1298
+ * @description dead man's switch, cancel all orders after the given timeout
1299
+ * @see https://docs.woo.org/#cancel-all-after
1300
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1301
+ * @param {boolean} activated countdown
1302
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1303
+ * @returns {object} the api result
1304
+ */
1305
+ await this.loadMarkets();
1306
+ const request = {
1307
+ 'trigger_after': (timeout > 0) ? timeout : 0,
1308
+ };
1309
+ const response = await this.v1PrivatePostOrderCancelAllAfter(this.extend(request, params));
1310
+ //
1311
+ // {
1312
+ // "success": true,
1313
+ // "data": {
1314
+ // "expected_trigger_time": 1711534302938
1315
+ // },
1316
+ // "timestamp": 1711534302943
1317
+ // }
1318
+ //
1319
+ return response;
1320
+ }
1292
1321
  async fetchOrder(id, symbol = undefined, params = {}) {
1293
1322
  /**
1294
1323
  * @method
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.4";
7
+ declare const version = "4.3.5";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.5';
41
+ const version = '4.3.6';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -86,6 +86,7 @@ interface Exchange {
86
86
  sapiGetCapitalDepositSubAddress(params?: {}): Promise<implicitReturnType>;
87
87
  sapiGetCapitalDepositSubHisrec(params?: {}): Promise<implicitReturnType>;
88
88
  sapiGetCapitalWithdrawHistory(params?: {}): Promise<implicitReturnType>;
89
+ sapiGetCapitalWithdrawAddressList(params?: {}): Promise<implicitReturnType>;
89
90
  sapiGetCapitalContractConvertibleCoins(params?: {}): Promise<implicitReturnType>;
90
91
  sapiGetConvertTradeFlow(params?: {}): Promise<implicitReturnType>;
91
92
  sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
@@ -86,6 +86,7 @@ interface binance {
86
86
  sapiGetCapitalDepositSubAddress(params?: {}): Promise<implicitReturnType>;
87
87
  sapiGetCapitalDepositSubHisrec(params?: {}): Promise<implicitReturnType>;
88
88
  sapiGetCapitalWithdrawHistory(params?: {}): Promise<implicitReturnType>;
89
+ sapiGetCapitalWithdrawAddressList(params?: {}): Promise<implicitReturnType>;
89
90
  sapiGetCapitalContractConvertibleCoins(params?: {}): Promise<implicitReturnType>;
90
91
  sapiGetConvertTradeFlow(params?: {}): Promise<implicitReturnType>;
91
92
  sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
@@ -86,6 +86,7 @@ interface binance {
86
86
  sapiGetCapitalDepositSubAddress(params?: {}): Promise<implicitReturnType>;
87
87
  sapiGetCapitalDepositSubHisrec(params?: {}): Promise<implicitReturnType>;
88
88
  sapiGetCapitalWithdrawHistory(params?: {}): Promise<implicitReturnType>;
89
+ sapiGetCapitalWithdrawAddressList(params?: {}): Promise<implicitReturnType>;
89
90
  sapiGetCapitalContractConvertibleCoins(params?: {}): Promise<implicitReturnType>;
90
91
  sapiGetConvertTradeFlow(params?: {}): Promise<implicitReturnType>;
91
92
  sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
@@ -86,6 +86,7 @@ interface binance {
86
86
  sapiGetCapitalDepositSubAddress(params?: {}): Promise<implicitReturnType>;
87
87
  sapiGetCapitalDepositSubHisrec(params?: {}): Promise<implicitReturnType>;
88
88
  sapiGetCapitalWithdrawHistory(params?: {}): Promise<implicitReturnType>;
89
+ sapiGetCapitalWithdrawAddressList(params?: {}): Promise<implicitReturnType>;
89
90
  sapiGetCapitalContractConvertibleCoins(params?: {}): Promise<implicitReturnType>;
90
91
  sapiGetConvertTradeFlow(params?: {}): Promise<implicitReturnType>;
91
92
  sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
@@ -61,6 +61,7 @@ interface Exchange {
61
61
  swapV2PrivatePostTradeOrder(params?: {}): Promise<implicitReturnType>;
62
62
  swapV2PrivatePostTradeBatchOrders(params?: {}): Promise<implicitReturnType>;
63
63
  swapV2PrivatePostTradeCloseAllPositions(params?: {}): Promise<implicitReturnType>;
64
+ swapV2PrivatePostTradeCancelAllAfter(params?: {}): Promise<implicitReturnType>;
64
65
  swapV2PrivatePostTradeMarginType(params?: {}): Promise<implicitReturnType>;
65
66
  swapV2PrivatePostTradeLeverage(params?: {}): Promise<implicitReturnType>;
66
67
  swapV2PrivatePostTradePositionMargin(params?: {}): Promise<implicitReturnType>;
@@ -42,6 +42,7 @@ interface Exchange {
42
42
  v1PrivateGetPositionSymbol(params?: {}): Promise<implicitReturnType>;
43
43
  v1PrivateGetClientTransactionHistory(params?: {}): Promise<implicitReturnType>;
44
44
  v1PrivatePostOrder(params?: {}): Promise<implicitReturnType>;
45
+ v1PrivatePostOrderCancelAllAfter(params?: {}): Promise<implicitReturnType>;
45
46
  v1PrivatePostAssetMainSubTransfer(params?: {}): Promise<implicitReturnType>;
46
47
  v1PrivatePostAssetLtv(params?: {}): Promise<implicitReturnType>;
47
48
  v1PrivatePostAssetWithdraw(params?: {}): Promise<implicitReturnType>;
@@ -931,6 +931,7 @@ export default class Exchange {
931
931
  cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<{}>;
932
932
  cancelOrdersWs(ids: string[], symbol?: Str, params?: {}): Promise<{}>;
933
933
  cancelAllOrders(symbol?: Str, params?: {}): Promise<{}>;
934
+ cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<{}>;
934
935
  cancelOrdersForSymbols(orders: CancellationRequest[], params?: {}): Promise<{}>;
935
936
  cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<{}>;
936
937
  cancelUnifiedOrder(order: any, params?: {}): Promise<{}>;
@@ -4698,6 +4698,9 @@ export default class Exchange {
4698
4698
  async cancelAllOrders(symbol = undefined, params = {}) {
4699
4699
  throw new NotSupported(this.id + ' cancelAllOrders() is not supported yet');
4700
4700
  }
4701
+ async cancelAllOrdersAfter(timeout, params = {}) {
4702
+ throw new NotSupported(this.id + ' cancelAllOrdersAfter() is not supported yet');
4703
+ }
4701
4704
  async cancelOrdersForSymbols(orders, params = {}) {
4702
4705
  throw new NotSupported(this.id + ' cancelOrdersForSymbols() is not supported yet');
4703
4706
  }
package/js/src/binance.js CHANGED
@@ -324,6 +324,7 @@ export default class binance extends Exchange {
324
324
  'capital/deposit/subAddress': 0.1,
325
325
  'capital/deposit/subHisrec': 0.1,
326
326
  'capital/withdraw/history': 1800,
327
+ 'capital/withdraw/address/list': 10,
327
328
  'capital/contract/convertible-coins': 4.0002,
328
329
  'convert/tradeFlow': 20.001,
329
330
  'convert/exchangeInfo': 50,
@@ -4110,6 +4111,7 @@ export default class binance extends Exchange {
4110
4111
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
4111
4112
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4112
4113
  * @param {string} [params.subType] "linear" or "inverse"
4114
+ * @param {string} [params.type] 'spot', 'option', use params["subType"] for swap and future markets
4113
4115
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
4114
4116
  */
4115
4117
  await this.loadMarkets();
package/js/src/bingx.d.ts CHANGED
@@ -79,6 +79,7 @@ export default class bingx extends Exchange {
79
79
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
80
80
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
81
81
  cancelOrders(ids: string[], symbol?: Str, params?: {}): Promise<any>;
82
+ cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<any>;
82
83
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
83
84
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
84
85
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/bingx.js CHANGED
@@ -35,6 +35,7 @@ export default class bingx extends Exchange {
35
35
  'option': false,
36
36
  'addMargin': true,
37
37
  'cancelAllOrders': true,
38
+ 'cancelAllOrdersAfter': true,
38
39
  'cancelOrder': true,
39
40
  'cancelOrders': true,
40
41
  'closeAllPositions': true,
@@ -231,6 +232,7 @@ export default class bingx extends Exchange {
231
232
  'trade/order': 3,
232
233
  'trade/batchOrders': 3,
233
234
  'trade/closeAllPositions': 3,
235
+ 'trade/cancelAllAfter': 3,
234
236
  'trade/marginType': 3,
235
237
  'trade/leverage': 3,
236
238
  'trade/positionMargin': 3,
@@ -2752,6 +2754,49 @@ export default class bingx extends Exchange {
2752
2754
  //
2753
2755
  return response;
2754
2756
  }
2757
+ async cancelAllOrdersAfter(timeout, params = {}) {
2758
+ /**
2759
+ * @method
2760
+ * @name bingx#cancelAllOrdersAfter
2761
+ * @description dead man's switch, cancel all orders after the given timeout
2762
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20all%20orders%20in%20countdown
2763
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20all%20orders%20in%20countdown
2764
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
2765
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2766
+ * @param {string} [params.type] spot or swap market
2767
+ * @returns {object} the api result
2768
+ */
2769
+ await this.loadMarkets();
2770
+ const isActive = (timeout > 0);
2771
+ const request = {
2772
+ 'type': (isActive) ? 'ACTIVATE' : 'CLOSE',
2773
+ 'timeOut': (isActive) ? (this.parseToInt(timeout / 1000)) : 0,
2774
+ };
2775
+ let response = undefined;
2776
+ let type = undefined;
2777
+ [type, params] = this.handleMarketTypeAndParams('cancelAllOrdersAfter', undefined, params);
2778
+ if (type === 'spot') {
2779
+ response = await this.spotV1PrivatePostTradeCancelAllAfter(this.extend(request, params));
2780
+ }
2781
+ else if (type === 'swap') {
2782
+ response = await this.swapV2PrivatePostTradeCancelAllAfter(this.extend(request, params));
2783
+ }
2784
+ else {
2785
+ throw new NotSupported(this.id + ' cancelAllOrdersAfter() is not supported for ' + type + ' markets');
2786
+ }
2787
+ //
2788
+ // {
2789
+ // code: '0',
2790
+ // msg: '',
2791
+ // data: {
2792
+ // triggerTime: '1712645434',
2793
+ // status: 'ACTIVATED',
2794
+ // note: 'All your perpetual pending orders will be closed automatically at 2024-04-09 06:50:34 UTC(+0),before that you can cancel the timer, or extend triggerTime time by this request'
2795
+ // }
2796
+ // }
2797
+ //
2798
+ return response;
2799
+ }
2755
2800
  async fetchOrder(id, symbol = undefined, params = {}) {
2756
2801
  /**
2757
2802
  * @method
@@ -62,6 +62,7 @@ export default class bitmex extends Exchange {
62
62
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
63
63
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
64
64
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
65
+ cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<any>;
65
66
  fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
66
67
  parseLeverage(leverage: any, market?: any): Leverage;
67
68
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
package/js/src/bitmex.js CHANGED
@@ -39,6 +39,7 @@ export default class bitmex extends Exchange {
39
39
  'option': false,
40
40
  'addMargin': undefined,
41
41
  'cancelAllOrders': true,
42
+ 'cancelAllOrdersAfter': true,
42
43
  'cancelOrder': true,
43
44
  'cancelOrders': true,
44
45
  'closeAllPositions': false,
@@ -2119,6 +2120,29 @@ export default class bitmex extends Exchange {
2119
2120
  //
2120
2121
  return this.parseOrders(response, market);
2121
2122
  }
2123
+ async cancelAllOrdersAfter(timeout, params = {}) {
2124
+ /**
2125
+ * @method
2126
+ * @name bitmex#cancelAllOrdersAfter
2127
+ * @description dead man's switch, cancel all orders after the given timeout
2128
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancelAllAfter
2129
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
2130
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2131
+ * @returns {object} the api result
2132
+ */
2133
+ await this.loadMarkets();
2134
+ const request = {
2135
+ 'timeout': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
2136
+ };
2137
+ const response = await this.privatePostOrderCancelAllAfter(this.extend(request, params));
2138
+ //
2139
+ // {
2140
+ // now: '2024-04-09T09:01:56.560Z',
2141
+ // cancelTime: '2024-04-09T09:01:56.660Z'
2142
+ // }
2143
+ //
2144
+ return response;
2145
+ }
2122
2146
  async fetchLeverages(symbols = undefined, params = {}) {
2123
2147
  /**
2124
2148
  * @method
package/js/src/bybit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bybit.js';
2
- import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest } from './base/types.js';
3
3
  /**
4
4
  * @class bybit
5
5
  * @augments Exchange
@@ -66,6 +66,7 @@ export default class bybit extends Exchange {
66
66
  cancelUsdcOrder(id: any, symbol?: Str, params?: {}): Promise<Order>;
67
67
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
68
68
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
69
+ cancelOrdersForSymbols(orders: CancellationRequest[], params?: {}): Promise<Order[]>;
69
70
  cancelAllUsdcOrders(symbol?: Str, params?: {}): Promise<any>;
70
71
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
71
72
  fetchUsdcOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/bybit.js CHANGED
@@ -38,6 +38,8 @@ export default class bybit extends Exchange {
38
38
  'borrowCrossMargin': true,
39
39
  'cancelAllOrders': true,
40
40
  'cancelOrder': true,
41
+ 'cancelOrders': true,
42
+ 'cancelOrdersForSymbols': true,
41
43
  'closeAllPositions': false,
42
44
  'closePosition': false,
43
45
  'createMarketBuyOrderWithCost': true,
@@ -4385,6 +4387,90 @@ export default class bybit extends Exchange {
4385
4387
  const row = this.safeList(result, 'list', []);
4386
4388
  return this.parseOrders(row, market);
4387
4389
  }
4390
+ async cancelOrdersForSymbols(orders, params = {}) {
4391
+ /**
4392
+ * @method
4393
+ * @name bybit#cancelOrdersForSymbols
4394
+ * @description cancel multiple orders for multiple symbols
4395
+ * @see https://bybit-exchange.github.io/docs/v5/order/batch-cancel
4396
+ * @param {string[]} ids order ids
4397
+ * @param {string} symbol unified symbol of the market the order was made in
4398
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4399
+ * @param {string[]} [params.clientOrderIds] client order ids
4400
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4401
+ */
4402
+ await this.loadMarkets();
4403
+ const ordersRequests = [];
4404
+ let category = undefined;
4405
+ for (let i = 0; i < orders.length; i++) {
4406
+ const order = orders[i];
4407
+ const symbol = this.safeString(order, 'symbol');
4408
+ const market = this.market(symbol);
4409
+ let currentCategory = undefined;
4410
+ [currentCategory, params] = this.getBybitType('cancelOrders', market, params);
4411
+ if (currentCategory === 'inverse') {
4412
+ throw new NotSupported(this.id + ' cancelOrdersForSymbols does not allow inverse orders');
4413
+ }
4414
+ if ((category !== undefined) && (category !== currentCategory)) {
4415
+ throw new ExchangeError(this.id + ' cancelOrdersForSymbols requires all orders to be of the same category (linear, spot or option))');
4416
+ }
4417
+ category = currentCategory;
4418
+ const id = this.safeString(order, 'id');
4419
+ const clientOrderId = this.safeString(order, 'clientOrderId');
4420
+ let idKey = 'orderId';
4421
+ if (clientOrderId !== undefined) {
4422
+ idKey = 'orderLinkId';
4423
+ }
4424
+ const orderItem = {
4425
+ 'symbol': market['id'],
4426
+ };
4427
+ orderItem[idKey] = (idKey === 'orderId') ? id : clientOrderId;
4428
+ ordersRequests.push(orderItem);
4429
+ }
4430
+ const request = {
4431
+ 'category': category,
4432
+ 'request': ordersRequests,
4433
+ };
4434
+ const response = await this.privatePostV5OrderCancelBatch(this.extend(request, params));
4435
+ //
4436
+ // {
4437
+ // "retCode": "0",
4438
+ // "retMsg": "OK",
4439
+ // "result": {
4440
+ // "list": [
4441
+ // {
4442
+ // "category": "spot",
4443
+ // "symbol": "BTCUSDT",
4444
+ // "orderId": "1636282505818800896",
4445
+ // "orderLinkId": "1636282505818800897"
4446
+ // },
4447
+ // {
4448
+ // "category": "spot",
4449
+ // "symbol": "BTCUSDT",
4450
+ // "orderId": "1636282505818800898",
4451
+ // "orderLinkId": "1636282505818800899"
4452
+ // }
4453
+ // ]
4454
+ // },
4455
+ // "retExtInfo": {
4456
+ // "list": [
4457
+ // {
4458
+ // "code": "0",
4459
+ // "msg": "OK"
4460
+ // },
4461
+ // {
4462
+ // "code": "0",
4463
+ // "msg": "OK"
4464
+ // }
4465
+ // ]
4466
+ // },
4467
+ // "time": "1709796158501"
4468
+ // }
4469
+ //
4470
+ const result = this.safeDict(response, 'result', {});
4471
+ const row = this.safeList(result, 'list', []);
4472
+ return this.parseOrders(row, undefined);
4473
+ }
4388
4474
  async cancelAllUsdcOrders(symbol = undefined, params = {}) {
4389
4475
  if (symbol === undefined) {
4390
4476
  throw new ArgumentsRequired(this.id + ' cancelAllUsdcOrders() requires a symbol argument');
@@ -3431,12 +3431,13 @@ export default class coinbase extends Exchange {
3431
3431
  sinceString = Precise.stringSub(now, requestedDuration.toString());
3432
3432
  }
3433
3433
  request['start'] = sinceString;
3434
- let endString = this.numberToString(until);
3435
- if (until === undefined) {
3434
+ if (until !== undefined) {
3435
+ request['end'] = this.numberToString(this.parseToInt(until / 1000));
3436
+ }
3437
+ else {
3436
3438
  // 300 candles max
3437
- endString = Precise.stringAdd(sinceString, requestedDuration.toString());
3439
+ request['end'] = Precise.stringAdd(sinceString, requestedDuration.toString());
3438
3440
  }
3439
- request['end'] = endString;
3440
3441
  const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
3441
3442
  //
3442
3443
  // {