ccxt 4.5.2 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +78 -5
  5. package/dist/cjs/src/base/functions/encode.js +8 -0
  6. package/dist/cjs/src/base/functions/rsa.js +14 -1
  7. package/dist/cjs/src/base/functions.js +1 -0
  8. package/dist/cjs/src/binance.js +12 -15
  9. package/dist/cjs/src/bitget.js +1 -1
  10. package/dist/cjs/src/bitvavo.js +8 -0
  11. package/dist/cjs/src/bybit.js +20 -6
  12. package/dist/cjs/src/coinbase.js +28 -10
  13. package/dist/cjs/src/coincatch.js +34 -21
  14. package/dist/cjs/src/delta.js +1 -0
  15. package/dist/cjs/src/gate.js +27 -12
  16. package/dist/cjs/src/gemini.js +3 -3
  17. package/dist/cjs/src/htx.js +4 -4
  18. package/dist/cjs/src/kucoinfutures.js +11 -10
  19. package/dist/cjs/src/mexc.js +30 -1
  20. package/dist/cjs/src/okx.js +19 -4
  21. package/dist/cjs/src/pro/binance.js +3 -3
  22. package/dist/cjs/src/pro/bitfinex.js +140 -0
  23. package/dist/cjs/src/pro/bitget.js +168 -26
  24. package/dist/cjs/src/pro/bybit.js +67 -11
  25. package/dist/cjs/src/pro/coinex.js +10 -11
  26. package/dist/cjs/src/pro/kucoin.js +64 -0
  27. package/dist/cjs/src/pro/mexc.js +7 -3
  28. package/js/ccxt.d.ts +1 -1
  29. package/js/ccxt.js +1 -1
  30. package/js/src/abstract/myokx.d.ts +1 -0
  31. package/js/src/abstract/okx.d.ts +1 -0
  32. package/js/src/abstract/okxus.d.ts +1 -0
  33. package/js/src/base/Exchange.d.ts +6 -0
  34. package/js/src/base/Exchange.js +78 -5
  35. package/js/src/base/functions/encode.d.ts +2 -1
  36. package/js/src/base/functions/encode.js +8 -1
  37. package/js/src/base/functions/rsa.js +16 -3
  38. package/js/src/binance.js +12 -15
  39. package/js/src/bitget.js +1 -1
  40. package/js/src/bitvavo.js +8 -0
  41. package/js/src/bybit.js +20 -6
  42. package/js/src/coinbase.d.ts +1 -1
  43. package/js/src/coinbase.js +28 -10
  44. package/js/src/coincatch.d.ts +2 -0
  45. package/js/src/coincatch.js +34 -21
  46. package/js/src/delta.js +1 -0
  47. package/js/src/gate.js +27 -12
  48. package/js/src/gemini.js +3 -3
  49. package/js/src/htx.js +4 -4
  50. package/js/src/kucoinfutures.js +11 -10
  51. package/js/src/mexc.d.ts +3 -0
  52. package/js/src/mexc.js +30 -1
  53. package/js/src/okx.d.ts +4 -2
  54. package/js/src/okx.js +19 -4
  55. package/js/src/pro/binance.js +3 -3
  56. package/js/src/pro/bitfinex.d.ts +30 -0
  57. package/js/src/pro/bitfinex.js +140 -0
  58. package/js/src/pro/bitget.d.ts +9 -1
  59. package/js/src/pro/bitget.js +168 -26
  60. package/js/src/pro/bybit.d.ts +6 -2
  61. package/js/src/pro/bybit.js +67 -11
  62. package/js/src/pro/coinex.js +11 -12
  63. package/js/src/pro/kucoin.d.ts +22 -0
  64. package/js/src/pro/kucoin.js +64 -0
  65. package/js/src/pro/mexc.js +7 -3
  66. package/package.json +3 -3
