ccxt 4.2.6 → 4.2.8

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 CHANGED
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
209
209
 
210
210
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
211
211
 
212
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.6/dist/ccxt.browser.js
213
- * unpkg: https://unpkg.com/ccxt@4.2.6/dist/ccxt.browser.js
212
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.8/dist/ccxt.browser.js
213
+ * unpkg: https://unpkg.com/ccxt@4.2.8/dist/ccxt.browser.js
214
214
 
215
215
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
216
216
 
217
217
  ```HTML
218
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.6/dist/ccxt.browser.js"></script>
218
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.8/dist/ccxt.browser.js"></script>
219
219
  ```
220
220
 
221
221
  Creates a global `ccxt` object:
@@ -21574,6 +21574,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21574
21574
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
21575
21575
  * @param {boolean} [params.sor] *spot only* whether to use SOR (Smart Order Routing) or not, default is false
21576
21576
  * @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
21577
+ * @param {float} [params.trailingPercent] the percent to trail away from the current market price
21578
+ * @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
21577
21579
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
21578
21580
  */
21579
21581
  await this.loadMarkets();
@@ -21622,6 +21624,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21622
21624
  * @param {float|undefined} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
21623
21625
  * @param {object} params extra parameters specific to the exchange API endpoint
21624
21626
  * @param {string|undefined} params.marginMode 'cross' or 'isolated', for spot margin trading
21627
+ * @param {float} [params.trailingPercent] the percent to trail away from the current market price
21628
+ * @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
21625
21629
  * @returns {object} request to be sent to the exchange
21626
21630
  */
21627
21631
  const market = this.market(symbol);
@@ -21635,9 +21639,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21635
21639
  const stopLossPrice = this.safeValue(params, 'stopLossPrice', triggerPrice); // fallback to stopLoss
21636
21640
  const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
21637
21641
  const trailingDelta = this.safeValue(params, 'trailingDelta');
21642
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', price);
21643
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
21644
+ const isTrailingPercentOrder = trailingPercent !== undefined;
21638
21645
  const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
21639
21646
  const isTakeProfit = takeProfitPrice !== undefined;
21640
- params = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice']);
21647
+ params = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent']);
21641
21648
  const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
21642
21649
  const request = {
21643
21650
  'symbol': market['id'],
@@ -21658,7 +21665,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21658
21665
  }
21659
21666
  let uppercaseType = type.toUpperCase();
21660
21667
  let stopPrice = undefined;
