ccxt 4.2.76 → 4.2.77

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 (65) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +966 -597
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +6 -0
  7. package/dist/cjs/src/binance.js +502 -443
  8. package/dist/cjs/src/bingx.js +1 -1
  9. package/dist/cjs/src/blofin.js +14 -2
  10. package/dist/cjs/src/bybit.js +100 -58
  11. package/dist/cjs/src/coinbase.js +1 -1
  12. package/dist/cjs/src/delta.js +66 -49
  13. package/dist/cjs/src/hyperliquid.js +1 -1
  14. package/dist/cjs/src/kraken.js +8 -8
  15. package/dist/cjs/src/kucoin.js +152 -5
  16. package/dist/cjs/src/pro/ascendex.js +1 -1
  17. package/dist/cjs/src/pro/bitvavo.js +1 -1
  18. package/dist/cjs/src/pro/coinex.js +20 -14
  19. package/dist/cjs/src/pro/deribit.js +1 -1
  20. package/dist/cjs/src/pro/exmo.js +1 -1
  21. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  22. package/dist/cjs/src/pro/phemex.js +1 -1
  23. package/dist/cjs/src/pro/poloniex.js +1 -1
  24. package/dist/cjs/src/pro/probit.js +1 -1
  25. package/dist/cjs/src/pro/woo.js +61 -6
  26. package/dist/cjs/src/woo.js +25 -0
  27. package/js/ccxt.d.ts +1 -1
  28. package/js/ccxt.js +1 -1
  29. package/js/src/abstract/kucoin.d.ts +1 -0
  30. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  31. package/js/src/base/Exchange.d.ts +3 -3
  32. package/js/src/base/Exchange.js +6 -0
  33. package/js/src/base/types.d.ts +1 -1
  34. package/js/src/binance.d.ts +2 -2
  35. package/js/src/binance.js +502 -443
  36. package/js/src/bingx.js +1 -1
  37. package/js/src/bitflyer.d.ts +2 -2
  38. package/js/src/bithumb.d.ts +2 -2
  39. package/js/src/blofin.js +14 -2
  40. package/js/src/bybit.d.ts +1 -1
  41. package/js/src/bybit.js +100 -58
  42. package/js/src/coinbase.js +1 -1
  43. package/js/src/delta.d.ts +2 -1
  44. package/js/src/delta.js +66 -49
  45. package/js/src/deribit.d.ts +1 -1
  46. package/js/src/gate.d.ts +1 -1
  47. package/js/src/hyperliquid.js +1 -1
  48. package/js/src/kraken.js +8 -8
  49. package/js/src/kucoin.d.ts +4 -1
  50. package/js/src/kucoin.js +152 -5
  51. package/js/src/okx.d.ts +1 -1
  52. package/js/src/pro/ascendex.js +1 -1
  53. package/js/src/pro/bitvavo.js +1 -1
  54. package/js/src/pro/coinex.js +20 -14
  55. package/js/src/pro/deribit.js +1 -1
  56. package/js/src/pro/exmo.js +1 -1
  57. package/js/src/pro/krakenfutures.js +1 -1
  58. package/js/src/pro/phemex.js +1 -1
  59. package/js/src/pro/poloniex.js +1 -1
  60. package/js/src/pro/probit.js +1 -1
  61. package/js/src/pro/woo.d.ts +1 -0
  62. package/js/src/pro/woo.js +61 -6
  63. package/js/src/woo.js +25 -0
  64. package/package.json +1 -1
  65. package/skip-tests.json +1 -2
@@ -2468,7 +2468,7 @@ class bingx extends bingx$1 {
2468
2468
  'FILLED': 'closed',
2469
2469
  'CANCELED': 'canceled',
2470
2470
  'CANCELLED': 'canceled',
2471
- 'FAILED': 'failed',
2471
+ 'FAILED': 'canceled',
2472
2472
  };
2473
2473
  return this.safeString(statuses, status, status);
2474
2474
  }
