ccxt 4.2.7 → 4.2.9

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.
@@ -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
@@ -50301,7 +50329,11 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50301
50329
  '30012': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
50302
50330
  '30013': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded,
50303
50331
  '30014': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeNotAvailable,
50304
- // funding account errors
50332
+ '30016': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OnMaintenance,
50333
+ '30017': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded,
50334
+ '30018': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50335
+ '30019': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50336
+ // funding account & sub account errors
50305
50337
  '60000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50306
50338
  '60001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50307
50339
  '60002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
@@ -50318,13 +50350,31 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50318
50350
  '60020': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50319
50351
  '60021': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50320
50352
  '60022': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50353
+ '60026': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50354
+ '60027': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50355
+ '60028': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
50356
+ '60029': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
50321
50357
  '60030': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50322
50358
  '60031': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50323
50359
  '60050': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50324
50360
  '60051': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50325
50361
  '61001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
50326
50362
  '61003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50327
- // spot errors
50363
+ '61004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50364
+ '61005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50365
+ '61006': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported,
50366
+ '61007': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50367
+ '61008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50368
+ // spot public errors
50369
+ '70000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50370
+ '70001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50371
+ '70002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
50372
+ '71001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50373
+ '71002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50374
+ '71003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50375
+ '71004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50376
+ '71005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50377
+ // spot & margin errors
50328
50378
  '50000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50329
50379
  '50001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
50330
50380
  '50002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
@@ -50344,26 +50394,75 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50344
50394
  '50016': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50345
50395
  '50017': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50346
50396
  '50018': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50347
- '50019': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50348
- '51004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
50349
- // '50019': ExchangeError, // 400, Invalid status. validate status is [1=Failed, 2=Success, 3=Frozen Failed, 4=Frozen Success, 5=Partially Filled, 6=Fully Fulled, 7=Canceling, 8=Canceled
50397
+ '50019': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50350
50398
  '50020': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
50351
50399
  '50021': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50352
50400
  '50022': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeNotAvailable,
50353
50401
  '50023': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
50402
+ '50024': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50403
+ '50025': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50404
+ '50026': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50405
+ '50027': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50406
+ '50028': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50354
50407
  '50029': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50355
- '50030': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50408
+ '50030': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
50409
+ '50031': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
50356
50410
  '50032': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
50411
+ '50033': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50357
50412
  // below Error codes used interchangeably for both failed postOnly and IOC orders depending on market price and order side
50358
- '50035': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50359
50413
  '50034': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50414
+ '50035': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50415
+ '50036': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50416
+ '50037': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50417
+ '50038': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50418
+ '50039': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50419
+ '50040': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
50420
+ '50041': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50421
+ '50042': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50422
+ '51000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
50423
+ '51001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50424
+ '51002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50425
+ '51003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50426
+ '51004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
50427
+ '51005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50428
+ '51006': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50429
+ '51007': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50430
+ '51008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50431
+ '51009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50432
+ '51010': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50360
50433
  '51011': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50434
+ '51012': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50435
+ '51013': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50436
+ '51014': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50437
+ '51015': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50438
+ '52000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50439
+ '52001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50440
+ '52002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50441
+ '52003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50442
+ '52004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50361
50443
  '53000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
50362
50444
  '53001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
50445
+ '53002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50446
+ '53003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50447
+ '53005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50448
+ '53006': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50449
+ '53007': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50450
+ '53008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50451
+ '53009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50452
+ '53010': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50363
50453
  '57001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50364
50454
  '58001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50365
50455
  '59001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50366
50456
  '59002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50457
+ '59003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50458
+ '59004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50459
+ '59005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50460
+ '59006': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50461
+ '59007': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50462
+ '59008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50463
+ '59009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50464
+ '59010': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
50465
+ '59011': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50367
50466
  // contract errors
50368
50467
  '40001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
50369
50468
  '40002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
@@ -50399,14 +50498,22 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50399
50498
  '40032': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50400
50499
  '40033': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50401
50500
  '40034': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
50402
- '53002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50403
- '53003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50404
- '53005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50405
- '53006': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50406
- '53007': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50407
- '53008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50408
- '53009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50409
- '53010': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied, // 403 This account is restricted from borrowing
50501
+ '40035': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
50502
+ '40036': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50503
+ '40037': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
50504
+ '40038': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50505
+ '40039': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50506
+ '40040': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50507
+ '40041': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50508
+ '40042': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50509
+ '40043': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50510
+ '40044': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50511
+ '40045': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
50512
+ '40046': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50513
+ '40047': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
50514
+ '40048': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50515
+ '40049': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
50516
+ '40050': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, // 403, Client OrderId duplicated with existing orders
50410
50517
  },
