ccxt 4.5.45 → 4.5.47

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 (91) hide show
  1. package/README.md +5 -6
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -6
  4. package/dist/cjs/src/aftermath.js +1 -1
  5. package/dist/cjs/src/backpack.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +27 -0
  7. package/dist/cjs/src/binance.js +23 -17
  8. package/dist/cjs/src/bitfinex.js +6 -11
  9. package/dist/cjs/src/bitget.js +9 -4
  10. package/dist/cjs/src/bitmart.js +144 -21
  11. package/dist/cjs/src/bitmex.js +46 -0
  12. package/dist/cjs/src/bitstamp.js +14 -1
  13. package/dist/cjs/src/bittrade.js +1 -1
  14. package/dist/cjs/src/blofin.js +137 -29
  15. package/dist/cjs/src/bybit.js +58 -56
  16. package/dist/cjs/src/bydfi.js +102 -100
  17. package/dist/cjs/src/gate.js +37 -2
  18. package/dist/cjs/src/hollaex.js +1 -1
  19. package/dist/cjs/src/kraken.js +39 -29
  20. package/dist/cjs/src/kucoin.js +2161 -462
  21. package/dist/cjs/src/lighter.js +2 -2
  22. package/dist/cjs/src/okx.js +75 -58
  23. package/dist/cjs/src/paradex.js +2 -6
  24. package/dist/cjs/src/pro/bittrade.js +4 -0
  25. package/dist/cjs/src/pro/bydfi.js +19 -19
  26. package/dist/cjs/src/pro/gate.js +79 -54
  27. package/dist/cjs/src/pro/grvt.js +6 -4
  28. package/dist/cjs/src/pro/htx.js +4 -4
  29. package/dist/cjs/src/pro/lighter.js +1 -1
  30. package/dist/cjs/src/pro/okx.js +1 -1
  31. package/dist/cjs/src/whitebit.js +21 -2
  32. package/index.d.cts +2 -0
  33. package/js/ccxt.d.ts +2 -8
  34. package/js/ccxt.js +2 -6
  35. package/js/src/abstract/bitmart.d.ts +7 -0
  36. package/js/src/abstract/blofin.d.ts +28 -12
  37. package/js/src/abstract/bydfi.d.ts +29 -29
  38. package/js/src/abstract/kraken.d.ts +36 -29
  39. package/js/src/abstract/kucoin.d.ts +2 -0
  40. package/js/src/abstract/kucoinfutures.d.ts +2 -0
  41. package/js/src/aftermath.js +1 -1
  42. package/js/src/backpack.js +1 -1
  43. package/js/src/base/Exchange.d.ts +2 -0
  44. package/js/src/base/Exchange.js +27 -0
  45. package/js/src/binance.js +23 -17
  46. package/js/src/bitfinex.js +6 -11
  47. package/js/src/bitget.d.ts +1 -1
  48. package/js/src/bitget.js +9 -4
  49. package/js/src/bitmart.d.ts +18 -4
  50. package/js/src/bitmart.js +144 -21
  51. package/js/src/bitmex.d.ts +12 -0
  52. package/js/src/bitmex.js +46 -0
  53. package/js/src/bitstamp.js +14 -1
  54. package/js/src/bittrade.js +1 -1
  55. package/js/src/blofin.d.ts +2 -0
  56. package/js/src/blofin.js +137 -29
  57. package/js/src/bybit.d.ts +1 -0
  58. package/js/src/bybit.js +58 -56
  59. package/js/src/bydfi.d.ts +31 -31
  60. package/js/src/bydfi.js +102 -100
  61. package/js/src/gate.js +37 -2
  62. package/js/src/hollaex.js +1 -1
  63. package/js/src/kraken.js +39 -29
  64. package/js/src/kucoin.d.ts +249 -8
  65. package/js/src/kucoin.js +2161 -462
  66. package/js/src/lighter.js +2 -2
  67. package/js/src/okx.d.ts +1 -0
  68. package/js/src/okx.js +75 -58
  69. package/js/src/paradex.d.ts +0 -1
  70. package/js/src/paradex.js +2 -6
  71. package/js/src/pro/bittrade.js +4 -0
  72. package/js/src/pro/bydfi.d.ts +18 -18
  73. package/js/src/pro/bydfi.js +19 -19
  74. package/js/src/pro/gate.d.ts +2 -2
  75. package/js/src/pro/gate.js +79 -54
  76. package/js/src/pro/grvt.js +6 -4
  77. package/js/src/pro/htx.js +4 -4
  78. package/js/src/pro/lighter.js +1 -1
  79. package/js/src/pro/okx.js +1 -1
  80. package/js/src/whitebit.d.ts +1 -1
  81. package/js/src/whitebit.js +21 -2
  82. package/package.json +2 -2
  83. package/dist/cjs/src/abstract/coincatch.js +0 -11
  84. package/dist/cjs/src/coincatch.js +0 -5495
  85. package/dist/cjs/src/pro/coincatch.js +0 -1563
  86. package/js/src/abstract/coincatch.d.ts +0 -97
  87. package/js/src/abstract/coincatch.js +0 -5
  88. package/js/src/coincatch.d.ts +0 -788
  89. package/js/src/coincatch.js +0 -5488
  90. package/js/src/pro/coincatch.d.ts +0 -207
  91. package/js/src/pro/coincatch.js +0 -1556
