ccxt 4.2.2 → 4.2.3

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/js/src/bingx.js CHANGED
@@ -280,6 +280,9 @@ export default class bingx extends Exchange {
280
280
  'post': {
281
281
  'userDataStream': 1,
282
282
  },
283
+ 'put': {
284
+ 'userDataStream': 1,
285
+ },
283
286
  },
284
287
  },
285
288
  },
@@ -1721,6 +1724,10 @@ export default class bingx extends Exchange {
1721
1724
  const isTrailingAmountOrder = trailingAmount !== undefined;
1722
1725
  const isTrailingPercentOrder = trailingPercent !== undefined;
1723
1726
  const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
1727
+ const stopLoss = this.safeValue(params, 'stopLoss');
1728
+ const takeProfit = this.safeValue(params, 'takeProfit');
1729
+ const isStopLoss = stopLoss !== undefined;
1730
+ const isTakeProfit = takeProfit !== undefined;
1724
1731
  if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
1725
1732
  request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
1726
1733
  }
@@ -1766,6 +1773,42 @@ export default class bingx extends Exchange {
1766
1773
  request['priceRate'] = this.parseToNumeric(requestTrailingPercent);
1767
1774
  }
1768
1775
  }
1776
+ if (isStopLoss || isTakeProfit) {
1777
+ if (isStopLoss) {
1778
+ const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
1779
+ const slWorkingType = this.safeString(stopLoss, 'workingType', 'MARK_PRICE');
1780
+ const slType = this.safeString(stopLoss, 'type', 'STOP_MARKET');
1781
+ const slRequest = {
1782
+ 'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, slTriggerPrice)),
1783
+ 'workingType': slWorkingType,
1784
+ 'type': slType,
1785
+ };
1786
+ const slPrice = this.safeString(stopLoss, 'price');
1787
+ if (slPrice !== undefined) {
1788
+ slRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
1789
+ }
1790
+ const slQuantity = this.safeString(stopLoss, 'quantity', amount);
1791
+ slRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, slQuantity));
1792
+ request['stopLoss'] = this.json(slRequest);
1793
+ }
1794
+ if (isTakeProfit) {
1795
+ const tkTriggerPrice = this.safeString2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
1796
+ const tkWorkingType = this.safeString(takeProfit, 'workingType', 'MARK_PRICE');
1797
+ const tpType = this.safeString(takeProfit, 'type', 'TAKE_PROFIT_MARKET');
1798
+ const tpRequest = {
1799
+ 'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, tkTriggerPrice)),
1800
+ 'workingType': tkWorkingType,
1801
+ 'type': tpType,
1802
+ };
1803
+ const slPrice = this.safeString(takeProfit, 'price');
1804
+ if (slPrice !== undefined) {
1805
+ tpRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
1806
+ }
1807
+ const tkQuantity = this.safeString(takeProfit, 'quantity', amount);
1808
+ tpRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, tkQuantity));
1809
+ request['takeProfit'] = this.json(tpRequest);
1810
+ }
1811
+ }
1769
1812
  let positionSide = undefined;
1770
1813
  if (reduceOnly) {
1771
1814
  positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
@@ -1775,7 +1818,7 @@ export default class bingx extends Exchange {
1775
1818
  }
1776
1819
  request['positionSide'] = positionSide;
1777
1820
  request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
1778
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent']);
1821
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss']);
1779
1822
  }
1780
1823
  return this.extend(request, params);
1781
1824
  }