50411
50518
  'broad': {},
50412
50519
  },
@@ -81363,6 +81470,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81363
81470
  * @name bybit#createOrder
81364
81471
  * @description create a trade order
81365
81472
  * @see https://bybit-exchange.github.io/docs/v5/order/create-order
81473
+ * @see https://bybit-exchange.github.io/docs/v5/position/trading-stop
81366
81474
  * @param {string} symbol unified symbol of the market to create an order in
81367
81475
  * @param {string} type 'market' or 'limit'
81368
81476
  * @param {string} side 'buy' or 'sell'
@@ -81384,6 +81492,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81384
81492
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
81385
81493
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
81386
81494
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
81495
+ * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
81496
+ * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
81387
81497
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
81388
81498
  */
81389
81499
  await this.loadMarkets();
@@ -81394,8 +81504,16 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81394
81504
  if (isUsdcSettled && !isUnifiedAccount) {
81395
81505
  return await this.createUsdcOrder(symbol, type, side, amount, price, params);
81396
81506
  }
81507
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
81508
+ const isTrailingAmountOrder = trailingAmount !== undefined;
81397
81509
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
81398
- const response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
81510
+ let response = undefined;
81511
+ if (isTrailingAmountOrder) {
81512
+ response = await this.privatePostV5PositionTradingStop(orderRequest);
81513
+ }
81514
+ else {
81515
+ response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
81516
+ }
81399
81517
  //
81400
81518
  // {
81401
81519
  // "retCode": 0,
@@ -81505,12 +81623,21 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81505
81623
  const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
81506
81624
  const stopLoss = this.safeValue(params, 'stopLoss');
81507
81625
  const takeProfit = this.safeValue(params, 'takeProfit');
81626
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activePrice', price);
81627
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
81628
+ const isTrailingAmountOrder = trailingAmount !== undefined;
81508
81629
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
81509
81630
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
81510
81631
  const isStopLoss = stopLoss !== undefined;
81511
81632
  const isTakeProfit = takeProfit !== undefined;
81512
81633
  const isBuy = side === 'buy';