@@ -922,10 +922,12 @@ class bitget extends bitget$1["default"] {
922
922
  * @description get the list of most recent trades for a particular symbol
923
923
  * @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
924
924
  * @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
925
+ * @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
925
926
  * @param {string} symbol unified symbol of the market to fetch trades for
926
927
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
927
928
  * @param {int} [limit] the maximum amount of trades to fetch
928
929
  * @param {object} [params] extra parameters specific to the exchange API endpoint
930
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
929
931
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
930
932
  */
931
933
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -937,10 +939,12 @@ class bitget extends bitget$1["default"] {
937
939
  * @description get the list of most recent trades for a particular symbol
938
940
  * @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
939
941
  * @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
942
+ * @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
940
943
  * @param {string[]} symbols unified symbol of the market to fetch trades for
941
944
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
942
945
  * @param {int} [limit] the maximum amount of trades to fetch
943
946
  * @param {object} [params] extra parameters specific to the exchange API endpoint
947
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
944
948
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
945
949
  */
946
950
  async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
@@ -950,21 +954,28 @@ class bitget extends bitget$1["default"] {
950
954
  }
951
955
  await this.loadMarkets();
952
956
  symbols = this.marketSymbols(symbols);
957
+ let uta = undefined;
958
+ [uta, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'uta', false);
953
959
  const topics = [];
954
960
  const messageHashes = [];
955
961
  for (let i = 0; i < symbols.length; i++) {
956
962
  const symbol = symbols[i];
957
963
  const market = this.market(symbol);
958
964
  let instType = undefined;
959
- [instType, params] = this.getInstType(market, false, params);
965
+ [instType, params] = this.getInstType(market, uta, params);
960
966
  const args = {
961
967
  'instType': instType,
962
- 'channel': 'trade',
963
- 'instId': market['id'],
964
968
  };
969
+ const topicOrChannel = uta ? 'topic' : 'channel';
970
+ const symbolOrInstId = uta ? 'symbol' : 'instId';
971
+ args[topicOrChannel] = uta ? 'publicTrade' : 'trade';
972
+ args[symbolOrInstId] = market['id'];
965
973
  topics.push(args);
966
974
  messageHashes.push('trade:' + symbol);
967
975
  }
976
+ if (uta) {
977
+ params['uta'] = true;
978
+ }
968
979
  const trades = await this.watchPublicMultiple(messageHashes, topics, params);
969
980
  if (this.newUpdates) {
970
981
  const first = this.safeValue(trades, 0);
@@ -985,13 +996,17 @@ class bitget extends bitget$1["default"] {
985
996
  * @description unsubscribe from the trades channel
986
997
  * @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
987
998
  * @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
999
+ * @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
988
1000
  * @param {string} symbol unified symbol of the market to unwatch the trades for
989
1001
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1002
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
990
1003
  * @returns {any} status of the unwatch request
991
1004
  */
992
1005
  async unWatchTrades(symbol, params = {}) {
993
- await this.loadMarkets();
994
- return await this.unWatchChannel(symbol, 'trade', 'trade', params);
1006
+ let uta = undefined;
1007
+ [uta, params] = this.handleOptionAndParams(params, 'unWatchTrades', 'uta', false);
1008
+ const channelTopic = uta ? 'publicTrade' : 'trade';
1009
+ return await this.unWatchChannel(symbol, channelTopic, 'trade', params);
995
1010
  }
996
1011
  handleTrades(client, message) {
997
1012
  //
@@ -1010,10 +1025,28 @@ class bitget extends bitget$1["default"] {
1010
1025
  // "ts": 1701910980730
1011
1026
  // }
1012
1027
  //
1028
+ // uta
1029
+ //
1030
+ // {
1031
+ // "action": "snapshot",
1032
+ // "arg": { "instType": "spot", "topic": "publicTrade", "symbol": "BTCUSDT" },
1033
+ // "data": [
1034
+ // {
1035
+ // "T": "1756287827920",
1036
+ // "P": "110878.5",
1037
+ // "v": "0.07",
1038
+ // "S": "buy",
1039
+ // "L": "1344534089797185550"
1040
+ // "i": "1344534089797185549"
1041
+ // },
1042
+ // ],
1043
+ // "ts": 1701910980730
1044
+ // }
1045
+ //
1013
1046
  const arg = this.safeValue(message, 'arg', {});
1014
- const instType = this.safeString(arg, 'instType');
1015
- const marketType = (instType === 'SPOT') ? 'spot' : 'contract';
1016
- const marketId = this.safeString(arg, 'instId');
1047
+ const instType = this.safeStringLower(arg, 'instType');
1048
+ const marketType = (instType === 'spot') ? 'spot' : 'contract';
1049
+ const marketId = this.safeString2(arg, 'instId', 'symbol');
1017
1050
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
1018
1051
  const symbol = market['symbol'];
1019
1052
  let stored = this.safeValue(this.trades, symbol);
@@ -1092,13 +1125,57 @@ class bitget extends bitget$1["default"] {
1092
1125
  // "uTime": "1714471204194"
1093
1126
  // }
1094
1127
  //
1128
+ // uta private
1129
+ //
1130
+ // {
1131
+ // "symbol": "BTCUSDT",
1132
+ // "orderType": "market",
1133
+ // "updatedTime": "1736378720623",
1134
+ // "side": "buy",
1135
+ // "orderId": "1288888888888888888",
1136
+ // "execPnl": "0",
1137
+ // "feeDetail": [
1138
+ // {
1139
+ // "feeCoin": "USDT",
1140
+ // "fee": "0.569958"
1141
+ // }
1142
+ // ],
1143
+ // "execTime": "1736378720623",
1144
+ // "tradeScope": "taker",
1145
+ // "tradeSide": "open",
1146
+ // "execId": "1288888888888888888",
1147
+ // "execLinkId": "1288888888888888888",
1148
+ // "execPrice": "94993",
1149
+ // "holdSide": "long",
1150
+ // "execValue": "949.93",
1151
+ // "category": "USDT-FUTURES",
1152
+ // "execQty": "0.01",
1153
+ // "clientOid": "1288888888888888889"
1154
+ // uta
1155
+ //
1156
+ // {
1157
+ // "i": "1344534089797185549", // Fill execution ID
1158
+ // "L": "1344534089797185550", // Execution correlation ID
1159
+ // "p": "110878.5", // Fill price
1160
+ // "v": "0.07", // Fill size
1161
+ // "S": "buy", // Fill side
1162
+ // "T": "1756287827920" // Fill timestamp
1163
+ // }
1164
+ //
1095
1165
  const instId = this.safeString2(trade, 'symbol', 'instId');
1096
1166
  const posMode = this.safeString(trade, 'posMode');
1097
- const defaultType = (posMode !== undefined) ? 'contract' : 'spot';
1167
+ const category = this.safeString(trade, 'category');
1168
+ let defaultType = undefined;
1169
+ if (category !== undefined) {
1170
+ defaultType = (category !== 'SPOT') ? 'contract' : 'spot';
1171
+ }
1172
+ else {
1173
+ defaultType = (posMode !== undefined) ? 'contract' : 'spot';
1174
+ }
1098
1175
  if (market === undefined) {
1099
1176
  market = this.safeMarket(instId, undefined, undefined, defaultType);
1100
1177
  }
1101
- const timestamp = this.safeIntegerN(trade, ['uTime', 'cTime', 'ts']);
1178
+ const timestamp = this.safeIntegerN(trade, ['uTime', 'cTime', 'ts', 'T', 'execTime']);
1102
1179
  const feeDetail = this.safeList(trade, 'feeDetail', []);
1103
1180
  const first = this.safeDict(feeDetail, 0);
1104
1181
  let fee = undefined;
@@ -1106,23 +1183,23 @@ class bitget extends bitget$1["default"] {
1106
1183
  const feeCurrencyId = this.safeString(first, 'feeCoin');
1107
1184
  const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1108
1185
  fee = {
1109
- 'cost': Precise["default"].stringAbs(this.safeString(first, 'totalFee')),
1186
+ 'cost': Precise["default"].stringAbs(this.safeString2(first, 'totalFee', 'fee')),
1110
1187
  'currency': feeCurrencyCode,
1111
1188
  };
1112
1189
  }
1113
1190
  return this.safeTrade({
1114
1191
  'info': trade,
1115
- 'id': this.safeString(trade, 'tradeId'),
1116
- 'order': this.safeString(trade, 'orderId'),
1192
+ 'id': this.safeStringN(trade, ['tradeId', 'i', 'execId']),
1193
+ 'order': this.safeString2(trade, 'orderId', 'L'),
1117
1194
  'timestamp': timestamp,
1118
1195
  'datetime': this.iso8601(timestamp),
1119
1196
  'symbol': market['symbol'],
1120
1197
  'type': this.safeString(trade, 'orderType'),
1121
- 'side': this.safeString(trade, 'side'),
1198
+ 'side': this.safeString2(trade, 'side', 'S'),
1122
1199
  'takerOrMaker': this.safeString(trade, 'tradeScope'),
1123
- 'price': this.safeString2(trade, 'priceAvg', 'price'),
1124
- 'amount': this.safeString2(trade, 'size', 'baseVolume'),
1125
- 'cost': this.safeString2(trade, 'amount', 'quoteVolume'),
1200
+ 'price': this.safeStringN(trade, ['priceAvg', 'price', 'execPrice', 'P']),
1201
+ 'amount': this.safeStringN(trade, ['size', 'baseVolume', 'execQty', 'v']),
1202
+ 'cost': this.safeStringN(trade, ['amount', 'quoteVolume', 'execValue']),
1126
1203
  'fee': fee,
1127
1204
  }, market);
1128
1205
  }
@@ -1718,11 +1795,13 @@ class bitget extends bitget$1["default"] {
1718
1795
  * @method
1719
1796
  * @name bitget#watchMyTrades
1720
1797
  * @description watches trades made by the user
1721
- * @see https://www.bitget.com/api-doc/contract/websocket/private/Order-Channel
1798
+ * @see https://www.bitget.com/api-doc/contract/websocket/private/Fill-Channel
1799
+ * @see https://www.bitget.com/api-doc/uta/websocket/private/Fill-Channel
1722
1800
  * @param {str} symbol unified market symbol
1723
1801
  * @param {int} [since] the earliest time in ms to fetch trades for
1724
1802
  * @param {int} [limit] the maximum number of trades structures to retrieve
1725
1803
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1804
+ * @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
1726
1805
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1727
1806
  */
1728
1807
  async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -1737,18 +1816,29 @@ class bitget extends bitget$1["default"] {
1737
1816
  let type = undefined;
1738
1817
  [type, params] = this.handleMarketTypeAndParams('watchMyTrades', market, params);
1739
1818
  let instType = undefined;
1819
+ let uta = undefined;
1820
+ [uta, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'uta', false);
1740
1821
  if (market === undefined && type === 'spot') {
1741
- instType = 'spot';
1822
+ instType = 'SPOT';
1742
1823
  }
1743
1824
  else {
1744
- [instType, params] = this.getInstType(market, false, params);
1825
+ [instType, params] = this.getInstType(market, uta, params);
1826
+ }
1827
+ if (uta) {
1828
+ instType = 'UTA';
1745
1829
  }
1746
1830
  const subscriptionHash = 'fill:' + instType;
1747
1831
  const args = {
1748
1832
  'instType': instType,
1749
- 'channel': 'fill',
1750
- 'instId': 'default',
1751
1833
  };
1834
+ const topicOrChannel = uta ? 'topic' : 'channel';
1835
+ args[topicOrChannel] = 'fill';
1836
+ if (!uta) {
1837
+ args['instId'] = 'default';
1838
+ }
1839
+ else {
1840
+ params['uta'] = true;
1841
+ }
1752
1842
  const trades = await this.watchPrivate(messageHash, subscriptionHash, args, params);
1753
1843
  if (this.newUpdates) {
1754
1844
  limit = trades.getLimit(symbol, limit);
@@ -1827,6 +1917,44 @@ class bitget extends bitget$1["default"] {
1827
1917
  // "ts": 1714471276629
1828
1918
  // }
1829
1919
  //
1920
+ // uta
1921
+ //
1922
+ // {
1923
+ // "data": [
1924
+ // {
1925
+ // "symbol": "BTCUSDT",
1926
+ // "orderType": "market",
1927
+ // "updatedTime": "1736378720623",
1928
+ // "side": "buy",
1929
+ // "orderId": "1288888888888888888",
1930
+ // "execPnl": "0",
1931
+ // "feeDetail": [
1932
+ // {
1933
+ // "feeCoin": "USDT",
1934
+ // "fee": "0.569958"
1935
+ // }
1936
+ // ],
1937
+ // "execTime": "1736378720623",
1938
+ // "tradeScope": "taker",
1939
+ // "tradeSide": "open",
1940
+ // "execId": "1288888888888888888",
1941
+ // "execLinkId": "1288888888888888888",
1942
+ // "execPrice": "94993",
1943
+ // "holdSide": "long",
1944
+ // "execValue": "949.93",
1945
+ // "category": "USDT-FUTURES",
1946
+ // "execQty": "0.01",
1947
+ // "clientOid": "1288888888888888889"
1948
+ // }
1949
+ // ],
1950
+ // "arg": {
1951
+ // "instType": "UTA",
1952
+ // "topic": "fill"
1953
+ // },
1954
+ // "action": "snapshot",
1955
+ // "ts": 1733904123981
1956
+ // }
1957
+ //
1830
1958
  if (this.myTrades === undefined) {
1831
1959
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
1832
1960
  this.myTrades = new Cache.ArrayCache(limit);
@@ -2089,12 +2217,25 @@ class bitget extends bitget$1["default"] {
2089
2217
  return await future;
2090
2218
  }
2091
2219
  async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
2092
- let url = this.urls['api']['ws']['private'];
2220
+ let uta = undefined;
2221
+ let url = undefined;
2222
+ [uta, params] = this.handleOptionAndParams(params, 'watchPrivate', 'uta', false);
2223
+ if (uta) {
2224
+ url = this.urls['api']['ws']['utaPrivate'];
2225
+ }
2226
+ else {
2227
+ url = this.urls['api']['ws']['private'];
2228
+ }
2093
2229
  const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
2094
2230
  if (sandboxMode) {
2095
2231
  const instType = this.safeString(args, 'instType');
2096
2232
  if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
2097
- url = this.urls['api']['demo']['private'];
2233
+ if (uta) {
2234
+ url = this.urls['api']['demo']['utaPrivate'];
2235
+ }
2236
+ else {
2237
+ url = this.urls['api']['demo']['private'];
2238
+ }
2098
2239
  }
2099
2240
  }
2100
2241
  await this.authenticate({ 'url': url });
@@ -2253,6 +2394,7 @@ class bitget extends bitget$1["default"] {
2253
2394
  const methods = {
2254
2395
  'ticker': this.handleTicker,
2255
2396
  'trade': this.handleTrades,
2397
+ 'publicTrade': this.handleTrades,
2256
2398
  'fill': this.handleMyTrades,
2257
2399
  'orders': this.handleOrder,
2258
2400
  'ordersAlgo': this.handleOrder,
@@ -2326,7 +2468,7 @@ class bitget extends bitget$1["default"] {
2326
2468
  const arg = this.safeDict(message, 'arg', {});
2327
2469
  const instType = this.safeStringLower(arg, 'instType');
2328
2470
  const type = (instType === 'spot') ? 'spot' : 'contract';
2329
- const instId = this.safeString(arg, 'instId');
2471
+ const instId = this.safeString2(arg, 'instId', 'symbol');
2330
2472
  const market = this.safeMarket(instId, undefined, undefined, type);
2331
2473
  const symbol = market['symbol'];
2332
2474
  const messageHash = 'unsubscribe:trade:' + market['symbol'];
@@ -2443,7 +2585,7 @@ class bitget extends bitget$1["default"] {
2443
2585
  // for now only unWatchOrderBook is supporteod
2444
2586
  this.handleOrderBookUnSubscription(client, message);
2445
2587
  }
2446
- else if (channel === 'trade') {
2588
+ else if ((channel === 'trade') || (channel === 'publicTrade')) {
2447
2589
  this.handleTradesUnSubscription(client, message);
2448
2590
  }
2449
2591
  else if (channel === 'ticker') {
@@ -445,13 +445,13 @@ class bybit extends bybit$1["default"] {
445
445
  * @description unWatches a price ticker
446
446
  * @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
447
447
  * @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
448
- * @param {string[]} symbols unified symbol of the market to fetch the ticker for
448
+ * @param {string[]} symbol unified symbol of the market to fetch the ticker for
449
449
  * @param {object} [params] extra parameters specific to the exchange API endpoint
450
450
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
451
451
  */
452
- async unWatchTicker(symbols, params = {}) {
452
+ async unWatchTicker(symbol, params = {}) {
453
453
  await this.loadMarkets();
454
- return await this.unWatchTickers([symbols], params);
454
+ return await this.unWatchTickers([symbol], params);
455
455
  }
456
456
  handleTicker(client, message) {
457
457
  //
@@ -1243,11 +1243,13 @@ class bybit extends bybit$1["default"] {
1243
1243
  * @name bybit#watchMyTrades
1244
1244
  * @description watches information on multiple trades made by the user
1245
1245
  * @see https://bybit-exchange.github.io/docs/v5/websocket/private/execution
1246
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/private/fast-execution
1246
1247
  * @param {string} symbol unified market symbol of the market orders were made in
1247
1248
  * @param {int} [since] the earliest time in ms to fetch orders for
1248
1249
  * @param {int} [limit] the maximum number of order structures to retrieve
1249
1250
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1250
1251
  * @param {boolean} [params.unifiedMargin] use unified margin account
1252
+ * @param {boolean} [params.executionFast] use fast execution
1251
1253
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1252
1254
  */
1253
1255
  async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -1265,7 +1267,12 @@ class bybit extends bybit$1["default"] {
1265
1267
  'unified': 'execution',
1266
1268
  'usdc': 'user.openapi.perp.trade',
1267
1269
  };
1268
- const topic = this.safeValue(topicByMarket, this.getPrivateType(url));
1270
+ let topic = this.safeValue(topicByMarket, this.getPrivateType(url));
1271
+ let executionFast = false;
1272
+ [executionFast, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'executionFast', false);
1273
+ if (executionFast) {
1274
+ topic = 'execution.fast';
1275
+ }
1269
1276
  const trades = await this.watchTopics(url, [messageHash], [topic], params);
1270
1277
  if (this.newUpdates) {
1271
1278
  limit = trades.getLimit(symbol, limit);
@@ -1277,9 +1284,11 @@ class bybit extends bybit$1["default"] {
1277
1284
  * @name bybit#unWatchMyTrades
1278
1285
  * @description unWatches information on multiple trades made by the user
1279
1286
  * @see https://bybit-exchange.github.io/docs/v5/websocket/private/execution
1287
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/private/fast-execution
1280
1288
  * @param {string} symbol unified market symbol of the market orders were made in
1281
1289
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1282
1290
  * @param {boolean} [params.unifiedMargin] use unified margin account
1291
+ * @param {boolean} [params.executionFast] use fast execution
1283
1292
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1284
1293
  */
1285
1294
  async unWatchMyTrades(symbol = undefined, params = {}) {
@@ -1297,7 +1306,12 @@ class bybit extends bybit$1["default"] {
1297
1306
  'unified': 'execution',
1298
1307
  'usdc': 'user.openapi.perp.trade',
1299
1308
  };
1300
- const topic = this.safeValue(topicByMarket, this.getPrivateType(url));
1309
+ let topic = this.safeValue(topicByMarket, this.getPrivateType(url));
1310
+ let executionFast = false;
1311
+ [executionFast, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'executionFast', false);
1312
+ if (executionFast) {
1313
+ topic = 'execution.fast';
1314
+ }
1301
1315
  return await this.unWatchTopics(url, 'myTrades', [], [messageHash], [subHash], [topic], params);
1302
1316
  }
1303
1317
  handleMyTrades(client, message) {
@@ -1363,8 +1377,31 @@ class bybit extends bybit$1["default"] {
1363
1377
  // ]
1364
1378
  // }
1365
1379
  //
1380
+ // execution.fast
1381
+ //
1382
+ // {
1383
+ // "topic": "execution.fast",
1384
+ // "creationTime": 1757405601981,
1385
+ // "data": [
1386
+ // {
1387
+ // "category": "linear",
1388
+ // "symbol": "BTCUSDT",
1389
+ // "execId": "ffcac6ac-7571-536d-a28a-847dd7d08a0f",
1390
+ // "execPrice": "112529.6",
1391
+ // "execQty": "0.001",
1392
+ // "orderId": "6e25ab73-7a55-4ae7-adc2-8ea95f167c85",
1393
+ // "isMaker": false,
1394
+ // "orderLinkId": "test-00001",
1395
+ // "side": "Buy",
1396
+ // "execTime": "1757405601977",
1397
+ // "seq": 9515624038
1398
+ // }
1399
+ // ]
1400
+ // }
1401
+ //
1366
1402
  const topic = this.safeString(message, 'topic');
1367
1403
  const spot = topic === 'ticketInfo';
1404
+ const executionFast = topic === 'execution.fast';
1368
1405
  let data = this.safeValue(message, 'data', []);
1369
1406
  if (!Array.isArray(data)) {
1370
1407
  data = this.safeValue(data, 'result', []);
@@ -1379,12 +1416,15 @@ class bybit extends bybit$1["default"] {
1379
1416
  for (let i = 0; i < data.length; i++) {
1380
1417
  const rawTrade = data[i];
1381
1418
  let parsed = undefined;
1382
- if (spot) {
1419
+ if (spot && !executionFast) {
1383
1420
  parsed = this.parseWsTrade(rawTrade);
1384
1421
  }
1385
1422
  else {
1386
1423
  // filter unified trades
1387
- const execType = this.safeString(rawTrade, 'execType', '');
1424
+ let execType = this.safeString(rawTrade, 'execType', '');
1425
+ if (executionFast) {
1426
+ execType = 'Trade';
1427
+ }
1388
1428
  if (!this.inArray(execType, filterExecTypes)) {
1389
1429
  continue;
1390
1430
  }
@@ -2340,12 +2380,13 @@ class bybit extends bybit$1["default"] {
2340
2380
  }
2341
2381
  }
2342
2382
  handleMessage(client, message) {
2383
+ const topic = this.safeString2(message, 'topic', 'op', '');
2343
2384
  if (this.handleErrorMessage(client, message)) {
2344
2385
  return;
2345
2386
  }
2346
2387
  // contract pong
2347
2388
  const ret_msg = this.safeString(message, 'ret_msg');
2348
- if (ret_msg === 'pong') {
2389
+ if ((ret_msg === 'pong') || (topic === 'pong')) {
2349
2390
  this.handlePong(client, message);
2350
2391
  return;
2351
2392
  }
@@ -2357,11 +2398,10 @@ class bybit extends bybit$1["default"] {
2357
2398
  }
2358
2399
  // pong
2359
2400
  const event = this.safeString(message, 'event');
2360
- if (event === 'sub') {
2401
+ if (event === 'sub' || (topic === 'subscribe')) {
2361
2402
  this.handleSubscriptionStatus(client, message);
2362
2403
  return;
2363
2404
  }
2364
- const topic = this.safeString2(message, 'topic', 'op', '');
2365
2405
  const methods = {
2366
2406
  'orderbook': this.handleOrderBook,
2367
2407
  'kline': this.handleOHLCV,
@@ -2374,6 +2414,7 @@ class bybit extends bybit$1["default"] {
2374
2414
  'wallet': this.handleBalance,
2375
2415
  'outboundAccountInfo': this.handleBalance,
2376
2416
  'execution': this.handleMyTrades,
2417
+ 'execution.fast': this.handleMyTrades,
2377
2418
  'ticketInfo': this.handleMyTrades,
2378
2419
  'user.openapi.perp.trade': this.handleMyTrades,
2379
2420
  'position': this.handlePositions,
@@ -2423,6 +2464,14 @@ class bybit extends bybit$1["default"] {
2423
2464
  //
2424
2465
  // { pong: 1653296711335 }
2425
2466
  //
2467
+ //
2468
+ // {
2469
+ // "req_id": "2",
2470
+ // "op": "pong",
2471
+ // "args": [ "1757405570352" ],
2472
+ // "conn_id": "d266o6hqo29sqmnq4vk0-1yus1"
2473
+ // }
2474
+ //
2426
2475
  client.lastPong = this.safeInteger(message, 'pong');
2427
2476
  return message;
2428
2477
  }
@@ -2442,6 +2491,13 @@ class bybit extends bybit$1["default"] {
2442
2491
  // "connId":"cojifin88smerbj9t560-404"
2443
2492
  // }
2444
2493
  //
2494
+ // {
2495
+ // "success": true,
2496
+ // "ret_msg": "",
2497
+ // "op": "auth",
2498
+ // "conn_id": "d266o6hqo29sqmnq4vk0-1yus1"
2499
+ // }
2500
+ //
2445
2501
  const success = this.safeValue(message, 'success');
2446
2502
  const code = this.safeInteger(message, 'retCode');
2447
2503
  const messageHash = 'authenticated';
@@ -2507,7 +2563,7 @@ class bybit extends bybit$1["default"] {
2507
2563
  for (let j = 0; j < messageHashes.length; j++) {
2508
2564
  const unsubHash = messageHashes[j];
2509
2565
  const subHash = subMessageHashes[j];
2510
- const usePrefix = (subHash === 'orders') || (subHash === 'myTrades');
2566
+ const usePrefix = (subHash === 'orders') || (subHash === 'myTrades') || (subHash === 'positions');
2511
2567
  this.cleanUnsubscription(client, subHash, unsubHash, usePrefix);
2512
2568
  }
2513
2569
  this.cleanCache(subscription);
@@ -755,7 +755,6 @@ class coinex extends coinex$1["default"] {
755
755
  let type = undefined;
756
756
  let callerMethodName = undefined;
757
757
  [callerMethodName, params] = this.handleParamString(params, 'callerMethodName', 'watchOrderBookForSymbols');
758
- [type, params] = this.handleMarketTypeAndParams(callerMethodName, undefined, params);
759
758
  const options = this.safeDict(this.options, 'watchOrderBook', {});
760
759
  const limits = this.safeList(options, 'limits', []);
761
760
  if (limit === undefined) {
@@ -772,17 +771,16 @@ class coinex extends coinex$1["default"] {
772
771
  }
773
772
  params = this.omit(params, 'aggregation');
774
773
  const symbolsDefined = (symbols !== undefined);
775
- if (symbolsDefined) {
776
- for (let i = 0; i < symbols.length; i++) {
777
- const symbol = symbols[i];
778
- market = this.market(symbol);
779
- messageHashes.push('orderbook:' + market['symbol']);
780
- watchOrderBookSubscriptions[symbol] = [market['id'], limit, aggregation, true];
781
- }
774
+ if (!symbolsDefined) {
775
+ throw new errors.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a symbol argument');
782
776
  }
783
- else {
784
- messageHashes.push('orderbook');
777
+ for (let i = 0; i < symbols.length; i++) {
778
+ const symbol = symbols[i];
779
+ market = this.market(symbol);
780
+ messageHashes.push('orderbook:' + market['symbol']);
781
+ watchOrderBookSubscriptions[symbol] = [market['id'], limit, aggregation, true];
785
782
  }
783
+ [type, params] = this.handleMarketTypeAndParams(callerMethodName, market, params);
786
784
  const marketList = Object.values(watchOrderBookSubscriptions);
787
785
  const subscribe = {
788
786
  'method': 'depth.subscribe',
@@ -849,7 +847,8 @@ class coinex extends coinex$1["default"] {
849
847
  // "id": null
850
848
  // }
851
849
  //
852
- const defaultType = this.safeString(this.options, 'defaultType');
850
+ const isSpot = client.url.indexOf('spot') > -1;
851
+ const defaultType = isSpot ? 'spot' : 'swap';
853
852
  const data = this.safeDict(message, 'data', {});
854
853
  const depth = this.safeDict(data, 'depth', {});
855
854
  const marketId = this.safeString(data, 'market');