ccxt 4.2.7 → 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.7/dist/ccxt.browser.js
213
- * unpkg: https://unpkg.com/ccxt@4.2.7/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.7/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
@@ -81363,6 +81391,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81363
81391
  * @name bybit#createOrder
81364
81392
  * @description create a trade order
81365
81393
  * @see https://bybit-exchange.github.io/docs/v5/order/create-order
81394
+ * @see https://bybit-exchange.github.io/docs/v5/position/trading-stop
81366
81395
  * @param {string} symbol unified symbol of the market to create an order in
81367
81396
  * @param {string} type 'market' or 'limit'
81368
81397
  * @param {string} side 'buy' or 'sell'
@@ -81384,6 +81413,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81384
81413
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
81385
81414
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
81386
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
81387
81418
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
81388
81419
  */
81389
81420
  await this.loadMarkets();
@@ -81394,8 +81425,16 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81394
81425
  if (isUsdcSettled && !isUnifiedAccount) {
81395
81426
  return await this.createUsdcOrder(symbol, type, side, amount, price, params);
81396
81427
  }
81428
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
81429
+ const isTrailingAmountOrder = trailingAmount !== undefined;
81397
81430
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
81398
- 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
+ }
81399
81438
  //
81400
81439
  // {
81401
81440
  // "retCode": 0,
@@ -81505,12 +81544,21 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81505
81544
  const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
81506
81545
  const stopLoss = this.safeValue(params, 'stopLoss');
81507
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;
81508
81550
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
81509
81551
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
81510
81552
  const isStopLoss = stopLoss !== undefined;
81511
81553
  const isTakeProfit = takeProfit !== undefined;
81512
81554
  const isBuy = side === 'buy';
81513
- 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) {
81514
81562
  const triggerDirection = this.safeString(params, 'triggerDirection');
81515
81563
  params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
81516
81564
  if (market['spot']) {
@@ -81565,7 +81613,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81565
81613
  // mandatory field for options
81566
81614
  request['orderLinkId'] = this.uuid16();
81567
81615
  }
81568
- 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']);
81569
81617
  return this.extend(request, params);
81570
81618
  }