@@ -1251,6 +1251,7 @@ class blofin extends blofin$1 {
1251
1251
  * @param {string} id order id
1252
1252
  * @param {string} symbol unified symbol of the market the order was made in
1253
1253
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1254
+ * @param {boolean} [params.trigger] True if cancelling a trigger/conditional order/tp sl orders
1254
1255
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1255
1256
  */
1256
1257
  if (symbol === undefined) {
@@ -1261,14 +1262,25 @@ class blofin extends blofin$1 {
1261
1262
  const request = {
1262
1263
  'instId': market['id'],
1263
1264
  };
1265
+ const isTrigger = this.safeBoolN(params, ['stop', 'trigger', 'tpsl'], false);
1264
1266
  const clientOrderId = this.safeString(params, 'clientOrderId');
1265
1267
  if (clientOrderId !== undefined) {
1266
1268
  request['clientOrderId'] = clientOrderId;
1267
1269
  }
1268
1270
  else {
1269
- request['orderId'] = id;
1271
+ if (!isTrigger) {
1272
+ request['orderId'] = id.toString();
1273
+ }
1274
+ else {
1275
+ request['tpslId'] = id.toString();
1276
+ }
1277
+ }
1278
+ const query = this.omit(params, ['orderId', 'clientOrderId', 'stop', 'trigger', 'tpsl']);
1279
+ if (isTrigger) {
1280
+ const tpslResponse = await this.cancelOrders([id], symbol, params);
1281
+ const first = this.safeDict(tpslResponse, 0);
1282
+ return first;
1270
1283
  }
1271
- const query = this.omit(params, ['orderId', 'clientOrderId']);
1272
1284
  const response = await this.privatePostTradeCancelOrder(this.extend(request, query));
1273
1285
  const data = this.safeList(response, 'data', []);
1274
1286
  const order = this.safeDict(data, 0);
@@ -963,6 +963,9 @@ class bybit extends bybit$1 {
963
963
  'precisionMode': number.TICK_SIZE,
964
964
  'options': {
965
965
  'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
966
+ 'createOrder': {
967
+ 'method': 'privatePostV5OrderCreate', // 'privatePostV5PositionTradingStop'
968
+ },
966
969
  'enableUnifiedMargin': undefined,
967
970
  'enableUnifiedAccount': undefined,
968
971
  'createMarketBuyOrderRequiresPrice': true,
@@ -3531,8 +3534,10 @@ class bybit extends bybit$1 {
3531
3534
  const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
3532
3535
  const isTrailingAmountOrder = trailingAmount !== undefined;
3533
3536
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
3537
+ const options = this.safeValue(this.options, 'createOrder', {});
3538
+ const defaultMethod = this.safeString(options, 'method', 'privatePostV5OrderCreate');
3534
3539
  let response = undefined;
3535
- if (isTrailingAmountOrder) {
3540
+ if (isTrailingAmountOrder || (defaultMethod === 'privatePostV5PositionTradingStop')) {
3536
3541
  response = await this.privatePostV5PositionTradingStop(orderRequest);
3537
3542
  }
3538
3543
  else {
@@ -3560,10 +3565,12 @@ class bybit extends bybit$1 {
3560
3565
  if ((price === undefined) && (lowerCaseType === 'limit')) {
3561
3566
  throw new errors.ArgumentsRequired(this.id + ' createOrder requires a price argument for limit orders');
3562
3567
  }
3568
+ let defaultMethod = undefined;
3569
+ [defaultMethod, params] = this.handleOptionAndParams(params, 'createOrder', 'method', 'privatePostV5OrderCreate');
3563
3570
  const request = {
3564
3571
  'symbol': market['id'],
3565
- 'side': this.capitalize(side),
3566
- 'orderType': this.capitalize(lowerCaseType), // limit or market
3572
+ // 'side': this.capitalize (side),
3573
+ // 'orderType': this.capitalize (lowerCaseType), // limit or market
3567
3574
  // 'timeInForce': 'GTC', // IOC, FOK, PostOnly
3568
3575
  // 'takeProfit': 123.45, // take profit price, only take effect upon opening the position
3569
3576
  // 'stopLoss': 123.45, // stop loss price, only take effect upon opening the position
@@ -3585,6 +3592,87 @@ class bybit extends bybit$1 {
3585
3592
  // Valid for option only.
3586
3593
  // 'orderIv': '0', // Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3587
3594
  };
3595
+ let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
3596
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
3597
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
3598
+ const stopLoss = this.safeValue(params, 'stopLoss');
3599
+ const takeProfit = this.safeValue(params, 'takeProfit');
3600
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activePrice', this.numberToString(price));
3601
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
3602
+ const isTrailingAmountOrder = trailingAmount !== undefined;
3603
+ const isTriggerOrder = triggerPrice !== undefined;
3604
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
3605
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
3606
+ const isStopLoss = stopLoss !== undefined;
3607
+ const isTakeProfit = takeProfit !== undefined;
3608
+ const isMarket = lowerCaseType === 'market';
3609
+ const isLimit = lowerCaseType === 'limit';
3610
+ const isBuy = side === 'buy';
3611
+ const isAlternativeEndpoint = defaultMethod === 'privatePostV5PositionTradingStop';
3612
+ if (isTrailingAmountOrder || isAlternativeEndpoint) {
3613
+ if (isStopLoss || isTakeProfit || isTriggerOrder || market['spot']) {
3614
+ throw new errors.InvalidOrder(this.id + ' the API endpoint used only supports contract trailingAmount, stopLossPrice and takeProfitPrice orders');
3615
+ }
3616
+ if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
3617
+ if (isStopLossTriggerOrder) {
3618
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
3619
+ if (isLimit) {
3620
+ request['tpslMode'] = 'Partial';
3621
+ request['slOrderType'] = 'Limit';
3622
+ request['slLimitPrice'] = this.priceToPrecision(symbol, price);
3623
+ request['slSize'] = this.amountToPrecision(symbol, amount);
3624
+ }
3625
+ }
3626
+ else if (isTakeProfitTriggerOrder) {
3627
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
3628
+ if (isLimit) {
3629
+ request['tpslMode'] = 'Partial';
3630
+ request['tpOrderType'] = 'Limit';
3631
+ request['tpLimitPrice'] = this.priceToPrecision(symbol, price);
3632
+ request['tpSize'] = this.amountToPrecision(symbol, amount);
3633
+ }
3634
+ }
3635
+ }
3636
+ }
3637
+ else {
3638
+ request['side'] = this.capitalize(side);
3639
+ request['orderType'] = this.capitalize(lowerCaseType);
3640
+ const timeInForce = this.safeStringLower(params, 'timeInForce'); // this is same as exchange specific param
3641
+ let postOnly = undefined;
3642
+ [postOnly, params] = this.handlePostOnly(isMarket, timeInForce === 'postonly', params);
3643
+ if (postOnly) {
3644
+ request['timeInForce'] = 'PostOnly';
3645
+ }
3646
+ else if (timeInForce === 'gtc') {
3647
+ request['timeInForce'] = 'GTC';
3648
+ }
3649
+ else if (timeInForce === 'fok') {
3650
+ request['timeInForce'] = 'FOK';
3651
+ }
3652
+ else if (timeInForce === 'ioc') {
3653
+ request['timeInForce'] = 'IOC';
3654
+ }
3655
+ if (market['spot']) {
3656
+ // only works for spot market
3657
+ if (triggerPrice !== undefined) {
3658
+ request['orderFilter'] = 'StopOrder';
3659
+ }
3660
+ else if (stopLossTriggerPrice !== undefined || takeProfitTriggerPrice !== undefined || isStopLoss || isTakeProfit) {
3661
+ request['orderFilter'] = 'tpslOrder';
3662
+ }
3663
+ }
3664
+ const clientOrderId = this.safeString(params, 'clientOrderId');
3665
+ if (clientOrderId !== undefined) {
3666
+ request['orderLinkId'] = clientOrderId;
3667
+ }
3668
+ else if (market['option']) {
3669
+ // mandatory field for options
3670
+ request['orderLinkId'] = this.uuid16();
3671
+ }
3672
+ if (isLimit) {
3673
+ request['price'] = this.priceToPrecision(symbol, price);
3674
+ }
3675
+ }
3588
3676
  if (market['spot']) {
3589
3677
  request['category'] = 'spot';
3590
3678
  }
@@ -3644,48 +3732,17 @@ class bybit extends bybit$1 {
3644
3732
  }
3645
3733
  }
3646
3734
  else {
3647
- request['qty'] = this.amountToPrecision(symbol, amount);
3648
- }
3649
- const isMarket = lowerCaseType === 'market';
3650
- const isLimit = lowerCaseType === 'limit';
3651
- if (isLimit) {
3652
- request['price'] = this.priceToPrecision(symbol, price);
3653
- }
3654
- const timeInForce = this.safeStringLower(params, 'timeInForce'); // this is same as exchange specific param
3655
- let postOnly = undefined;
3656
- [postOnly, params] = this.handlePostOnly(isMarket, timeInForce === 'postonly', params);
3657
- if (postOnly) {
3658
- request['timeInForce'] = 'PostOnly';
3659
- }
3660
- else if (timeInForce === 'gtc') {
3661
- request['timeInForce'] = 'GTC';
3662
- }
3663
- else if (timeInForce === 'fok') {
3664
- request['timeInForce'] = 'FOK';
3665
- }
3666
- else if (timeInForce === 'ioc') {
3667
- request['timeInForce'] = 'IOC';
3735
+ if (!isTrailingAmountOrder && !isAlternativeEndpoint) {
3736
+ request['qty'] = this.amountToPrecision(symbol, amount);
3737
+ }
3668
3738
  }
3669
- let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
3670
- const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
3671
- const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
3672
- const stopLoss = this.safeValue(params, 'stopLoss');
3673
- const takeProfit = this.safeValue(params, 'takeProfit');
3674
- const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activePrice', this.numberToString(price));
3675
- const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
3676
- const isTrailingAmountOrder = trailingAmount !== undefined;
3677
- const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
3678
- const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
3679
- const isStopLoss = stopLoss !== undefined;
3680
- const isTakeProfit = takeProfit !== undefined;
3681
- const isBuy = side === 'buy';
3682
3739
  if (isTrailingAmountOrder) {
3683
3740
  if (trailingTriggerPrice !== undefined) {
3684
3741
  request['activePrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
3685
3742
  }
3686
3743
  request['trailingStop'] = trailingAmount;
3687
3744
  }
3688
- else if (triggerPrice !== undefined) {
3745
+ else if (isTriggerOrder && !isAlternativeEndpoint) {
3689
3746
  const triggerDirection = this.safeString(params, 'triggerDirection');
3690
3747
  params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
3691
3748
  if (market['spot']) {
@@ -3702,7 +3759,7 @@ class bybit extends bybit$1 {
3702
3759
  }
3703
3760
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
3704
3761
  }
3705
- else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
3762
+ else if ((isStopLossTriggerOrder || isTakeProfitTriggerOrder) && !isAlternativeEndpoint) {
3706
3763
  if (isBuy) {
3707
3764
  request['triggerDirection'] = isStopLossTriggerOrder ? 1 : 2;
3708
3765
  }
@@ -3713,7 +3770,7 @@ class bybit extends bybit$1 {
3713
3770
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
3714
3771
  request['reduceOnly'] = true;
3715
3772
  }
3716
- if (isStopLoss || isTakeProfit) {
3773
+ if ((isStopLoss || isTakeProfit) && !isAlternativeEndpoint) {
3717
3774
  if (isStopLoss) {
3718
3775
  const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
3719
3776
  request['stopLoss'] = this.priceToPrecision(symbol, slTriggerPrice);
@@ -3735,23 +3792,6 @@ class bybit extends bybit$1 {
3735
3792
  }
3736
3793
  }
3737
3794
  }
3738
- if (market['spot']) {
3739
- // only works for spot market
3740
- if (triggerPrice !== undefined) {
3741
- request['orderFilter'] = 'StopOrder';
3742
- }
3743
- else if (stopLossTriggerPrice !== undefined || takeProfitTriggerPrice !== undefined || isStopLoss || isTakeProfit) {
3744
- request['orderFilter'] = 'tpslOrder';
3745
- }
3746
- }
3747
- const clientOrderId = this.safeString(params, 'clientOrderId');
3748
- if (clientOrderId !== undefined) {
3749
- request['orderLinkId'] = clientOrderId;
3750
- }
3751
- else if (market['option']) {
3752
- // mandatory field for options
3753
- request['orderLinkId'] = this.uuid16();
3754
- }
3755
3795
  params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice']);
3756
3796
  return this.extend(request, params);
3757
3797
  }
@@ -5214,7 +5254,9 @@ class bybit extends bybit$1 {
5214
5254
  }
5215
5255
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
5216
5256
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
5217
- let request = {};
5257
+ let request = {
5258
+ 'execType': 'Trade',
5259
+ };
5218
5260
  let market = undefined;
5219
5261
  let isUsdcSettled = false;
5220
5262
  if (symbol !== undefined) {
@@ -2883,7 +2883,7 @@ class coinbase extends coinbase$1 {
2883
2883
  let paginate = false;
2884
2884
  [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
2885
2885
  if (paginate) {
2886
- return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2886
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 1000);
2887
2887
  }
2888
2888
  let market = undefined;
2889
2889
  if (symbol !== undefined) {