21661
- if (isStopLoss) {
21668
+ if (isTrailingPercentOrder) {
21669
+ uppercaseType = 'TRAILING_STOP_MARKET';
21670
+ request['callbackRate'] = trailingPercent;
21671
+ if (trailingTriggerPrice !== undefined) {
21672
+ request['activationPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
21673
+ }
21674
+ }
21675
+ else if (isStopLoss) {
21662
21676
  stopPrice = stopLossPrice;
21663
21677
  if (isMarketOrder) {
21664
21678
  // spot STOP_LOSS market orders are not a valid order type
@@ -21802,9 +21816,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21802
21816
  }
21803
21817
  else if (uppercaseType === 'TRAILING_STOP_MARKET') {
21804
21818
  quantityIsRequired = true;
21805
- const callbackRate = this.safeNumber(query, 'callbackRate');
21806
- if (callbackRate === undefined) {
21807
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires a callbackRate extra param for a ' + type + ' order');
21819
+ if (trailingPercent === undefined) {
21820
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires a trailingPercent param for a ' + type + ' order');
21808
21821
  }
21809
21822
  }
21810
21823
  if (quantityIsRequired) {
@@ -27432,6 +27445,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27432
27445
  '80014': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
27433
27446
  '80016': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
27434
27447
  '80017': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
27448
+ '100414': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
27435
27449
  '100437': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, // {"code":100437,"msg":"The withdrawal amount is lower than the minimum limit, please re-enter.","timestamp":1689258588845}
27436
27450
  },
27437
27451
  'broad': {},
@@ -28975,12 +28989,26 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28975
28989
  // }
28976
28990
  //
28977
28991
  if (typeof response === 'string') {
28992
+ // broken api engine : order-ids are too long numbers (i.e. 1742930526912864656)
28993
+ // and JSON.parse can not handle them in JS, so we have to use .parseJson
28994
+ // however, when order has an attached SL/TP, their value types need extra parsing
28995
+ response = this.fixStringifiedJsonMembers(response);
28978
28996
  response = this.parseJson(response);
28979
28997
  }
28980
28998
  const data = this.safeValue(response, 'data', {});
28981
28999
  const order = this.safeValue(data, 'order', data);
28982
29000
  return this.parseOrder(order, market);
28983
29001
  }
29002
+ fixStringifiedJsonMembers(content) {
29003
+ // when stringified json has members with their values also stringified, like:
29004
+ // '{"code":0, "data":{"order":{"orderId":1742968678528512345,"symbol":"BTC-USDT", "takeProfit":"{\"type\":\"TAKE_PROFIT\",\"stopPrice\":43320.1}","reduceOnly":false}}}'
29005
+ // we can fix with below manipulations
29006
+ // @ts-ignore
29007
+ let modifiedContent = content.replaceAll('\\', '');
29008
+ modifiedContent = modifiedContent.replaceAll('"{', '{');
29009
+ modifiedContent = modifiedContent.replaceAll('}"', '}');
29010
+ return modifiedContent;
29011
+ }
28984
29012
  async createOrders(orders, params = {}) {
28985
29013
  /**
28986
29014
  * @method
@@ -54503,6 +54531,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
54503
54531
  'chat/connected': 5,
54504
54532
  'chat/pinned': 5,
54505
54533
  'funding': 5,
54534
+ 'guild': 5,
54506
54535
  'instrument': 5,
54507
54536
  'instrument/active': 5,
54508
54537
  'instrument/activeAndIndices': 5,
@@ -54531,6 +54560,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
54531
54560
  },
54532
54561
  'private': {
54533
54562
  'get': {
54563
+ 'address': 5,
54534
54564
  'apiKey': 5,
54535
54565
  'execution': 5,
54536
54566
  'execution/tradeHistory': 5,
@@ -54543,21 +54573,33 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
54543
54573
  'user/affiliateStatus': 5,
54544
54574
  'user/checkReferralCode': 5,
54545
54575
  'user/commission': 5,
54576
+ 'user/csa': 5,
54546
54577
  'user/depositAddress': 5,
54547
54578
  'user/executionHistory': 5,
54579
+ 'user/getWalletTransferAccounts': 5,
54548
54580
  'user/margin': 5,
54549
54581
  'user/quoteFillRatio': 5,
54550
54582
  'user/quoteValueRatio': 5,
54583
+ 'user/staking': 5,
54584
+ 'user/staking/instruments': 5,
54585
+ 'user/staking/tiers': 5,
54551
54586
  'user/tradingVolume': 5,
54587
+ 'user/unstakingRequests': 5,
54552
54588
  'user/wallet': 5,
54553
54589
  'user/walletHistory': 5,
54554
54590
  'user/walletSummary': 5,
54591
+ 'userAffiliates': 5,
54555
54592
  'userEvent': 5,
54556
54593
  },
54557
54594
  'post': {
54595
+ 'address': 5,
54558
54596
  'chat': 5,
54597
+ 'guild': 5,
54598
+ 'guild/archive': 5,
54559
54599
  'guild/join': 5,
54600
+ 'guild/kick': 5,
54560
54601
  'guild/leave': 5,
54602
+ 'guild/sharesTrades': 5,
54561
54603
  'order': 1,
54562
54604
  'order/cancelAllAfter': 5,
54563
54605
  'order/closePosition': 5,
@@ -54565,6 +54607,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
54565
54607
  'position/leverage': 1,
54566
54608
  'position/riskLimit': 5,
54567
54609
  'position/transferMargin': 1,
54610
+ 'user/addSubaccount': 5,
54568
54611
  'user/cancelWithdrawal': 5,
54569
54612
  'user/communicationToken': 5,
54570
54613
  'user/confirmEmail': 5,
@@ -54572,13 +54615,18 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
54572
54615
  'user/logout': 5,
54573
54616
  'user/preferences': 5,
54574
54617
  'user/requestWithdrawal': 5,
54618
+ 'user/unstakingRequests': 5,
54619
+ 'user/updateSubaccount': 5,
54620
+ 'user/walletTransfer': 5,
54575
54621
  },
54576
54622
  'put': {
54623
+ 'guild': 5,
54577
54624
  'order': 1,
54578
54625
  },
54579
54626
  'delete': {
54580
54627
  'order': 1,
54581
54628
  'order/all': 1,
54629
+ 'user/unstakingRequests': 5,
54582
54630
  },
54583
54631
  },
54584
54632
  },
@@ -55966,13 +56014,11 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
55966
56014
  let fee = undefined;
55967
56015
  const feeCostString = this.numberToString(this.convertFromRawCost(symbol, this.safeString(trade, 'execComm')));
55968
56016
  if (feeCostString !== undefined) {
55969
- const currencyId = this.safeString(trade, 'settlCurrency');
55970
- const feeCurrencyCode = this.safeCurrencyCode(currencyId);
55971
- const feeRateString = this.safeString(trade, 'commission');
56017
+ const currencyId = this.safeString2(trade, 'settlCurrency', 'currency');
55972
56018
  fee = {
55973
- 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCostString),
55974
- 'currency': feeCurrencyCode,
55975
- 'rate': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeRateString),
56019
+ 'cost': feeCostString,
56020
+ 'currency': this.safeCurrencyCode(currencyId),
56021
+ 'rate': this.safeString(trade, 'commission'),
55976
56022
  };
55977
56023
  }
55978
56024
  // Trade or Funding
@@ -81345,6 +81391,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81345
81391
  * @name bybit#createOrder
81346
81392
  * @description create a trade order
81347
81393
  * @see https://bybit-exchange.github.io/docs/v5/order/create-order
81394
+ * @see https://bybit-exchange.github.io/docs/v5/position/trading-stop
81348
81395
  * @param {string} symbol unified symbol of the market to create an order in
81349
81396
  * @param {string} type 'market' or 'limit'
81350
81397
  * @param {string} side 'buy' or 'sell'
@@ -81366,6 +81413,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81366
81413
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
81367
81414
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
81368
81415
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
81416
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
81417
+ * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
81369
81418
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
81370
81419
  */
81371
81420
  await this.loadMarkets();
@@ -81376,8 +81425,16 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81376
81425
  if (isUsdcSettled && !isUnifiedAccount) {
81377
81426
  return await this.createUsdcOrder(symbol, type, side, amount, price, params);
81378
81427
  }
81428
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
81429
+ const isTrailingAmountOrder = trailingAmount !== undefined;
81379
81430
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
81380
- const response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
81431
+ let response = undefined;
81432
+ if (isTrailingAmountOrder) {
81433
+ response = await this.privatePostV5PositionTradingStop(orderRequest);
81434
+ }
81435
+ else {
81436
+ response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
81437
+ }
81381
81438
  //
81382
81439
  // {
81383
81440
  // "retCode": 0,
@@ -81487,12 +81544,21 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81487
81544
  const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
81488
81545
  const stopLoss = this.safeValue(params, 'stopLoss');
81489
81546
  const takeProfit = this.safeValue(params, 'takeProfit');
81547
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activePrice', price);
81548
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
81549
+ const isTrailingAmountOrder = trailingAmount !== undefined;
81490
81550
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
81491
81551
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
81492
81552
  const isStopLoss = stopLoss !== undefined;
81493
81553
  const isTakeProfit = takeProfit !== undefined;
81494
81554
  const isBuy = side === 'buy';
81495
- if (triggerPrice !== undefined) {
81555
+ if (isTrailingAmountOrder) {
81556
+ if (trailingTriggerPrice !== undefined) {
81557
+ request['activePrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
81558
+ }
81559
+ request['trailingStop'] = trailingAmount;
81560
+ }
81561
+ else if (triggerPrice !== undefined) {
81496
81562
  const triggerDirection = this.safeString(params, 'triggerDirection');
81497
81563
  params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
81498
81564
  if (market['spot']) {
@@ -81547,7 +81613,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81547
81613
  // mandatory field for options
81548
81614
  request['orderLinkId'] = this.uuid16();
81549
81615
  }
81550
- params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit']);
81616
+ params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice']);
81551
81617
  return this.extend(request, params);
81552
81618
  }
81553
81619
  async createOrders(orders, params = {}) {
@@ -191572,6 +191638,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191572
191638
  const stopLossDefined = (stopLoss !== undefined);
191573
191639
  const takeProfit = this.safeValue(params, 'takeProfit');
191574
191640
  const takeProfitDefined = (takeProfit !== undefined);
191641
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
191642
+ const isTrailingPercentOrder = trailingPercent !== undefined;
191575
191643
  const defaultMarginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
191576
191644
  let marginMode = this.safeString2(params, 'marginMode', 'tdMode'); // cross or isolated, tdMode not ommited so as to be extended into the request
191577
191645
  let margin = false;
@@ -191604,7 +191672,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191604
191672
  const isMarketOrder = type === 'market';
191605
191673
  let postOnly = false;
191606
191674
  [postOnly, params] = this.handlePostOnly(isMarketOrder, type === 'post_only', params);
191607
- params = this.omit(params, ['currency', 'ccy', 'marginMode', 'timeInForce', 'stopPrice', 'triggerPrice', 'clientOrderId', 'stopLossPrice', 'takeProfitPrice', 'slOrdPx', 'tpOrdPx', 'margin', 'stopLoss', 'takeProfit']);
191675
+ params = this.omit(params, ['currency', 'ccy', 'marginMode', 'timeInForce', 'stopPrice', 'triggerPrice', 'clientOrderId', 'stopLossPrice', 'takeProfitPrice', 'slOrdPx', 'tpOrdPx', 'margin', 'stopLoss', 'takeProfit', 'trailingPercent']);
191608
191676
  const ioc = (timeInForce === 'IOC') || (type === 'ioc');
191609
191677
  const fok = (timeInForce === 'FOK') || (type === 'fok');
191610
191678
  const trigger = (triggerPrice !== undefined) || (type === 'trigger');
@@ -191663,7 +191731,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191663
191731
  else if (fok) {
191664
191732
  request['ordType'] = 'fok';
191665
191733
  }
191666
- if (stopLossDefined || takeProfitDefined) {
191734
+ if (isTrailingPercentOrder) {
191735
+ const convertedTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
191736
+ request['callbackRatio'] = convertedTrailingPercent;
191737
+ request['ordType'] = 'move_order_stop';
191738
+ }
191739
+ else if (stopLossDefined || takeProfitDefined) {
191667
191740
  if (stopLossDefined) {
191668
191741
  const stopLossTriggerPrice = this.safeValueN(stopLoss, ['triggerPrice', 'stopPrice', 'slTriggerPx']);
191669
191742
  if (stopLossTriggerPrice === undefined) {
@@ -191807,6 +191880,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191807
191880
  * @param {float} [params.stopLoss.price] used for stop loss limit orders, not used for stop loss market price orders
191808
191881
  * @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
191809
191882
  * @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
191883
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
191810
191884
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
191811
191885
  */
191812
191886
  await this.loadMarkets();
@@ -191814,7 +191888,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191814
191888
  let request = this.createOrderRequest(symbol, type, side, amount, price, params);
191815
191889
  let method = this.safeString(this.options, 'createOrder', 'privatePostTradeBatchOrders');
191816
191890
  const requestOrdType = this.safeString(request, 'ordType');
191817
- if ((requestOrdType === 'trigger') || (requestOrdType === 'conditional') || (type === 'oco') || (type === 'move_order_stop') || (type === 'iceberg') || (type === 'twap')) {
191891
+ if ((requestOrdType === 'trigger') || (requestOrdType === 'conditional') || (requestOrdType === 'move_order_stop') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
191818
191892
  method = 'privatePostTradeOrderAlgo';
191819
191893
  }
191820
191894
  if ((method !== 'privatePostTradeOrder') && (method !== 'privatePostTradeOrderAlgo') && (method !== 'privatePostTradeBatchOrders')) {
@@ -192011,17 +192085,20 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192011
192085
  * @name okx#cancelOrder
192012
192086
  * @description cancels an open order
192013
192087
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-order
192088
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
192014
192089
  * @param {string} id order id
192015
192090
  * @param {string} symbol unified symbol of the market the order was made in
192016
192091
  * @param {object} [params] extra parameters specific to the exchange API endpoint
192017
192092
  * @param {boolean} [params.trigger] true if trigger orders
192093
+ * @param {boolean} [params.trailing] set to true if you want to cancel a trailing order
192018
192094
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
192019
192095
  */
192020
192096
  if (symbol === undefined) {
192021
192097
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
192022
192098
  }
192023
192099
  const stop = this.safeValue2(params, 'stop', 'trigger');
192024
- if (stop) {
192100
+ const trailing = this.safeValue(params, 'trailing', false);
192101
+ if (stop || trailing) {
192025
192102
  const orderInner = await this.cancelOrders([id], symbol, params);
192026
192103
  return this.safeValue(orderInner, 0);
192027
192104
  }
@@ -192072,6 +192149,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192072
192149
  * @param {string} symbol unified market symbol
192073
192150
  * @param {object} [params] extra parameters specific to the exchange API endpoint
192074
192151
  * @param {boolean} [params.trigger] whether the order is a stop/trigger order
192152
+ * @param {boolean} [params.trailing] set to true if you want to cancel trailing orders
192075
192153
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192076
192154
  */
192077
192155
  // TODO : the original endpoint signature differs, according to that you can skip individual symbol and assign ids in batch. At this moment, `params` is not being used too.
@@ -192087,7 +192165,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192087
192165
  const clientOrderIds = this.parseIds(this.safeValue2(params, 'clOrdId', 'clientOrderId'));
192088
192166
  const algoIds = this.parseIds(this.safeValue(params, 'algoId'));
192089
192167
  const stop = this.safeValue2(params, 'stop', 'trigger');
192090
- if (stop) {
192168
+ const trailing = this.safeValue(params, 'trailing', false);
192169
+ if (stop || trailing) {
192091
192170
  method = 'privatePostTradeCancelAlgos';
192092
192171
  }
192093
192172
  if (clientOrderIds === undefined) {
@@ -192101,7 +192180,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192101
192180
  }
192102
192181
  }
192103
192182
  for (let i = 0; i < ids.length; i++) {
192104
- if (stop) {
192183
+ if (trailing || stop) {
192105
192184
  request.push({
192106
192185
  'algoId': ids[i],
192107
192186
  'instId': market['id'],
@@ -192540,7 +192619,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192540
192619
  /**
192541
192620
  * @method
192542
192621
  * @name okx#fetchOpenOrders
192543
- * @description Fetch orders that are still open
192544
192622
  * @description fetch all unfilled currently open orders
192545
192623
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list
192546
192624
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-list
@@ -192553,6 +192631,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192553
192631
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
192554
192632
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192555
192633
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
192634
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
192556
192635
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192557
192636
  */
192558
192637
  await this.loadMarkets();
@@ -192585,15 +192664,21 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192585
192664
  let method = this.safeString(params, 'method', defaultMethod);
192586
192665
  const ordType = this.safeString(params, 'ordType');
192587
192666
  const stop = this.safeValue2(params, 'stop', 'trigger');
192588
- if (stop || (ordType in algoOrderTypes)) {
192667
+ const trailing = this.safeValue(params, 'trailing', false);
192668
+ if (trailing || stop || (ordType in algoOrderTypes)) {
192589
192669
  method = 'privateGetTradeOrdersAlgoPending';
192670
+ }
192671
+ if (trailing) {
192672
+ request['ordType'] = 'move_order_stop';
192673
+ }
192674
+ else if (stop || (ordType in algoOrderTypes)) {
192590
192675
  if (stop) {
192591
192676
  if (ordType === undefined) {
192592
192677
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
192593
192678
  }
192594
192679
  }
192595
192680
  }
192596
- const query = this.omit(params, ['method', 'stop', 'trigger']);
192681
+ const query = this.omit(params, ['method', 'stop', 'trigger', 'trailing']);
192597
192682
  let response = undefined;
192598
192683
  if (method === 'privateGetTradeOrdersAlgoPending') {
192599
192684
  response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
@@ -192714,6 +192799,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192714
192799
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
192715
192800
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192716
192801
  * @param {int} [params.until] timestamp in ms to fetch orders for
192802
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
192717
192803
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192718
192804
  */
192719
192805
  await this.loadMarkets();
@@ -192747,7 +192833,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192747
192833
  let method = this.safeString(params, 'method', defaultMethod);
192748
192834
  const ordType = this.safeString(params, 'ordType');
192749
192835
  const stop = this.safeValue2(params, 'stop', 'trigger');
192750
- if (stop || (ordType in algoOrderTypes)) {
192836
+ const trailing = this.safeValue(params, 'trailing', false);
192837
+ if (trailing) {
192838
+ method = 'privateGetTradeOrdersAlgoHistory';
192839
+ request['ordType'] = 'move_order_stop';
192840
+ }
192841
+ else if (stop || (ordType in algoOrderTypes)) {
192751
192842
  method = 'privateGetTradeOrdersAlgoHistory';
192752
192843
  const algoId = this.safeString(params, 'algoId');
192753
192844
  if (algoId !== undefined) {
@@ -192758,7 +192849,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192758
192849
  if (ordType === undefined) {
192759
192850
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchCanceledOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
192760
192851
  }
192761
- request['ordType'] = ordType;
192762
192852
  }
192763
192853
  }
192764
192854
  else {
@@ -192771,7 +192861,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192771
192861
  query = this.omit(query, ['until', 'till']);
192772
192862
  }
192773
192863
  }
192774
- const send = this.omit(query, ['method', 'stop', 'ordType', 'trigger']);
192864
+ const send = this.omit(query, ['method', 'stop', 'trigger', 'trailing']);
192775
192865
  let response = undefined;
192776
192866
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192777
192867
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -192899,6 +192989,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192899
192989
  * @param {int} [params.until] timestamp in ms to fetch orders for
192900
192990
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
192901
192991
  * @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
192992
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
192902
192993
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192903
192994
  */
192904
192995
  await this.loadMarkets();
@@ -192936,14 +193027,20 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192936
193027
  let method = this.safeString(params, 'method', defaultMethod);
192937
193028
  const ordType = this.safeString(params, 'ordType');
192938
193029
  const stop = this.safeValue2(params, 'stop', 'trigger');
192939
- if (stop || (ordType in algoOrderTypes)) {
193030
+ const trailing = this.safeValue(params, 'trailing', false);
193031
+ if (trailing || stop || (ordType in algoOrderTypes)) {
192940
193032
  method = 'privateGetTradeOrdersAlgoHistory';
193033
+ request['state'] = 'effective';
193034
+ }
193035
+ if (trailing) {
193036
+ request['ordType'] = 'move_order_stop';
193037
+ }
193038
+ else if (stop || (ordType in algoOrderTypes)) {
192941
193039
  if (stop) {
192942
193040
  if (ordType === undefined) {
192943
193041
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchClosedOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
192944
193042
  }
192945
193043
  }
192946
- request['state'] = 'effective';
192947
193044
  }
192948
193045
  else {
192949
193046
  if (since !== undefined) {
@@ -192956,7 +193053,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192956
193053
  }
192957
193054
  request['state'] = 'filled';
192958
193055
  }
192959
- const send = this.omit(query, ['method', 'stop', 'trigger']);
193056
+ const send = this.omit(query, ['method', 'stop', 'trigger', 'trailing']);
192960
193057
  let response = undefined;
192961
193058
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192962
193059
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -198594,7 +198691,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
198594
198691
  },
198595
198692
  },
198596
198693
  'options': {
198597
- 'brokerId': 'ccxt2022',
198694
+ 'brokerId': 'CCXT',
198598
198695
  'x-phemex-request-expiry': 60,
198599
198696
  'createOrderByQuoteRequiresPrice': true,
198600
198697
  'networks': {
@@ -227577,8 +227674,7 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
227577
227674
  async watchTickers(symbols = undefined, params = {}) {
227578
227675
  /**
227579
227676
  * @method
227580
- * @name okx#watchTickers
227581
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel
227677
+ * @name coinbasepro#watchTickers
227582
227678
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
227583
227679
  * @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
227584
227680
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -229636,13 +229732,19 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229636
229732
  await this.loadMarkets();
229637
229733
  symbols = this.marketSymbols(symbols);
229638
229734
  const topics = [];
229735
+ const messageHashes = [];
229736
+ if (!limit) {
229737
+ limit = 150;
229738
+ }
229639
229739
  for (let i = 0; i < symbols.length; i++) {
229640
229740
  const symbol = symbols[i];
229641
229741
  const market = this.market(symbol);
229642
- const currentTopic = 'book' + '.' + market['id'];
229742
+ const currentTopic = 'book' + '.' + market['id'] + '.' + limit;
229743
+ const messageHash = 'orderbook:' + market['symbol'];
229744
+ messageHashes.push(messageHash);
229643
229745
  topics.push(currentTopic);
229644
229746
  }
229645
- const orderbook = await this.watchPublicMultiple(topics, topics, params);
229747
+ const orderbook = await this.watchPublicMultiple(messageHashes, topics, params);
229646
229748
  return orderbook.limit();
229647
229749
  }
229648
229750
  handleOrderBookSnapshot(client, message) {
@@ -229667,7 +229769,6 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229667
229769
  // ]
229668
229770
  // }
229669
229771
  //
229670
- const messageHash = this.safeString(message, 'subscription');
229671
229772
  const marketId = this.safeString(message, 'instrument_name');
229672
229773
  const market = this.safeMarket(marketId);
229673
229774
  const symbol = market['symbol'];
@@ -229683,6 +229784,7 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229683
229784
  }
229684
229785
  orderbook.reset(snapshot);
229685
229786
  this.orderbooks[symbol] = orderbook;
229787
+ const messageHash = 'orderbook:' + symbol;
229686
229788
  client.resolve(orderbook, messageHash);
229687
229789
  }
229688
229790
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -251905,7 +252007,8 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
251905
252007
  const marketId = this.safeString(data, 'symbol');
251906
252008
  const symbol = this.safeSymbol(marketId);
251907
252009
  const market = this.safeMarket(symbol);
251908
- const timeframe = this.findTimeframe(channel);
252010
+ const timeframes = this.safeValue(this.options, 'timeframes', {});
252011
+ const timeframe = this.findTimeframe(channel, timeframes);
251909
252012
  const messageHash = channel + '::' + symbol;
251910
252013
  const parsed = this.parseWsOHLCV(data, market);
251911
252014
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -291900,7 +292003,7 @@ SOFTWARE.
291900
292003
 
291901
292004
  //-----------------------------------------------------------------------------
291902
292005
  // this is updated by vss.js when building
291903
- const version = '4.2.6';
292006
+ const version = '4.2.8';
291904
292007
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
291905
292008
  //-----------------------------------------------------------------------------
291906
292009