81571
81619
  async createOrders(orders, params = {}) {
@@ -191590,6 +191638,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191590
191638
  const stopLossDefined = (stopLoss !== undefined);
191591
191639
  const takeProfit = this.safeValue(params, 'takeProfit');
191592
191640
  const takeProfitDefined = (takeProfit !== undefined);
191641
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
191642
+ const isTrailingPercentOrder = trailingPercent !== undefined;
191593
191643
  const defaultMarginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
191594
191644
  let marginMode = this.safeString2(params, 'marginMode', 'tdMode'); // cross or isolated, tdMode not ommited so as to be extended into the request
191595
191645
  let margin = false;
@@ -191622,7 +191672,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191622
191672
  const isMarketOrder = type === 'market';
191623
191673
  let postOnly = false;
191624
191674
  [postOnly, params] = this.handlePostOnly(isMarketOrder, type === 'post_only', params);
191625
- 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']);
191626
191676
  const ioc = (timeInForce === 'IOC') || (type === 'ioc');
191627
191677
  const fok = (timeInForce === 'FOK') || (type === 'fok');
191628
191678
  const trigger = (triggerPrice !== undefined) || (type === 'trigger');
@@ -191681,7 +191731,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191681
191731
  else if (fok) {
191682
191732
  request['ordType'] = 'fok';
191683
191733
  }
191684
- 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) {
191685
191740
  if (stopLossDefined) {
191686
191741
  const stopLossTriggerPrice = this.safeValueN(stopLoss, ['triggerPrice', 'stopPrice', 'slTriggerPx']);
191687
191742
  if (stopLossTriggerPrice === undefined) {
@@ -191825,6 +191880,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191825
191880
  * @param {float} [params.stopLoss.price] used for stop loss limit orders, not used for stop loss market price orders
191826
191881
  * @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
191827
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
191828
191884
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
191829
191885
  */
191830
191886
  await this.loadMarkets();
@@ -191832,7 +191888,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191832
191888
  let request = this.createOrderRequest(symbol, type, side, amount, price, params);
191833
191889
  let method = this.safeString(this.options, 'createOrder', 'privatePostTradeBatchOrders');
191834
191890
  const requestOrdType = this.safeString(request, 'ordType');
191835
- 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')) {
191836
191892
  method = 'privatePostTradeOrderAlgo';
191837
191893
  }
191838
191894
  if ((method !== 'privatePostTradeOrder') && (method !== 'privatePostTradeOrderAlgo') && (method !== 'privatePostTradeBatchOrders')) {
@@ -192029,17 +192085,20 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192029
192085
  * @name okx#cancelOrder
192030
192086
  * @description cancels an open order
192031
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
192032
192089
  * @param {string} id order id
192033
192090
  * @param {string} symbol unified symbol of the market the order was made in
192034
192091
  * @param {object} [params] extra parameters specific to the exchange API endpoint
192035
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
192036
192094
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
192037
192095
  */
192038
192096
  if (symbol === undefined) {
192039
192097
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
192040
192098
  }
192041
192099
  const stop = this.safeValue2(params, 'stop', 'trigger');
192042
- if (stop) {
192100
+ const trailing = this.safeValue(params, 'trailing', false);
192101
+ if (stop || trailing) {
192043
192102
  const orderInner = await this.cancelOrders([id], symbol, params);
192044
192103
  return this.safeValue(orderInner, 0);
192045
192104
  }
@@ -192090,6 +192149,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192090
192149
  * @param {string} symbol unified market symbol
192091
192150
  * @param {object} [params] extra parameters specific to the exchange API endpoint
192092
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
192093
192153
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192094
192154
  */
192095
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.
@@ -192105,7 +192165,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192105
192165
  const clientOrderIds = this.parseIds(this.safeValue2(params, 'clOrdId', 'clientOrderId'));
192106
192166
  const algoIds = this.parseIds(this.safeValue(params, 'algoId'));
192107
192167
  const stop = this.safeValue2(params, 'stop', 'trigger');
192108
- if (stop) {
192168
+ const trailing = this.safeValue(params, 'trailing', false);
192169
+ if (stop || trailing) {
192109
192170
  method = 'privatePostTradeCancelAlgos';
192110
192171
  }
192111
192172
  if (clientOrderIds === undefined) {
@@ -192119,7 +192180,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192119
192180
  }
192120
192181
  }
192121
192182
  for (let i = 0; i < ids.length; i++) {
192122
- if (stop) {
192183
+ if (trailing || stop) {
192123
192184
  request.push({
192124
192185
  'algoId': ids[i],
192125
192186
  'instId': market['id'],
@@ -192558,7 +192619,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192558
192619
  /**
192559
192620
  * @method
192560
192621
  * @name okx#fetchOpenOrders
192561
- * @description Fetch orders that are still open
192562
192622
  * @description fetch all unfilled currently open orders
192563
192623
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list
192564
192624
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-list
@@ -192571,6 +192631,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192571
192631
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
192572
192632
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192573
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
192574
192635
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192575
192636
  */
192576
192637
  await this.loadMarkets();
@@ -192603,15 +192664,21 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192603
192664
  let method = this.safeString(params, 'method', defaultMethod);
192604
192665
  const ordType = this.safeString(params, 'ordType');
192605
192666
  const stop = this.safeValue2(params, 'stop', 'trigger');
192606
- if (stop || (ordType in algoOrderTypes)) {
192667
+ const trailing = this.safeValue(params, 'trailing', false);
192668
+ if (trailing || stop || (ordType in algoOrderTypes)) {
192607
192669
  method = 'privateGetTradeOrdersAlgoPending';
192670
+ }
192671
+ if (trailing) {
192672
+ request['ordType'] = 'move_order_stop';
192673
+ }
192674
+ else if (stop || (ordType in algoOrderTypes)) {
192608
192675
  if (stop) {
192609
192676
  if (ordType === undefined) {
192610
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"');
192611
192678
  }
192612
192679
  }
192613
192680
  }
192614
- const query = this.omit(params, ['method', 'stop', 'trigger']);
192681
+ const query = this.omit(params, ['method', 'stop', 'trigger', 'trailing']);
192615
192682
  let response = undefined;
192616
192683
  if (method === 'privateGetTradeOrdersAlgoPending') {
192617
192684
  response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
@@ -192732,6 +192799,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192732
192799
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
192733
192800
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192734
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
192735
192803
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192736
192804
  */
192737
192805
  await this.loadMarkets();
@@ -192765,7 +192833,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192765
192833
  let method = this.safeString(params, 'method', defaultMethod);
192766
192834
  const ordType = this.safeString(params, 'ordType');
192767
192835
  const stop = this.safeValue2(params, 'stop', 'trigger');
192768
- 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)) {
192769
192842
  method = 'privateGetTradeOrdersAlgoHistory';
192770
192843
  const algoId = this.safeString(params, 'algoId');
192771
192844
  if (algoId !== undefined) {
@@ -192776,7 +192849,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192776
192849
  if (ordType === undefined) {
192777
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"');
192778
192851
  }
192779
- request['ordType'] = ordType;
192780
192852
  }
192781
192853
  }
192782
192854
  else {
@@ -192789,7 +192861,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192789
192861
  query = this.omit(query, ['until', 'till']);
192790
192862
  }
192791
192863
  }
192792
- const send = this.omit(query, ['method', 'stop', 'ordType', 'trigger']);
192864
+ const send = this.omit(query, ['method', 'stop', 'trigger', 'trailing']);
192793
192865
  let response = undefined;
192794
192866
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192795
192867
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -192917,6 +192989,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192917
192989
  * @param {int} [params.until] timestamp in ms to fetch orders for
192918
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)
192919
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
192920
192993
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192921
192994
  */
192922
192995
  await this.loadMarkets();
@@ -192954,14 +193027,20 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192954
193027
  let method = this.safeString(params, 'method', defaultMethod);
192955
193028
  const ordType = this.safeString(params, 'ordType');
192956
193029
  const stop = this.safeValue2(params, 'stop', 'trigger');
192957
- if (stop || (ordType in algoOrderTypes)) {
193030
+ const trailing = this.safeValue(params, 'trailing', false);
193031
+ if (trailing || stop || (ordType in algoOrderTypes)) {
192958
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)) {
192959
193039
  if (stop) {
192960
193040
  if (ordType === undefined) {
192961
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"');
192962
193042
  }
192963
193043
  }
192964
- request['state'] = 'effective';
192965
193044
  }
192966
193045
  else {
192967
193046
  if (since !== undefined) {
@@ -192974,7 +193053,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192974
193053
  }
192975
193054
  request['state'] = 'filled';
192976
193055
  }
192977
- const send = this.omit(query, ['method', 'stop', 'trigger']);
193056
+ const send = this.omit(query, ['method', 'stop', 'trigger', 'trailing']);
192978
193057
  let response = undefined;
192979
193058
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192980
193059
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -227595,8 +227674,7 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
227595
227674
  async watchTickers(symbols = undefined, params = {}) {
227596
227675
  /**
227597
227676
  * @method
227598
- * @name okx#watchTickers
227599
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel
227677
+ * @name coinbasepro#watchTickers
227600
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
227601
227679
  * @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
227602
227680
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -229654,13 +229732,19 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229654
229732
  await this.loadMarkets();
229655
229733
  symbols = this.marketSymbols(symbols);
229656
229734
  const topics = [];
229735
+ const messageHashes = [];
229736
+ if (!limit) {
229737
+ limit = 150;
229738
+ }
229657
229739
  for (let i = 0; i < symbols.length; i++) {
229658
229740
  const symbol = symbols[i];
229659
229741
  const market = this.market(symbol);
229660
- const currentTopic = 'book' + '.' + market['id'];
229742
+ const currentTopic = 'book' + '.' + market['id'] + '.' + limit;
229743
+ const messageHash = 'orderbook:' + market['symbol'];
229744
+ messageHashes.push(messageHash);
229661
229745
  topics.push(currentTopic);
229662
229746
  }
229663
- const orderbook = await this.watchPublicMultiple(topics, topics, params);
229747
+ const orderbook = await this.watchPublicMultiple(messageHashes, topics, params);
229664
229748
  return orderbook.limit();
229665
229749
  }
229666
229750
  handleOrderBookSnapshot(client, message) {
@@ -229685,7 +229769,6 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229685
229769
  // ]
229686
229770
  // }
229687
229771
  //
229688
- const messageHash = this.safeString(message, 'subscription');
229689
229772
  const marketId = this.safeString(message, 'instrument_name');
229690
229773
  const market = this.safeMarket(marketId);
229691
229774
  const symbol = market['symbol'];
@@ -229701,6 +229784,7 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229701
229784
  }
229702
229785
  orderbook.reset(snapshot);
229703
229786
  this.orderbooks[symbol] = orderbook;
229787
+ const messageHash = 'orderbook:' + symbol;
229704
229788
  client.resolve(orderbook, messageHash);
229705
229789
  }
229706
229790
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -251923,7 +252007,8 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
251923
252007
  const marketId = this.safeString(data, 'symbol');
251924
252008
  const symbol = this.safeSymbol(marketId);
251925
252009
  const market = this.safeMarket(symbol);
251926
- const timeframe = this.findTimeframe(channel);
252010
+ const timeframes = this.safeValue(this.options, 'timeframes', {});
252011
+ const timeframe = this.findTimeframe(channel, timeframes);
251927
252012
  const messageHash = channel + '::' + symbol;
251928
252013
  const parsed = this.parseWsOHLCV(data, market);
251929
252014
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -291918,7 +292003,7 @@ SOFTWARE.
291918
292003
 
291919
292004
  //-----------------------------------------------------------------------------
291920
292005
  // this is updated by vss.js when building
291921
- const version = '4.2.7';
292006
+ const version = '4.2.8';
291922
292007
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
291923
292008
  //-----------------------------------------------------------------------------
291924
292009