81513
- if (triggerPrice !== undefined) {
81634
+ if (isTrailingAmountOrder) {
81635
+ if (trailingTriggerPrice !== undefined) {
81636
+ request['activePrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
81637
+ }
81638
+ request['trailingStop'] = trailingAmount;
81639
+ }
81640
+ else if (triggerPrice !== undefined) {
81514
81641
  const triggerDirection = this.safeString(params, 'triggerDirection');
81515
81642
  params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
81516
81643
  if (market['spot']) {
@@ -81565,7 +81692,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81565
81692
  // mandatory field for options
81566
81693
  request['orderLinkId'] = this.uuid16();
81567
81694
  }
81568
- params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit']);
81695
+ params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice']);
81569
81696
  return this.extend(request, params);
81570
81697
  }
81571
81698
  async createOrders(orders, params = {}) {
@@ -191590,6 +191717,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191590
191717
  const stopLossDefined = (stopLoss !== undefined);
191591
191718
  const takeProfit = this.safeValue(params, 'takeProfit');
191592
191719
  const takeProfitDefined = (takeProfit !== undefined);
191720
+ const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
191721
+ const isTrailingPercentOrder = trailingPercent !== undefined;
191593
191722
  const defaultMarginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
191594
191723
  let marginMode = this.safeString2(params, 'marginMode', 'tdMode'); // cross or isolated, tdMode not ommited so as to be extended into the request
191595
191724
  let margin = false;
@@ -191622,7 +191751,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191622
191751
  const isMarketOrder = type === 'market';
191623
191752
  let postOnly = false;
191624
191753
  [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']);
191754
+ params = this.omit(params, ['currency', 'ccy', 'marginMode', 'timeInForce', 'stopPrice', 'triggerPrice', 'clientOrderId', 'stopLossPrice', 'takeProfitPrice', 'slOrdPx', 'tpOrdPx', 'margin', 'stopLoss', 'takeProfit', 'trailingPercent']);
191626
191755
  const ioc = (timeInForce === 'IOC') || (type === 'ioc');
191627
191756
  const fok = (timeInForce === 'FOK') || (type === 'fok');
191628
191757
  const trigger = (triggerPrice !== undefined) || (type === 'trigger');
@@ -191681,7 +191810,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191681
191810
  else if (fok) {
191682
191811
  request['ordType'] = 'fok';
191683
191812
  }
191684
- if (stopLossDefined || takeProfitDefined) {
191813
+ if (isTrailingPercentOrder) {
191814
+ const convertedTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
191815
+ request['callbackRatio'] = convertedTrailingPercent;
191816
+ request['ordType'] = 'move_order_stop';
191817
+ }
191818
+ else if (stopLossDefined || takeProfitDefined) {
191685
191819
  if (stopLossDefined) {
191686
191820
  const stopLossTriggerPrice = this.safeValueN(stopLoss, ['triggerPrice', 'stopPrice', 'slTriggerPx']);
191687
191821
  if (stopLossTriggerPrice === undefined) {
@@ -191825,6 +191959,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191825
191959
  * @param {float} [params.stopLoss.price] used for stop loss limit orders, not used for stop loss market price orders
191826
191960
  * @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
191827
191961
  * @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
191962
+ * @param {string} [params.trailingPercent] the percent to trail away from the current market price
191828
191963
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
191829
191964
  */
191830
191965
  await this.loadMarkets();
@@ -191832,7 +191967,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191832
191967
  let request = this.createOrderRequest(symbol, type, side, amount, price, params);
191833
191968
  let method = this.safeString(this.options, 'createOrder', 'privatePostTradeBatchOrders');
191834
191969
  const requestOrdType = this.safeString(request, 'ordType');
191835
- if ((requestOrdType === 'trigger') || (requestOrdType === 'conditional') || (type === 'oco') || (type === 'move_order_stop') || (type === 'iceberg') || (type === 'twap')) {
191970
+ if ((requestOrdType === 'trigger') || (requestOrdType === 'conditional') || (requestOrdType === 'move_order_stop') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
191836
191971
  method = 'privatePostTradeOrderAlgo';
191837
191972
  }
191838
191973
  if ((method !== 'privatePostTradeOrder') && (method !== 'privatePostTradeOrderAlgo') && (method !== 'privatePostTradeBatchOrders')) {
@@ -192029,17 +192164,20 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192029
192164
  * @name okx#cancelOrder
192030
192165
  * @description cancels an open order
192031
192166
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-order
192167
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
192032
192168
  * @param {string} id order id
192033
192169
  * @param {string} symbol unified symbol of the market the order was made in
192034
192170
  * @param {object} [params] extra parameters specific to the exchange API endpoint
192035
192171
  * @param {boolean} [params.trigger] true if trigger orders
192172
+ * @param {boolean} [params.trailing] set to true if you want to cancel a trailing order
192036
192173
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
192037
192174
  */
192038
192175
  if (symbol === undefined) {
192039
192176
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
192040
192177
  }
192041
192178
  const stop = this.safeValue2(params, 'stop', 'trigger');
192042
- if (stop) {
192179
+ const trailing = this.safeValue(params, 'trailing', false);
192180
+ if (stop || trailing) {
192043
192181
  const orderInner = await this.cancelOrders([id], symbol, params);
192044
192182
  return this.safeValue(orderInner, 0);
192045
192183
  }
@@ -192090,6 +192228,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192090
192228
  * @param {string} symbol unified market symbol
192091
192229
  * @param {object} [params] extra parameters specific to the exchange API endpoint
192092
192230
  * @param {boolean} [params.trigger] whether the order is a stop/trigger order
192231
+ * @param {boolean} [params.trailing] set to true if you want to cancel trailing orders
192093
192232
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192094
192233
  */
192095
192234
  // 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 +192244,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192105
192244
  const clientOrderIds = this.parseIds(this.safeValue2(params, 'clOrdId', 'clientOrderId'));
192106
192245
  const algoIds = this.parseIds(this.safeValue(params, 'algoId'));
192107
192246
  const stop = this.safeValue2(params, 'stop', 'trigger');
192108
- if (stop) {
192247
+ const trailing = this.safeValue(params, 'trailing', false);
192248
+ if (stop || trailing) {
192109
192249
  method = 'privatePostTradeCancelAlgos';
192110
192250
  }
192111
192251
  if (clientOrderIds === undefined) {
@@ -192119,7 +192259,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192119
192259
  }
192120
192260
  }
192121
192261
  for (let i = 0; i < ids.length; i++) {
192122
- if (stop) {
192262
+ if (trailing || stop) {
192123
192263
  request.push({
192124
192264
  'algoId': ids[i],
192125
192265
  'instId': market['id'],
@@ -192558,7 +192698,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192558
192698
  /**
192559
192699
  * @method
192560
192700
  * @name okx#fetchOpenOrders
192561
- * @description Fetch orders that are still open
192562
192701
  * @description fetch all unfilled currently open orders
192563
192702
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list
192564
192703
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-list
@@ -192571,6 +192710,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192571
192710
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
192572
192711
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192573
192712
  * @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)
192713
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
192574
192714
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192575
192715
  */
192576
192716
  await this.loadMarkets();
@@ -192603,15 +192743,21 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192603
192743
  let method = this.safeString(params, 'method', defaultMethod);
192604
192744
  const ordType = this.safeString(params, 'ordType');
192605
192745
  const stop = this.safeValue2(params, 'stop', 'trigger');
192606
- if (stop || (ordType in algoOrderTypes)) {
192746
+ const trailing = this.safeValue(params, 'trailing', false);
192747
+ if (trailing || stop || (ordType in algoOrderTypes)) {
192607
192748
  method = 'privateGetTradeOrdersAlgoPending';
192749
+ }
192750
+ if (trailing) {
192751
+ request['ordType'] = 'move_order_stop';
192752
+ }
192753
+ else if (stop || (ordType in algoOrderTypes)) {
192608
192754
  if (stop) {
192609
192755
  if (ordType === undefined) {
192610
192756
  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
192757
  }
192612
192758
  }
192613
192759
  }
192614
- const query = this.omit(params, ['method', 'stop', 'trigger']);
192760
+ const query = this.omit(params, ['method', 'stop', 'trigger', 'trailing']);
192615
192761
  let response = undefined;
192616
192762
  if (method === 'privateGetTradeOrdersAlgoPending') {
192617
192763
  response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
@@ -192732,6 +192878,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192732
192878
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
192733
192879
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
192734
192880
  * @param {int} [params.until] timestamp in ms to fetch orders for
192881
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
192735
192882
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192736
192883
  */
192737
192884
  await this.loadMarkets();
@@ -192765,7 +192912,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192765
192912
  let method = this.safeString(params, 'method', defaultMethod);
192766
192913
  const ordType = this.safeString(params, 'ordType');
192767
192914
  const stop = this.safeValue2(params, 'stop', 'trigger');
192768
- if (stop || (ordType in algoOrderTypes)) {
192915
+ const trailing = this.safeValue(params, 'trailing', false);
192916
+ if (trailing) {
192917
+ method = 'privateGetTradeOrdersAlgoHistory';
192918
+ request['ordType'] = 'move_order_stop';
192919
+ }
192920
+ else if (stop || (ordType in algoOrderTypes)) {
192769
192921
  method = 'privateGetTradeOrdersAlgoHistory';
192770
192922
  const algoId = this.safeString(params, 'algoId');
192771
192923
  if (algoId !== undefined) {
@@ -192776,7 +192928,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192776
192928
  if (ordType === undefined) {
192777
192929
  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
192930
  }
192779
- request['ordType'] = ordType;
192780
192931
  }
192781
192932
  }
192782
192933
  else {
@@ -192789,7 +192940,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192789
192940
  query = this.omit(query, ['until', 'till']);
192790
192941
  }
192791
192942
  }
192792
- const send = this.omit(query, ['method', 'stop', 'ordType', 'trigger']);
192943
+ const send = this.omit(query, ['method', 'stop', 'trigger', 'trailing']);
192793
192944
  let response = undefined;
192794
192945
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192795
192946
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -192917,6 +193068,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192917
193068
  * @param {int} [params.until] timestamp in ms to fetch orders for
192918
193069
  * @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
193070
  * @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
193071
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
192920
193072
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
192921
193073
  */
192922
193074
  await this.loadMarkets();
@@ -192954,14 +193106,20 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192954
193106
  let method = this.safeString(params, 'method', defaultMethod);
192955
193107
  const ordType = this.safeString(params, 'ordType');
192956
193108
  const stop = this.safeValue2(params, 'stop', 'trigger');
192957
- if (stop || (ordType in algoOrderTypes)) {
193109
+ const trailing = this.safeValue(params, 'trailing', false);
193110
+ if (trailing || stop || (ordType in algoOrderTypes)) {
192958
193111
  method = 'privateGetTradeOrdersAlgoHistory';
193112
+ request['state'] = 'effective';
193113
+ }
193114
+ if (trailing) {
193115
+ request['ordType'] = 'move_order_stop';
193116
+ }
193117
+ else if (stop || (ordType in algoOrderTypes)) {
192959
193118
  if (stop) {
192960
193119
  if (ordType === undefined) {
192961
193120
  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
193121
  }
192963
193122
  }
192964
- request['state'] = 'effective';
192965
193123
  }
192966
193124
  else {
192967
193125
  if (since !== undefined) {
@@ -192974,7 +193132,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
192974
193132
  }
192975
193133
  request['state'] = 'filled';
192976
193134
  }
192977
- const send = this.omit(query, ['method', 'stop', 'trigger']);
193135
+ const send = this.omit(query, ['method', 'stop', 'trigger', 'trailing']);
192978
193136
  let response = undefined;
192979
193137
  if (method === 'privateGetTradeOrdersAlgoHistory') {
192980
193138
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -209649,7 +209807,10 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
209649
209807
  name = this.safeString(params, 'name', name);
209650
209808
  params = this.omit(params, 'name');
209651
209809
  let wsParams = [];
209652
- const messageHash = 'tickers';
209810
+ let messageHash = 'tickers';
209811
+ if (symbols !== undefined) {
209812
+ messageHash = 'tickers::' + symbols.join(',');
209813
+ }
209653
209814
  if (name === 'bookTicker') {
209654
209815
  if (marketIds === undefined) {
209655
209816
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchTickers() requires symbols for bookTicker');
@@ -209842,6 +210003,19 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
209842
210003
  this.tickers[symbol] = result;
209843
210004
  newTickers.push(result);
209844
210005
  }
210006
+ const messageHashes = this.findMessageHashes(client, 'tickers::');
210007
+ for (let i = 0; i < messageHashes.length; i++) {
210008
+ const messageHash = messageHashes[i];
210009
+ const parts = messageHash.split('::');
210010
+ const symbolsString = parts[1];
210011
+ const symbols = symbolsString.split(',');
210012
+ const tickers = this.filterByArray(newTickers, 'symbol', symbols);
210013
+ const tickersSymbols = Object.keys(tickers);
210014
+ const numTickers = tickersSymbols.length;
210015
+ if (numTickers > 0) {
210016
+ client.resolve(tickers, messageHash);
210017
+ }
210018
+ }
209845
210019
  client.resolve(newTickers, 'tickers');
209846
210020
  }
209847
210021
  signParams(params = {}) {
@@ -214656,7 +214830,9 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
214656
214830
  }
214657
214831
  const tickers = await this.watchPublicMultiple(messageHashes, topics, params);
214658
214832
  if (this.newUpdates) {
214659
- return tickers;
214833
+ const result = {};
214834
+ result[tickers['symbol']] = tickers;
214835
+ return result;
214660
214836
  }
214661
214837
  return this.filterByArray(this.tickers, 'symbol', symbols);
214662
214838
  }
@@ -216542,7 +216718,10 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216542
216718
  if (type === 'swap') {
216543
216719
  type = 'futures';
216544
216720
  }
216545
- const messageHash = 'tickers';
216721
+ let messageHash = 'tickers';
216722
+ if (symbols !== undefined) {
216723
+ messageHash += '::' + symbols.join(',');
216724
+ }
216546
216725
  const request = {
216547
216726
  'action': 'subscribe',
216548
216727
  'args': ['futures/ticker'],
@@ -216948,7 +217127,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
216948
217127
  // }
216949
217128
  //
216950
217129
  const marketId = this.safeString(position, 'symbol');
216951
- market = this.safeMarket(marketId, market, '', 'swap');
217130
+ market = this.safeMarket(marketId, market, undefined, 'swap');
216952
217131
  const symbol = market['symbol'];
216953
217132
  const openTimestamp = this.safeInteger(position, 'create_time');
216954
217133
  const timestamp = this.safeInteger(position, 'update_time');
@@ -217141,6 +217320,18 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
217141
217320
  const symbol = this.safeString(ticker, 'symbol');
217142
217321
  this.tickers[symbol] = ticker;
217143
217322
  client.resolve(ticker, 'tickers');
217323
+ const messageHashes = this.findMessageHashes(client, 'tickers::');
217324
+ for (let i = 0; i < messageHashes.length; i++) {
217325
+ const messageHash = messageHashes[i];
217326
+ const parts = messageHash.split('::');
217327
+ const symbolsString = parts[1];
217328
+ const symbols = symbolsString.split(',');
217329
+ if (this.inArray(symbol, symbols)) {
217330
+ const response = {};
217331
+ response[symbol] = ticker;
217332
+ client.resolve(response, messageHash);
217333
+ }
217334
+ }
217144
217335
  }
217145
217336
  return message;
217146
217337
  }
@@ -217290,7 +217481,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
217290
217481
  }
217291
217482
  else {
217292
217483
  const marketId = this.safeString(data, 'symbol');
217293
- const market = this.safeMarket(marketId, undefined, '', 'swap');
217484
+ const market = this.safeMarket(marketId, undefined, undefined, 'swap');
217294
217485
  const symbol = market['symbol'];
217295
217486
  const items = this.safeValue(data, 'items', []);
217296
217487
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -223759,7 +223950,9 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
223759
223950
  }
223760
223951
  const ticker = await this.watchTopics(url, messageHashes, topics, params);
223761
223952
  if (this.newUpdates) {
223762
- return ticker;
223953
+ const result = {};
223954
+ result[ticker['symbol']] = ticker;
223955
+ return result;
223763
223956
  }
223764
223957
  return this.filterByArray(this.tickers, 'symbol', symbols);
223765
223958
  }
@@ -227595,8 +227788,7 @@ class coinbasepro extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
227595
227788
  async watchTickers(symbols = undefined, params = {}) {
227596
227789
  /**
227597
227790
  * @method
227598
- * @name okx#watchTickers
227599
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel
227791
+ * @name coinbasepro#watchTickers
227600
227792
  * @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
227793
  * @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
227602
227794
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -229654,13 +229846,19 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229654
229846
  await this.loadMarkets();
229655
229847
  symbols = this.marketSymbols(symbols);
229656
229848
  const topics = [];
229849
+ const messageHashes = [];
229850
+ if (!limit) {
229851
+ limit = 150;
229852
+ }
229657
229853
  for (let i = 0; i < symbols.length; i++) {
229658
229854
  const symbol = symbols[i];
229659
229855
  const market = this.market(symbol);
229660
- const currentTopic = 'book' + '.' + market['id'];
229856
+ const currentTopic = 'book' + '.' + market['id'] + '.' + limit;
229857
+ const messageHash = 'orderbook:' + market['symbol'];
229858
+ messageHashes.push(messageHash);
229661
229859
  topics.push(currentTopic);
229662
229860
  }
229663
- const orderbook = await this.watchPublicMultiple(topics, topics, params);
229861
+ const orderbook = await this.watchPublicMultiple(messageHashes, topics, params);
229664
229862
  return orderbook.limit();
229665
229863
  }
229666
229864
  handleOrderBookSnapshot(client, message) {
@@ -229685,7 +229883,6 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229685
229883
  // ]
229686
229884
  // }
229687
229885
  //
229688
- const messageHash = this.safeString(message, 'subscription');
229689
229886
  const marketId = this.safeString(message, 'instrument_name');
229690
229887
  const market = this.safeMarket(marketId);
229691
229888
  const symbol = market['symbol'];
@@ -229701,6 +229898,7 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
229701
229898
  }
229702
229899
  orderbook.reset(snapshot);
229703
229900
  this.orderbooks[symbol] = orderbook;
229901
+ const messageHash = 'orderbook:' + symbol;
229704
229902
  client.resolve(orderbook, messageHash);
229705
229903
  }
229706
229904
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -251923,7 +252121,8 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
251923
252121
  const marketId = this.safeString(data, 'symbol');
251924
252122
  const symbol = this.safeSymbol(marketId);
251925
252123
  const market = this.safeMarket(symbol);
251926
- const timeframe = this.findTimeframe(channel);
252124
+ const timeframes = this.safeValue(this.options, 'timeframes', {});
252125
+ const timeframe = this.findTimeframe(channel, timeframes);
251927
252126
  const messageHash = channel + '::' + symbol;
251928
252127
  const parsed = this.parseWsOHLCV(data, market);
251929
252128
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -291918,7 +292117,7 @@ SOFTWARE.
291918
292117
 
291919
292118
  //-----------------------------------------------------------------------------
291920
292119
  // this is updated by vss.js when building
291921
- const version = '4.2.7';
292120
+ const version = '4.2.9';
291922
292121
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
291923
292122
  //-----------------------------------------------------------------------------
291924
292123