@@ -1785,6 +1828,7 @@ export default class bingx extends Exchange {
1785
1828
  * @name bingx#createOrder
1786
1829
  * @description create a trade order
1787
1830
  * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
1831
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
1788
1832
  * @param {string} symbol unified symbol of the market to create an order in
1789
1833
  * @param {string} type 'market' or 'limit'
1790
1834
  * @param {string} side 'buy' or 'sell'
@@ -1800,6 +1844,10 @@ export default class bingx extends Exchange {
1800
1844
  * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
1801
1845
  * @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
1802
1846
  * @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
1847
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
1848
+ * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
1849
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
1850
+ * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
1803
1851
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1804
1852
  */
1805
1853
  await this.loadMarkets();
@@ -1850,6 +1898,9 @@ export default class bingx extends Exchange {
1850
1898
  // }
1851
1899
  // }
1852
1900
  //
1901
+ if (typeof response === 'string') {
1902
+ response = JSON.parse(response);
1903
+ }
1853
1904
  const data = this.safeValue(response, 'data', {});
1854
1905
  const order = this.safeValue(data, 'order', data);
1855
1906
  return this.parseOrder(order, market);
@@ -2054,6 +2105,24 @@ export default class bingx extends Exchange {
2054
2105
  // "orderType": "",
2055
2106
  // "workingType": "MARK_PRICE"
2056
2107
  // }
2108
+ // with tp and sl
2109
+ // {
2110
+ // orderId: 1741440894764281900,
2111
+ // symbol: 'LTC-USDT',
2112
+ // positionSide: 'LONG',
2113
+ // side: 'BUY',
2114
+ // type: 'MARKET',
2115
+ // price: 0,
2116
+ // quantity: 1,
2117
+ // stopPrice: 0,
2118
+ // workingType: 'MARK_PRICE',
2119
+ // clientOrderID: '',
2120
+ // timeInForce: 'GTC',
2121
+ // priceRate: 0,
2122
+ // stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
2123
+ // takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
2124
+ // reduceOnly: false
2125
+ // }
2057
2126
  //
2058
2127
  const positionSide = this.safeString2(order, 'positionSide', 'ps');
2059
2128
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
@@ -2092,6 +2161,30 @@ export default class bingx extends Exchange {
2092
2161
  'cost': Precise.stringAbs(feeCost),
2093
2162
  };
2094
2163
  const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
2164
+ let stopLoss = this.safeValue(order, 'stopLoss');
2165
+ let stopLossPrice = undefined;
2166
+ if (stopLoss !== undefined) {
2167
+ stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
2168
+ }
2169
+ if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
2170
+ // stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
2171
+ if (typeof stopLoss === 'string') {
2172
+ stopLoss = JSON.parse(stopLoss);
2173
+ }
2174
+ stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
2175
+ }
2176
+ let takeProfit = this.safeValue(order, 'takeProfit');
2177
+ let takeProfitPrice = undefined;
2178
+ if (takeProfit !== undefined) {
2179
+ takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
2180
+ }
2181
+ if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
2182
+ // takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
2183
+ if (typeof takeProfit === 'string') {
2184
+ takeProfit = JSON.parse(takeProfit);
2185
+ }
2186
+ takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
2187
+ }
2095
2188
  return this.safeOrder({
2096
2189
  'info': order,
2097
2190
  'id': orderId,
@@ -2108,8 +2201,8 @@ export default class bingx extends Exchange {
2108
2201
  'price': price,
2109
2202
  'stopPrice': this.safeNumber(order, 'stopPrice'),
2110
2203
  'triggerPrice': this.safeNumber(order, 'stopPrice'),
2111
- 'stopLossPrice': this.safeNumber(order, 'stopLoss'),
2112
- 'takeProfitPrice': this.safeNumber(order, 'takeProfit'),
2204
+ 'stopLossPrice': stopLossPrice,
2205
+ 'takeProfitPrice': takeProfitPrice,
2113
2206
  'average': average,
2114
2207
  'cost': undefined,
2115
2208
  'amount': amount,
@@ -2303,6 +2396,7 @@ export default class bingx extends Exchange {
2303
2396
  * @param {string[]} ids order ids
2304
2397
  * @param {string} symbol unified market symbol, default is undefined
2305
2398
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2399
+ * @param {string[]} [params.clientOrderIds] client order ids
2306
2400
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2307
2401
  */
2308
2402
  if (symbol === undefined) {
@@ -2313,19 +2407,27 @@ export default class bingx extends Exchange {
2313
2407
  const request = {
2314
2408
  'symbol': market['id'],
2315
2409
  };
2410
+ const clientOrderIds = this.safeValue(params, 'clientOrderIds');
2411
+ let idsToParse = ids;
2412
+ const areClientOrderIds = (clientOrderIds !== undefined);
2413
+ if (areClientOrderIds) {
2414
+ idsToParse = clientOrderIds;
2415
+ }
2316
2416
  const parsedIds = [];
2317
- for (let i = 0; i < ids.length; i++) {
2318
- const id = ids[i];
2417
+ for (let i = 0; i < idsToParse.length; i++) {
2418
+ const id = idsToParse[i];
2319
2419
  const stringId = id.toString();
2320
2420
  parsedIds.push(stringId);
2321
2421
  }
2322
2422
  let response = undefined;
2323
2423
  if (market['spot']) {
2324
- request['orderIds'] = parsedIds.join(',');
2424
+ const spotReqKey = areClientOrderIds ? 'clientOrderIds' : 'orderIds';
2425
+ request[spotReqKey] = parsedIds.join(',');
2325
2426
  response = await this.spotV1PrivatePostTradeCancelOrders(this.extend(request, params));
2326
2427
  }
2327
2428
  else {
2328
- request['orderIdList'] = parsedIds;
2429
+ const swapReqKey = areClientOrderIds ? 'ClientOrderIDList' : 'orderIdList';
2430
+ request[swapReqKey] = parsedIds;
2329
2431
  response = await this.swapV2PrivateDeleteTradeBatchOrders(this.extend(request, params));
2330
2432
  }
2331
2433
  //
package/js/src/bitget.js CHANGED
@@ -4745,8 +4745,8 @@ export default class bitget extends Exchange {
4745
4745
  }
4746
4746
  let marginMode = undefined;
4747
4747
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
4748
- const stop = this.safeValue(params, 'stop');
4749
- params = this.omit(params, 'stop');
4748
+ const stop = this.safeValue2(params, 'stop', 'trigger');
4749
+ params = this.omit(params, ['stop', 'trigger']);
4750
4750
  const orderIdList = [];
4751
4751
  for (let i = 0; i < ids.length; i++) {
4752
4752
  const individualId = ids[i];
@@ -4842,8 +4842,8 @@ export default class bitget extends Exchange {
4842
4842
  const request = {
4843
4843
  'symbol': market['id'],
4844
4844
  };
4845
- const stop = this.safeValue(params, 'stop');
4846
- params = this.omit(params, 'stop');
4845
+ const stop = this.safeValue2(params, 'stop', 'trigger');
4846
+ params = this.omit(params, ['stop', 'trigger']);
4847
4847
  let response = undefined;
4848
4848
  if (market['spot']) {
4849
4849
  if (marginMode !== undefined) {
package/js/src/bitmart.js CHANGED
@@ -2510,8 +2510,8 @@ export default class bitmart extends Exchange {
2510
2510
  response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
2511
2511
  }
2512
2512
  else {
2513
- const stop = this.safeValue(params, 'stop');
2514
- params = this.omit(params, ['stop']);
2513
+ const stop = this.safeValue2(params, 'stop', 'trigger');
2514
+ params = this.omit(params, ['stop', 'trigger']);
2515
2515
  if (!stop) {
2516
2516
  response = await this.privatePostContractPrivateCancelOrder(this.extend(request, params));
2517
2517
  }
@@ -1281,7 +1281,7 @@ export default class kucoinfutures extends kucoin {
1281
1281
  * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-stop-orders
1282
1282
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1283
1283
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1284
- * @param {object} [params.stop] When true, all the trigger orders will be cancelled
1284
+ * @param {object} [params.trigger] When true, all the trigger orders will be cancelled
1285
1285
  * @returns Response from the exchange
1286
1286
  */
1287
1287
  await this.loadMarkets();
@@ -1289,8 +1289,8 @@ export default class kucoinfutures extends kucoin {
1289
1289
  if (symbol !== undefined) {
1290
1290
  request['symbol'] = this.marketId(symbol);
1291
1291
  }
1292
- const stop = this.safeValue(params, 'stop');
1293
- params = this.omit(params, 'stop');
1292
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1293
+ params = this.omit(params, ['stop', 'trigger']);
1294
1294
  let response = undefined;
1295
1295
  if (stop) {
1296
1296
  response = await this.futuresPrivateDeleteStopOrders(this.extend(request, params));
@@ -1459,7 +1459,7 @@ export default class kucoinfutures extends kucoin {
1459
1459
  * @param {int} [since] timestamp in ms of the earliest order to retrieve
1460
1460
  * @param {int} [limit] The maximum number of orders to retrieve
1461
1461
  * @param {object} [params] exchange specific parameters
1462
- * @param {bool} [params.stop] set to true to retrieve untriggered stop orders
1462
+ * @param {bool} [params.trigger] set to true to retrieve untriggered stop orders
1463
1463
  * @param {int} [params.until] End time in ms
1464
1464
  * @param {string} [params.side] buy or sell
1465
1465
  * @param {string} [params.type] limit or market
@@ -1472,9 +1472,9 @@ export default class kucoinfutures extends kucoin {
1472
1472
  if (paginate) {
1473
1473
  return await this.fetchPaginatedCallDynamic('fetchOrdersByStatus', symbol, since, limit, params);
1474
1474
  }
1475
- const stop = this.safeValue(params, 'stop');
1475
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1476
1476
  const until = this.safeInteger2(params, 'until', 'till');
1477
- params = this.omit(params, ['stop', 'until', 'till']);
1477
+ params = this.omit(params, ['stop', 'until', 'till', 'trigger']);
1478
1478
  if (status === 'closed') {
1479
1479
  status = 'done';
1480
1480
  }
package/js/src/okcoin.js CHANGED
@@ -1974,7 +1974,7 @@ export default class okcoin extends Exchange {
1974
1974
  // 'ordId': id,
1975
1975
  };
1976
1976
  const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1977
- const stop = this.safeValue(params, 'stop');
1977
+ const stop = this.safeValue2(params, 'stop', 'trigger');
1978
1978
  if (stop) {
1979
1979
  if (clientOrderId !== undefined) {
1980
1980
  request['algoClOrdId'] = clientOrderId;
@@ -1991,7 +1991,7 @@ export default class okcoin extends Exchange {
1991
1991
  request['ordId'] = id;
1992
1992
  }
1993
1993
  }
1994
- const query = this.omit(params, ['clientOrderId', 'stop']);
1994
+ const query = this.omit(params, ['clientOrderId', 'stop', 'trigger']);
1995
1995
  let response = undefined;
1996
1996
  if (stop) {
1997
1997
  response = await this.privateGetTradeOrderAlgo(this.extend(request, query));
package/js/src/okx.js CHANGED
@@ -3032,12 +3032,13 @@ export default class okx extends Exchange {
3032
3032
  * @param {string} id order id
3033
3033
  * @param {string} symbol unified symbol of the market the order was made in
3034
3034
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3035
+ * @param {boolean} [params.trigger] true if trigger orders
3035
3036
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3036
3037
  */
3037
3038
  if (symbol === undefined) {
3038
3039
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
3039
3040
  }
3040
- const stop = this.safeValue(params, 'stop');
3041
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3041
3042
  if (stop) {
3042
3043
  const orderInner = await this.cancelOrders([id], symbol, params);
3043
3044
  return this.safeValue(orderInner, 0);
@@ -3409,6 +3410,7 @@ export default class okx extends Exchange {
3409
3410
  * @param {string} id the order id
3410
3411
  * @param {string} symbol unified market symbol
3411
3412
  * @param {object} [params] extra and exchange specific parameters
3413
+ * @param {boolean} [params.trigger] true if fetching trigger orders
3412
3414
  * @returns [an order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3413
3415
  */
3414
3416
  if (symbol === undefined) {
@@ -3426,7 +3428,7 @@ export default class okx extends Exchange {
3426
3428
  const options = this.safeValue(this.options, 'fetchOrder', {});
3427
3429
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrder');
3428
3430
  let method = this.safeString(params, 'method', defaultMethod);
3429
- const stop = this.safeValue(params, 'stop');
3431
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3430
3432
  if (stop) {
3431
3433
  method = 'privateGetTradeOrderAlgo';
3432
3434
  if (clientOrderId !== undefined) {
@@ -3444,7 +3446,7 @@ export default class okx extends Exchange {
3444
3446
  request['ordId'] = id;
3445
3447
  }
3446
3448
  }
3447
- const query = this.omit(params, ['method', 'clOrdId', 'clientOrderId', 'stop']);
3449
+ const query = this.omit(params, ['method', 'clOrdId', 'clientOrderId', 'stop', 'trigger']);
3448
3450
  let response = undefined;
3449
3451
  if (method === 'privateGetTradeOrderAlgo') {
3450
3452
  response = await this.privateGetTradeOrderAlgo(this.extend(request, query));
@@ -3600,7 +3602,7 @@ export default class okx extends Exchange {
3600
3602
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersPending');
3601
3603
  let method = this.safeString(params, 'method', defaultMethod);
3602
3604
  const ordType = this.safeString(params, 'ordType');
3603
- const stop = this.safeValue(params, 'stop');
3605
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3604
3606
  if (stop || (ordType in algoOrderTypes)) {
3605
3607
  method = 'privateGetTradeOrdersAlgoPending';
3606
3608
  if (stop) {
@@ -3609,7 +3611,7 @@ export default class okx extends Exchange {
3609
3611
  }
3610
3612
  }
3611
3613
  }
3612
- const query = this.omit(params, ['method', 'stop']);
3614
+ const query = this.omit(params, ['method', 'stop', 'trigger']);
3613
3615
  let response = undefined;
3614
3616
  if (method === 'privateGetTradeOrdersAlgoPending') {
3615
3617
  response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
@@ -3762,7 +3764,7 @@ export default class okx extends Exchange {
3762
3764
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
3763
3765
  let method = this.safeString(params, 'method', defaultMethod);
3764
3766
  const ordType = this.safeString(params, 'ordType');
3765
- const stop = this.safeValue(params, 'stop');
3767
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3766
3768
  if (stop || (ordType in algoOrderTypes)) {
3767
3769
  method = 'privateGetTradeOrdersAlgoHistory';
3768
3770
  const algoId = this.safeString(params, 'algoId');
@@ -3787,7 +3789,7 @@ export default class okx extends Exchange {
3787
3789
  query = this.omit(query, ['until', 'till']);
3788
3790
  }
3789
3791
  }
3790
- const send = this.omit(query, ['method', 'stop', 'ordType']);
3792
+ const send = this.omit(query, ['method', 'stop', 'ordType', 'trigger']);
3791
3793
  let response = undefined;
3792
3794
  if (method === 'privateGetTradeOrdersAlgoHistory') {
3793
3795
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -3949,7 +3951,7 @@ export default class okx extends Exchange {
3949
3951
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
3950
3952
  let method = this.safeString(params, 'method', defaultMethod);
3951
3953
  const ordType = this.safeString(params, 'ordType');
3952
- const stop = this.safeValue(params, 'stop');
3954
+ const stop = this.safeValue2(params, 'stop', 'trigger');
3953
3955
  if (stop || (ordType in algoOrderTypes)) {
3954
3956
  method = 'privateGetTradeOrdersAlgoHistory';
3955
3957
  if (stop) {
@@ -3970,7 +3972,7 @@ export default class okx extends Exchange {
3970
3972
  }
3971
3973
  request['state'] = 'filled';
3972
3974
  }
3973
- const send = this.omit(query, ['method', 'stop']);
3975
+ const send = this.omit(query, ['method', 'stop', 'trigger']);
3974
3976
  let response = undefined;
3975
3977
  if (method === 'privateGetTradeOrdersAlgoHistory') {
3976
3978
  response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
@@ -33,6 +33,7 @@ export default class bingx extends bingxRest {
33
33
  },
34
34
  },
35
35
  'options': {
36
+ 'listenKeyRefreshRate': 3540000,
36
37
  'ws': {
37
38
  'gunzip': true,
38
39
  },
@@ -630,7 +631,7 @@ export default class bingx extends bingxRest {
630
631
  const lastAuthenticatedTime = this.safeInteger(this.options, 'lastAuthenticatedTime', 0);
631
632
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000); // 1 hour
632
633
  if (time - lastAuthenticatedTime > listenKeyRefreshRate) {
633
- const response = await this.userAuthPrivatePostUserDataStream({ 'listenKey': listenKey }); // extend the expiry
634
+ const response = await this.userAuthPrivatePutUserDataStream({ 'listenKey': listenKey }); // extend the expiry
634
635
  this.options['listenKey'] = this.safeString(response, 'listenKey');
635
636
  this.options['lastAuthenticatedTime'] = time;
636
637
  }
@@ -211,7 +211,7 @@ export default class bybit extends bybitRest {
211
211
  */
212
212
  await this.loadMarkets();
213
213
  symbols = this.marketSymbols(symbols, undefined, false);
214
- const messageHash = 'tickers::' + symbols.join(',');
214
+ const messageHashes = [];
215
215
  const url = this.getUrlByMarketType(symbols[0], false, params);
216
216
  params = this.cleanParams(params);
217
217
  const options = this.safeValue(this.options, 'watchTickers', {});
@@ -221,8 +221,9 @@ export default class bybit extends bybitRest {
221
221
  for (let i = 0; i < marketIds.length; i++) {
222
222
  const marketId = marketIds[i];
223
223
  topics.push(topic + '.' + marketId);
224
+ messageHashes.push('ticker:' + symbols[i]);
224
225
  }
225
- const ticker = await this.watchTopics(url, messageHash, topics, params);
226
+ const ticker = await this.watchTopics(url, messageHashes, topics, params);
226
227
  if (this.newUpdates) {
227
228
  return ticker;
228
229
  }
@@ -358,17 +359,6 @@ export default class bybit extends bybitRest {
358
359
  this.tickers[symbol] = parsed;
359
360
  const messageHash = 'ticker:' + symbol;
360
361
  client.resolve(this.tickers[symbol], messageHash);
361
- // watchTickers part
362
- const messageHashes = this.findMessageHashes(client, 'tickers::');
363
- for (let i = 0; i < messageHashes.length; i++) {
364
- const messageHashTicker = messageHashes[i];
365
- const parts = messageHashTicker.split('::');
366
- const symbolsString = parts[1];
367
- const symbols = symbolsString.split(',');
368
- if (this.inArray(parsed['symbol'], symbols)) {
369
- client.resolve(parsed, messageHashTicker);
370
- }
371
- }
372
362
  }
373
363
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
374
364
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.2",
3
+ "version": "4.2.3",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",