@@ -508,7 +508,7 @@ class lighter extends lighter$1["default"] {
508
508
  setSandboxMode(enable) {
509
509
  super.setSandboxMode(enable);
510
510
  this.options['sandboxMode'] = enable;
511
- this.options['chainId'] = 300;
511
+ this.options['chainId'] = enable ? 300 : 304;
512
512
  }
513
513
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
514
514
  /**
@@ -1152,7 +1152,7 @@ class lighter extends lighter$1["default"] {
1152
1152
  // "daily_chart": {},
1153
1153
  // "market_config": {
1154
1154
  // "market_margin_mode": 0,
1155
- // "insurance_fund_account_index": 281474976710655,
1155
+ // "insurance_fund_account_index": 281474976710654,
1156
1156
  // "liquidation_mode": 0,
1157
1157
  // "force_reduce_only": false,
1158
1158
  // "trading_hours": ""
@@ -1073,11 +1073,13 @@ class okx extends okx$1["default"] {
1073
1073
  },
1074
1074
  'networks': {
1075
1075
  'BTC': 'Bitcoin',
1076
- 'BTCLN': 'Lightning',
1077
1076
  'BTCLIGHTNING': 'Lightning',
1077
+ 'BSC': 'BSC',
1078
1078
  'BEP20': 'BSC',
1079
1079
  'BRC20': 'BRC20',
1080
+ 'ETH': 'ERC20',
1080
1081
  'ERC20': 'ERC20',
1082
+ 'TRX': 'TRC20',
1081
1083
  'TRC20': 'TRC20',
1082
1084
  'CRC20': 'Crypto',
1083
1085
  'ACA': 'Acala',
@@ -1193,6 +1195,11 @@ class okx extends okx$1["default"] {
1193
1195
  // "WBTCK-OKTC",
1194
1196
  // "ZetaChain",
1195
1197
  },
1198
+ 'networksById': {
1199
+ 'ERC20': 'ERC20',
1200
+ 'TRC20': 'TRC20',
1201
+ 'BEP20': 'BEP20',
1202
+ },
1196
1203
  'fetchOpenInterestHistory': {
1197
1204
  'timeframes': {
1198
1205
  '5m': '5m',
@@ -1890,7 +1897,18 @@ class okx extends okx$1["default"] {
1890
1897
  // }
1891
1898
  //
1892
1899
  const dataResponse = this.safeList(response, 'data', []);
1893
- return this.parseMarkets(dataResponse);
1900
+ const marketsWithoutTest = [];
1901
+ for (let i = 0; i < dataResponse.length; i++) {
1902
+ const data = dataResponse[i];
1903
+ if (this.isSandboxModeEnabled) {
1904
+ const instFamily = this.safeString(data, 'instFamily', '');
1905
+ if (instFamily.startsWith('TEST')) {
1906
+ continue;
1907
+ }
1908
+ }
1909
+ marketsWithoutTest.push(data);
1910
+ }
1911
+ return this.parseMarkets(marketsWithoutTest);
1894
1912
  }
1895
1913
  /**
1896
1914
  * @method
@@ -1959,68 +1977,67 @@ class okx extends okx$1["default"] {
1959
1977
  // }
1960
1978
  //
1961
1979
  const data = this.safeList(response, 'data', []);
1962
- const result = {};
1963
1980
  const dataByCurrencyId = this.groupBy(data, 'ccy');
1964
- const currencyIds = Object.keys(dataByCurrencyId);
1965
- for (let i = 0; i < currencyIds.length; i++) {
1966
- const currencyId = currencyIds[i];
1967
- const currency = this.safeCurrency(currencyId);
1968
- const code = currency['code'];
1969
- const chains = dataByCurrencyId[currencyId];
1970
- const networks = {};
1971
- let type = 'crypto';
1972
- const chainsLength = chains.length;
1973
- for (let j = 0; j < chainsLength; j++) {
1974
- const chain = chains[j];
1975
- // allow empty string for rare fiat-currencies, e.g. TRY
1976
- const networkId = this.safeString(chain, 'chain', ''); // USDT-BEP20, USDT-Avalance-C, etc
1977
- if (networkId === '') {
1978
- // only happens for fiat 'TRY' currency
1979
- type = 'fiat';
1980
- }
1981
- const idParts = networkId.split('-');
1982
- const parts = this.arraySlice(idParts, 1);
1983
- const chainPart = parts.join('-');
1984
- const networkCode = this.networkIdToCode(chainPart, currency['code']);
1985
- networks[networkCode] = {
1986
- 'id': networkId,
1987
- 'network': networkCode,
1988
- 'active': undefined,
1989
- 'deposit': this.safeBool(chain, 'canDep'),
1990
- 'withdraw': this.safeBool(chain, 'canWd'),
1991
- 'fee': this.safeNumber(chain, 'fee'),
1992
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'wdTickSz'))),
1993
- 'limits': {
1994
- 'withdraw': {
1995
- 'min': this.safeNumber(chain, 'minWd'),
1996
- 'max': this.safeNumber(chain, 'maxWd'),
1997
- },
1998
- },
1999
- 'info': chain,
2000
- };
1981
+ const currencies = Object.values(dataByCurrencyId);
1982
+ return this.parseCurrencies(currencies);
1983
+ }
1984
+ parseCurrency(currency) {
1985
+ const chains = currency;
1986
+ // currencies are grouped by chain entries, so there is at least one entry
1987
+ const firstChain = this.safeDict(chains, 0, {});
1988
+ const currencyId = this.safeString(firstChain, 'ccy');
1989
+ const code = this.safeCurrencyCode(currencyId);
1990
+ const networks = {};
1991
+ let type = 'crypto';
1992
+ const chainsLength = chains.length;
1993
+ for (let j = 0; j < chainsLength; j++) {
1994
+ const chain = chains[j];
1995
+ // allow empty string for rare fiat-currencies, e.g. TRY
1996
+ const networkId = this.safeString(chain, 'chain', ''); // USDT-BEP20, USDT-Avalance-C, etc
1997
+ if (networkId === '') {
1998
+ // only happens for fiat 'TRY' currency
1999
+ type = 'fiat';
2001
2000
  }
2002
- const firstChain = this.safeDict(chains, 0, {});
2003
- result[code] = this.safeCurrencyStructure({
2004
- 'info': chains,
2005
- 'code': code,
2006
- 'id': currencyId,
2007
- 'name': this.safeString(firstChain, 'name'),
2001
+ const idParts = networkId.split('-');
2002
+ const parts = this.arraySlice(idParts, 1);
2003
+ const chainPart = parts.join('-');
2004
+ const networkCode = this.networkIdToCode(chainPart, code);
2005
+ networks[networkCode] = {
2006
+ 'id': networkId,
2007
+ 'network': networkCode,
2008
2008
  'active': undefined,
2009
- 'deposit': undefined,
2010
- 'withdraw': undefined,
2011
- 'fee': undefined,
2012
- 'precision': undefined,
2009
+ 'deposit': this.safeBool(chain, 'canDep'),
2010
+ 'withdraw': this.safeBool(chain, 'canWd'),
2011
+ 'fee': this.safeNumber(chain, 'fee'),
2012
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'wdTickSz'))),
2013
2013
  'limits': {
2014
- 'amount': {
2015
- 'min': undefined,
2016
- 'max': undefined,
2014
+ 'withdraw': {
2015
+ 'min': this.safeNumber(chain, 'minWd'),
2016
+ 'max': this.safeNumber(chain, 'maxWd'),
2017
2017
  },
2018
2018
  },
2019
- 'type': type,
2020
- 'networks': networks,
2021
- });
2019
+ 'info': chain,
2020
+ };
2022
2021
  }
2023
- return result;
2022
+ return this.safeCurrencyStructure({
2023
+ 'info': chains,
2024
+ 'code': code,
2025
+ 'id': currencyId,
2026
+ 'name': this.safeString(firstChain, 'name'),
2027
+ 'active': undefined,
2028
+ 'deposit': undefined,
2029
+ 'withdraw': undefined,
2030
+ 'fee': undefined,
2031
+ 'precision': undefined,
2032
+ 'limits': {
2033
+ 'amount': {
2034
+ 'min': undefined,
2035
+ 'max': undefined,
2036
+ },
2037
+ },
2038
+ 'type': type,
2039
+ 'networks': networks,
2040
+ });
2024
2041
  }
2025
2042
  /**
2026
2043
  * @method
@@ -5405,7 +5422,7 @@ class okx extends okx$1["default"] {
5405
5422
  if (fee === undefined) {
5406
5423
  const currencies = await this.fetchCurrencies();
5407
5424
  this.currencies = this.mapToSafeMap(this.deepExtend(this.currencies, currencies));
5408
- const targetNetwork = this.safeDict(currency['networks'], this.networkIdToCode(network), {});
5425
+ const targetNetwork = this.safeDict(currency['networks'], this.networkIdToCode(network, currency['code']), {});
5409
5426
  fee = this.safeString(targetNetwork, 'fee');
5410
5427
  if (fee === undefined) {
5411
5428
  throw new errors.ArgumentsRequired(this.id + ' withdraw() requires a "fee" string parameter, network transaction fee must be ≥ 0. Withdrawals to OKCoin or OKX are fee-free, please set "0". Withdrawing to external digital asset address requires network transaction fee.');
@@ -1344,10 +1344,6 @@ class paradex extends paradex$1["default"] {
1344
1344
  };
1345
1345
  return this.safeStringLower(types, type, type);
1346
1346
  }
1347
- convertShortString(str) {
1348
- // TODO: add stringToBase16 in exchange
1349
- return '0x' + this.binaryToBase16(this.base64ToBinary(this.stringToBase64(str)));
1350
- }
1351
1347
  scaleNumber(num) {
1352
1348
  return Precise["default"].stringMul(num, '100000000');
1353
1349
  }
@@ -1464,9 +1460,9 @@ class paradex extends paradex$1["default"] {
1464
1460
  const now = this.nonce();
1465
1461
  const orderReq = {
1466
1462
  'timestamp': now * 1000,
1467
- 'market': this.convertShortString(request['market']),
1463
+ 'market': this.stringToBase16(request['market']),
1468
1464
  'side': (orderSide === 'BUY') ? '1' : '2',
1469
- 'orderType': this.convertShortString(request['type']),
1465
+ 'orderType': this.stringToBase16(request['type']),
1470
1466
  'size': this.scaleNumber(request['size']),
1471
1467
  'price': (isMarket) ? '0' : this.scaleNumber(request['price']),
1472
1468
  };
@@ -304,6 +304,7 @@ class bittrade extends bittrade$1["default"] {
304
304
  // {
305
305
  // "id": 1583473663565,
306
306
  // "rep": "market.btcusdt.mbp.150",
307
+ // "ts": 1774979531056,
307
308
  // "status": "ok",
308
309
  // "data": {
309
310
  // "seqNum": 104999417756,
@@ -322,10 +323,13 @@ class bittrade extends bittrade$1["default"] {
322
323
  //
323
324
  const symbol = this.safeString(subscription, 'symbol');
324
325
  const messageHash = this.safeString(subscription, 'messageHash');
326
+ const timestamp = this.safeInteger(message, 'ts');
325
327
  const orderbook = this.orderbooks[symbol];
326
328
  const data = this.safeValue(message, 'data');
327
329
  const snapshot = this.parseOrderBook(data, symbol);
328
330
  snapshot['nonce'] = this.safeInteger(data, 'seqNum');
331
+ snapshot['timestamp'] = timestamp;
332
+ snapshot['datetime'] = this.iso8601(timestamp);
329
333
  orderbook.reset(snapshot);
330
334
  // unroll the accumulated deltas
331
335
  const messages = orderbook.cache;
@@ -44,7 +44,7 @@ class bydfi extends bydfi$1["default"] {
44
44
  },
45
45
  'urls': {
46
46
  'api': {
47
- 'ws': 'wss://stream.bydfi.com/v1/public/swap',
47
+ 'ws': 'wss://stream.bydfi.com/v1/public/fapi',
48
48
  },
49
49
  },
50
50
  'options': {
@@ -143,7 +143,7 @@ class bydfi extends bydfi$1["default"] {
143
143
  * @method
144
144
  * @name bydfi#watchTicker
145
145
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
146
- * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
146
+ * @see https://developers.bydfi.com/en/futures/websocket-market#ticker-by-symbol
147
147
  * @param {string} symbol unified symbol of the market to fetch the ticker for
148
148
  * @param {object} [params] extra parameters specific to the exchange API endpoint
149
149
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -160,7 +160,7 @@ class bydfi extends bydfi$1["default"] {
160
160
  * @method
161
161
  * @name bydfi#unWatchTicker
162
162
  * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
163
- * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
163
+ * @see https://developers.bydfi.com/en/futures/websocket-market#ticker-by-symbol
164
164
  * @param {string} symbol unified symbol of the market to fetch the ticker for
165
165
  * @param {object} [params] extra parameters specific to the exchange API endpoint
166
166
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -172,8 +172,8 @@ class bydfi extends bydfi$1["default"] {
172
172
  * @method
173
173
  * @name bydfi#watchTickers
174
174
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
175
- * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
176
- * @see https://developers.bydfi.com/en/swap/websocket-market#market-wide-ticker
175
+ * @see https://developers.bydfi.com/en/futures/websocket-market#ticker-by-symbol
176
+ * @see https://developers.bydfi.com/en/futures/websocket-market#market-wide-ticker
177
177
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
178
178
  * @param {object} [params] extra parameters specific to the exchange API endpoint
179
179
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -204,8 +204,8 @@ class bydfi extends bydfi$1["default"] {
204
204
  * @method
205
205
  * @name bydfi#unWatchTickers
206
206
  * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
207
- * @see https://developers.bydfi.com/en/swap/websocket-market#ticker-by-symbol
208
- * @see https://developers.bydfi.com/en/swap/websocket-market#market-wide-ticker
207
+ * @see https://developers.bydfi.com/en/futures/websocket-market#ticker-by-symbol
208
+ * @see https://developers.bydfi.com/en/futures/websocket-market#market-wide-ticker
209
209
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
210
210
  * @param {object} [params] extra parameters specific to the exchange API endpoint
211
211
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -289,7 +289,7 @@ class bydfi extends bydfi$1["default"] {
289
289
  * @method
290
290
  * @name bydfi#watchOHLCV
291
291
  * @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
292
- * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
292
+ * @see https://developers.bydfi.com/en/futures/websocket-market#candlestick-data
293
293
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
294
294
  * @param {string} timeframe the length of time each candle represents
295
295
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -305,7 +305,7 @@ class bydfi extends bydfi$1["default"] {
305
305
  * @method
306
306
  * @name bydfi#unWatchOHLCV
307
307
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
308
- * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
308
+ * @see https://developers.bydfi.com/en/futures/websocket-market#candlestick-data
309
309
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
310
310
  * @param {string} timeframe the length of time each candle represents
311
311
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -318,7 +318,7 @@ class bydfi extends bydfi$1["default"] {
318
318
  * @method
319
319
  * @name bydfi#watchOHLCVForSymbols
320
320
  * @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
321
- * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
321
+ * @see https://developers.bydfi.com/en/futures/websocket-market#candlestick-data
322
322
  * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
323
323
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
324
324
  * @param {int} [limit] the maximum amount of candles to fetch
@@ -354,7 +354,7 @@ class bydfi extends bydfi$1["default"] {
354
354
  * @method
355
355
  * @name bydfi#unWatchOHLCVForSymbols
356
356
  * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
357
- * @see https://developers.bydfi.com/en/swap/websocket-market#candlestick-data
357
+ * @see https://developers.bydfi.com/en/futures/websocket-market#candlestick-data
358
358
  * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
359
359
  * @param {object} [params] extra parameters specific to the exchange API endpoint
360
360
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
@@ -422,7 +422,7 @@ class bydfi extends bydfi$1["default"] {
422
422
  * @method
423
423
  * @name bydfi#watchOrderBook
424
424
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
425
- * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
425
+ * @see https://developers.bydfi.com/en/futures/websocket-market#limited-depth-information
426
426
  * @param {string} symbol unified symbol of the market to fetch the order book for
427
427
  * @param {int} [limit] the maximum amount of order book entries to return (default and maxi is 100)
428
428
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -435,7 +435,7 @@ class bydfi extends bydfi$1["default"] {
435
435
  * @method
436
436
  * @name bydfi#unWatchOrderBook
437
437
  * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
438
- * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
438
+ * @see https://developers.bydfi.com/en/futures/websocket-market#limited-depth-information
439
439
  * @param {string} symbol unified array of symbols
440
440
  * @param {object} [params] extra parameters specific to the exchange API endpoint
441
441
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
@@ -447,7 +447,7 @@ class bydfi extends bydfi$1["default"] {
447
447
  * @method
448
448
  * @name bydfi#watchOrderBookForSymbols
449
449
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
450
- * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
450
+ * @see https://developers.bydfi.com/en/futures/websocket-market#limited-depth-information
451
451
  * @param {string[]} symbols unified array of symbols
452
452
  * @param {int} [limit] the maximum amount of order book entries to return (default and max is 100)
453
453
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -479,7 +479,7 @@ class bydfi extends bydfi$1["default"] {
479
479
  * @method
480
480
  * @name bydfi#unWatchOrderBookForSymbols
481
481
  * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
482
- * @see https://developers.bydfi.com/en/swap/websocket-market#limited-depth-information
482
+ * @see https://developers.bydfi.com/en/futures/websocket-market#limited-depth-information
483
483
  * @param {string[]} symbols unified array of symbols
484
484
  * @param {object} [params] extra parameters specific to the exchange API endpoint
485
485
  * @param {string} [params.method] either '/market/level2' or '/spotMarket/level2Depth5' or '/spotMarket/level2Depth50' default is '/market/level2'
@@ -538,7 +538,7 @@ class bydfi extends bydfi$1["default"] {
538
538
  * @method
539
539
  * @name bydfi#watchOrders
540
540
  * @description watches information on multiple orders made by the user
541
- * @see https://developers.bydfi.com/en/swap/websocket-account#order-trade-update-push
541
+ * @see https://developers.bydfi.com/en/futures/websocket-account#order-trade-update-push
542
542
  * @param {string} symbol unified market symbol of the market orders were made in
543
543
  * @param {int} [since] the earliest time in ms to fetch orders for
544
544
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -556,7 +556,7 @@ class bydfi extends bydfi$1["default"] {
556
556
  * @method
557
557
  * @name bydfi#watchOrdersForSymbols
558
558
  * @description watches information on multiple orders made by the user
559
- * @see https://developers.bydfi.com/en/swap/websocket-account#order-trade-update-push
559
+ * @see https://developers.bydfi.com/en/futures/websocket-account#order-trade-update-push
560
560
  * @param {string[]} symbols unified symbol of the market to fetch orders for
561
561
  * @param {int} [since] the earliest time in ms to fetch orders for
562
562
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -699,7 +699,7 @@ class bydfi extends bydfi$1["default"] {
699
699
  * @method
700
700
  * @name bydfi#watchPositions
701
701
  * @description watch all open positions
702
- * @see https://developers.bydfi.com/en/swap/websocket-account#balance-and-position-update-push
702
+ * @see https://developers.bydfi.com/en/futures/websocket-account#balance-and-position-update-push
703
703
  * @param {string[]} [symbols] list of unified market symbols
704
704
  * @param {int} [since] the earliest time in ms to fetch positions for
705
705
  * @param {int} [limit] the maximum number of positions to retrieve
@@ -852,7 +852,7 @@ class bydfi extends bydfi$1["default"] {
852
852
  * @method
853
853
  * @name bydfi#watchBalance
854
854
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
855
- * @see https://developers.bydfi.com/en/swap/websocket-account#balance-and-position-update-push
855
+ * @see https://developers.bydfi.com/en/futures/websocket-account#balance-and-position-update-push
856
856
  * @param {object} [params] extra parameters specific to the exchange API endpoint
857
857
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
858
858
  */
@@ -51,6 +51,19 @@ class gate extends gate$1["default"] {
51
51
  'watchMyLiquidations': true,
52
52
  'watchMyLiquidationsForSymbols': true,
53
53
  'watchPositions': true,
54
+ 'unWatchTicker': false,
55
+ 'unWatchTickers': false,
56
+ 'unWatchOHLCV': false,
57
+ 'unWatchOHLCVForSymbols': false,
58
+ 'unWatchOrderBook': true,
59
+ 'unWatchOrderBookForSymbols': false,
60
+ 'unWatchTrades': true,
61
+ 'unWatchTradesForSymbols': true,
62
+ 'unWatchMyTrades': false,
63
+ 'unWatchOrders': false,
64
+ 'unWatchPositions': false,
65
+ 'unWatchMarkPrices': false,
66
+ 'unWatchMarkPrice': false,
54
67
  },
55
68
  'urls': {
56
69
  'api': {
@@ -1033,11 +1046,11 @@ class gate extends gate$1["default"] {
1033
1046
  /**
1034
1047
  * @method
1035
1048
  * @name gate#watchBalance
1049
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
1036
1050
  * @see https://www.gate.com/docs/developers/apiv4/ws/en/#spot-balance-channel
1037
1051
  * @see https://www.gate.com/docs/developers/futures/ws/en/#balances-api
1038
1052
  * @see https://www.gate.com/docs/developers/delivery/ws/en/#balances-api
1039
1053
  * @see https://www.gate.com/docs/developers/options/ws/en/#balances-channel
1040
- * @description watch balance and get the amount of funds available for trading or funds locked in orders
1041
1054
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1042
1055
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
1043
1056
  */
@@ -1065,22 +1078,26 @@ class gate extends gate$1["default"] {
1065
1078
  handleBalance(client, message) {
1066
1079
  //
1067
1080
  // spot order fill
1068
- // {
1069
- // "time": 1653664351,
1070
- // "channel": "spot.balances",
1071
- // "event": "update",
1072
- // "result": [
1073
- // {
1074
- // "timestamp": "1653664351",
1075
- // "timestamp_ms": "1653664351017",
1076
- // "user": "10406147",
1077
- // "currency": "LTC",
1078
- // "change": "-0.0002000000000000",
1079
- // "total": "0.09986000000000000000",
1080
- // "available": "0.09986000000000000000"
1081
- // }
1082
- // ]
1083
- // }
1081
+ // {
1082
+ // "time": 1653664351,
1083
+ // "time_ms": 1605248616763,
1084
+ // "channel": "spot.balances",
1085
+ // "event": "update",
1086
+ // "result": [
1087
+ // {
1088
+ // "timestamp": "1667556323",
1089
+ // "timestamp_ms": "1667556323730",
1090
+ // "user": "1000001",
1091
+ // "currency": "USDT",
1092
+ // "change": "0",
1093
+ // "total": "222244.3827652",
1094
+ // "available": "222244.3827",
1095
+ // "freeze": "5",
1096
+ // "freeze_change": "5.000000",
1097
+ // "change_type": "order-create"
1098
+ // }
1099
+ // ]
1100
+ // }
1084
1101
  //
1085
1102
  // account transfer
1086
1103
  //
@@ -1124,15 +1141,16 @@ class gate extends gate$1["default"] {
1124
1141
  // }
1125
1142
  //
1126
1143
  const result = this.safeValue(message, 'result', []);
1127
- const timestamp = this.safeInteger(message, 'time_ms');
1128
1144
  this.balance['info'] = result;
1129
- this.balance['timestamp'] = timestamp;
1130
- this.balance['datetime'] = this.iso8601(timestamp);
1131
1145
  for (let i = 0; i < result.length; i++) {
1132
1146
  const rawBalance = result[i];
1133
1147
  const account = this.account();
1134
1148
  const currencyId = this.safeString(rawBalance, 'currency', 'USDT'); // when not present it is USDT
1135
1149
  const code = this.safeCurrencyCode(currencyId);
1150
+ const timestamp = this.safeInteger2(rawBalance, 'time_ms', 'timestamp_ms');
1151
+ this.balance['timestamp'] = timestamp;
1152
+ this.balance['datetime'] = this.iso8601(timestamp);
1153
+ account['used'] = this.safeString(rawBalance, 'freeze');
1136
1154
  account['free'] = this.safeString(rawBalance, 'available');
1137
1155
  account['total'] = this.safeString2(rawBalance, 'total', 'balance');
1138
1156
  this.balance[code] = account;
@@ -1323,11 +1341,11 @@ class gate extends gate$1["default"] {
1323
1341
  /**
1324
1342
  * @method
1325
1343
  * @name gate#watchOrders
1344
+ * @description watches information on multiple orders made by the user
1326
1345
  * @see https://www.gate.com/docs/developers/apiv4/ws/en/#orders-channel
1327
1346
  * @see https://www.gate.com/docs/developers/futures/ws/en/#orders-api
1328
1347
  * @see https://www.gate.com/docs/developers/delivery/ws/en/#orders-api
1329
1348
  * @see https://www.gate.com/docs/developers/options/ws/en/#orders-channel
1330
- * @description watches information on multiple orders made by the user
1331
1349
  * @param {string} symbol unified market symbol of the market orders were made in
1332
1350
  * @param {int} [since] the earliest time in ms to fetch orders for
1333
1351
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1374,39 +1392,46 @@ class gate extends gate$1["default"] {
1374
1392
  }
1375
1393
  handleOrder(client, message) {
1376
1394
  //
1377
- // {
1378
- // "time": 1605175506,
1379
- // "channel": "spot.orders",
1380
- // "event": "update",
1381
- // "result": [
1382
- // {
1383
- // "id": "30784435",
1384
- // "user": 123456,
1385
- // "text": "t-abc",
1386
- // "create_time": "1605175506",
1387
- // "create_time_ms": "1605175506123",
1388
- // "update_time": "1605175506",
1389
- // "update_time_ms": "1605175506123",
1390
- // "event": "put",
1391
- // "currency_pair": "BTC_USDT",
1392
- // "type": "limit",
1393
- // "account": "spot",
1394
- // "side": "sell",
1395
- // "amount": "1",
1396
- // "price": "10001",
1397
- // "time_in_force": "gtc",
1398
- // "left": "1",
1399
- // "filled_total": "0",
1400
- // "fee": "0",
1401
- // "fee_currency": "USDT",
1402
- // "point_fee": "0",
1403
- // "gt_fee": "0",
1404
- // "gt_discount": true,
1405
- // "rebated_fee": "0",
1406
- // "rebated_fee_currency": "USDT"
1407
- // }
1408
- // ]
1409
- // }
1395
+ // {
1396
+ // "time": 1774613210,
1397
+ // "time_ms": 1774613210392,
1398
+ // "channel": "spot.orders",
1399
+ // "event": "update",
1400
+ // "result": [
1401
+ // {
1402
+ // "id": "1036717689726",
1403
+ // "text": "apiv4",
1404
+ // "create_time": "1774613210",
1405
+ // "update_time": "1774613210",
1406
+ // "currency_pair": "BTC_USDT",
1407
+ // "type": "limit",
1408
+ // "account": "unified",
1409
+ // "side": "buy",
1410
+ // "amount": "0.1",
1411
+ // "price": "200",
1412
+ // "time_in_force": "gtc",
1413
+ // "left": "0.1",
1414
+ // "filled_amount": "0",
1415
+ // "filled_total": "0",
1416
+ // "avg_deal_price": "0",
1417
+ // "fee": "0",
1418
+ // "fee_currency": "BTC",
1419
+ // "point_fee": "0",
1420
+ // "gt_fee": "0",
1421
+ // "rebated_fee": "0",
1422
+ // "rebated_fee_currency": "BTC",
1423
+ // "create_time_ms": "1774613210391",
1424
+ // "update_time_ms": "1774613210391",
1425
+ // "user": 10406147,
1426
+ // "event": "put",
1427
+ // "stp_id": 0,
1428
+ // "stp_act": "-",
1429
+ // "finish_as": "open",
1430
+ // "biz_info": "ch:ccxt",
1431
+ // "amend_text": "-"
1432
+ // }
1433
+ // ]
1434
+ // }
1410
1435
  //
1411
1436
  const orders = this.safeValue(message, 'result', []);
1412
1437
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
@@ -40,7 +40,8 @@ class grvt extends grvt$1["default"] {
40
40
  'channel': 'v1.book.s', // v1.book.s | v1.book.d
41
41
  },
42
42
  'watchTickers': {
43
- 'channel': 'v1.ticker.s', // v1.ticker.s | v1.ticker.d | v1.mini.s | v1.mini.d
43
+ 'channel': 'v1.ticker.s',
44
+ 'interval': 500, // raw, 50, 100, 200, 500, 1000, 5000
44
45
  },
45
46
  },
46
47
  'streaming': {
@@ -154,6 +155,8 @@ class grvt extends grvt$1["default"] {
154
155
  }
155
156
  let channel = undefined;
156
157
  [channel, params] = this.handleOptionAndParams(params, 'watchTickers', 'channel', 'v1.ticker.s');
158
+ let interval = undefined;
159
+ [interval, params] = this.handleOptionAndParams(params, 'watchTickers', 'interval', 500);
157
160
  await this.loadMarkets();
158
161
  symbols = this.marketSymbols(symbols);
159
162
  const rawHashes = [];
@@ -162,8 +165,7 @@ class grvt extends grvt$1["default"] {
162
165
  const symbol = symbols[i];
163
166
  const market = this.market(symbol);
164
167
  const marketId = market['id'];
165
- const interval = this.safeInteger(params, 'interval', 500); // raw, 50, 100, 200, 500, 1000, 5000
166
- rawHashes.push(marketId + '@' + interval);
168
+ rawHashes.push(marketId + '@' + interval.toString());
167
169
  messageHashes.push('ticker::' + market['symbol']);
168
170
  }
169
171
  const request = {
@@ -512,7 +514,7 @@ class grvt extends grvt$1["default"] {
512
514
  const symbol = symbols[i];
513
515
  const market = this.market(symbol);
514
516
  const marketId = market['id'];
515
- rawHashes.push(marketId + '@' + extraPart);
517
+ rawHashes.push(marketId + '@' + extraPart.toString());
516
518
  messageHashes.push('orderbook::' + market['symbol']);
517
519
  }
518
520
  const request = {