ccxt 4.4.68 → 4.4.70

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 (51) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +0 -1
  5. package/dist/cjs/src/binance.js +20 -3
  6. package/dist/cjs/src/bitget.js +49 -335
  7. package/dist/cjs/src/bitstamp.js +2 -3
  8. package/dist/cjs/src/bybit.js +7 -0
  9. package/dist/cjs/src/coinbase.js +25 -9
  10. package/dist/cjs/src/cryptomus.js +214 -116
  11. package/dist/cjs/src/hyperliquid.js +19 -8
  12. package/dist/cjs/src/okx.js +4 -0
  13. package/dist/cjs/src/paradex.js +172 -4
  14. package/dist/cjs/src/phemex.js +2 -2
  15. package/dist/cjs/src/pro/bitget.js +40 -7
  16. package/dist/cjs/src/pro/bybit.js +86 -38
  17. package/dist/cjs/src/tradeogre.js +34 -11
  18. package/dist/cjs/src/whitebit.js +211 -1
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/bybit.d.ts +4 -0
  22. package/js/src/abstract/myokx.d.ts +3 -0
  23. package/js/src/abstract/okx.d.ts +3 -0
  24. package/js/src/abstract/paradex.d.ts +23 -0
  25. package/js/src/abstract/tradeogre.d.ts +2 -1
  26. package/js/src/base/Exchange.js +0 -1
  27. package/js/src/base/types.d.ts +2 -2
  28. package/js/src/binance.js +20 -3
  29. package/js/src/bitget.d.ts +0 -1
  30. package/js/src/bitget.js +49 -335
  31. package/js/src/bitstamp.js +2 -3
  32. package/js/src/bybit.js +7 -0
  33. package/js/src/coinbase.d.ts +0 -5
  34. package/js/src/coinbase.js +25 -9
  35. package/js/src/cryptomus.d.ts +127 -1
  36. package/js/src/cryptomus.js +214 -116
  37. package/js/src/hyperliquid.js +19 -8
  38. package/js/src/okx.d.ts +1 -0
  39. package/js/src/okx.js +4 -0
  40. package/js/src/paradex.d.ts +48 -1
  41. package/js/src/paradex.js +172 -4
  42. package/js/src/phemex.d.ts +1 -1
  43. package/js/src/phemex.js +2 -2
  44. package/js/src/pro/bitget.js +40 -7
  45. package/js/src/pro/bybit.d.ts +1 -0
  46. package/js/src/pro/bybit.js +86 -38
  47. package/js/src/tradeogre.d.ts +1 -0
  48. package/js/src/tradeogre.js +34 -11
  49. package/js/src/whitebit.d.ts +35 -1
  50. package/js/src/whitebit.js +211 -1
  51. package/package.json +1 -1
@@ -76,10 +76,10 @@ class paradex extends paradex$1 {
76
76
  'fetchIsolatedBorrowRate': false,
77
77
  'fetchIsolatedBorrowRates': false,
78
78
  'fetchLedger': false,
79
- 'fetchLeverage': false,
79
+ 'fetchLeverage': true,
80
80
  'fetchLeverageTiers': false,
81
81
  'fetchLiquidations': true,
82
- 'fetchMarginMode': undefined,
82
+ 'fetchMarginMode': true,
83
83
  'fetchMarketLeverageTiers': false,
84
84
  'fetchMarkets': true,
85
85
  'fetchMarkOHLCV': false,
@@ -113,8 +113,8 @@ class paradex extends paradex$1 {
113
113
  'repayCrossMargin': false,
114
114
  'repayIsolatedMargin': false,
115
115
  'sandbox': true,
116
- 'setLeverage': false,
117
- 'setMarginMode': false,
116
+ 'setLeverage': true,
117
+ 'setMarginMode': true,
118
118
  'setPositionMode': false,
119
119
  'transfer': false,
120
120
  'withdraw': false,
@@ -156,12 +156,23 @@ class paradex extends paradex$1 {
156
156
  'system/state': 1,
157
157
  'system/time': 1,
158
158
  'trades': 1,
159
+ 'vaults': 1,
160
+ 'vaults/balance': 1,
161
+ 'vaults/config': 1,
162
+ 'vaults/history': 1,
163
+ 'vaults/positions': 1,
164
+ 'vaults/summary': 1,
165
+ 'vaults/transfers': 1,
159
166
  },
160
167
  },
161
168
  'private': {
162
169
  'get': {
163
170
  'account': 1,
171
+ 'account/info': 1,
172
+ 'account/history': 1,
173
+ 'account/margin': 1,
164
174
  'account/profile': 1,
175
+ 'account/subaccounts': 1,
165
176
  'balance': 1,
166
177
  'fills': 1,
167
178
  'funding/payments': 1,
@@ -174,20 +185,34 @@ class paradex extends paradex$1 {
174
185
  'orders/by_client_id/{client_id}': 1,
175
186
  'orders/{order_id}': 1,
176
187
  'points_data/{market}/{program}': 1,
188
+ 'referrals/qr-code': 1,
177
189
  'referrals/summary': 1,
178
190
  'transfers': 1,
191
+ 'algo/orders': 1,
192
+ 'algo/orders-history': 1,
193
+ 'algo/orders/{algo_id}': 1,
194
+ 'vaults/account-summary': 1,
179
195
  },
180
196
  'post': {
197
+ 'account/margin/{market}': 1,
198
+ 'account/profile/max_slippage': 1,
181
199
  'account/profile/referral_code': 1,
182
200
  'account/profile/username': 1,
183
201
  'auth': 1,
184
202
  'onboarding': 1,
185
203
  'orders': 1,
204
+ 'orders/batch': 1,
205
+ 'algo/orders': 1,
206
+ 'vaults': 1,
207
+ },
208
+ 'put': {
209
+ 'orders/{order_id}': 1,
186
210
  },
187
211
  'delete': {
188
212
  'orders': 1,
189
213
  'orders/by_client_id/{client_id}': 1,
190
214
  'orders/{order_id}': 1,
215
+ 'algo/orders/{algo_id}': 1,
191
216
  },
192
217
  },
193
218
  },
@@ -2126,6 +2151,149 @@ class paradex extends paradex$1 {
2126
2151
  };
2127
2152
  return this.safeString(statuses, status, status);
2128
2153
  }
2154
+ /**
2155
+ * @method
2156
+ * @name paradex#fetchMarginMode
2157
+ * @description fetches the margin mode of a specific symbol
2158
+ * @see https://docs.api.testnet.paradex.trade/#get-account-margin-configuration
2159
+ * @param {string} symbol unified symbol of the market the order was made in
2160
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2161
+ * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
2162
+ */
2163
+ async fetchMarginMode(symbol, params = {}) {
2164
+ await this.authenticateRest();
2165
+ await this.loadMarkets();
2166
+ const market = this.market(symbol);
2167
+ const request = {
2168
+ 'market': market['id'],
2169
+ };
2170
+ const response = await this.privateGetAccountMargin(this.extend(request, params));
2171
+ //
2172
+ // {
2173
+ // "account": "0x6343248026a845b39a8a73fbe9c7ef0a841db31ed5c61ec1446aa9d25e54dbc",
2174
+ // "configs": [
2175
+ // {
2176
+ // "market": "SOL-USD-PERP",
2177
+ // "leverage": 50,
2178
+ // "margin_type": "CROSS"
2179
+ // }
2180
+ // ]
2181
+ // }
2182
+ //
2183
+ const configs = this.safeList(response, 'configs');
2184
+ return this.parseMarginMode(this.safeDict(configs, 0), market);
2185
+ }
2186
+ parseMarginMode(rawMarginMode, market = undefined) {
2187
+ const marketId = this.safeString(rawMarginMode, 'market');
2188
+ market = this.safeMarket(marketId, market);
2189
+ const marginMode = this.safeStringLower(rawMarginMode, 'margin_type');
2190
+ return {
2191
+ 'info': rawMarginMode,
2192
+ 'symbol': market['symbol'],
2193
+ 'marginMode': marginMode,
2194
+ };
2195
+ }
2196
+ /**
2197
+ * @method
2198
+ * @name paradex#setMarginMode
2199
+ * @description set margin mode to 'cross' or 'isolated'
2200
+ * @see https://docs.api.testnet.paradex.trade/#set-margin-configuration
2201
+ * @param {string} marginMode 'cross' or 'isolated'
2202
+ * @param {string} symbol unified market symbol
2203
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2204
+ * @param {float} [params.leverage] the rate of leverage
2205
+ * @returns {object} response from the exchange
2206
+ */
2207
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
2208
+ this.checkRequiredArgument('setMarginMode', symbol, 'symbol');
2209
+ await this.authenticateRest();
2210
+ await this.loadMarkets();
2211
+ const market = this.market(symbol);
2212
+ let leverage = undefined;
2213
+ [leverage, params] = this.handleOptionAndParams(params, 'setMarginMode', 'leverage', 1);
2214
+ const request = {
2215
+ 'market': market['id'],
2216
+ 'leverage': leverage,
2217
+ 'margin_type': this.encodeMarginMode(marginMode),
2218
+ };
2219
+ return await this.privatePostAccountMarginMarket(this.extend(request, params));
2220
+ }
2221
+ /**
2222
+ * @method
2223
+ * @name paradex#fetchLeverage
2224
+ * @description fetch the set leverage for a market
2225
+ * @see https://docs.api.testnet.paradex.trade/#get-account-margin-configuration
2226
+ * @param {string} symbol unified market symbol
2227
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2228
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2229
+ */
2230
+ async fetchLeverage(symbol, params = {}) {
2231
+ await this.authenticateRest();
2232
+ await this.loadMarkets();
2233
+ const market = this.market(symbol);
2234
+ const request = {
2235
+ 'market': market['id'],
2236
+ };
2237
+ const response = await this.privateGetAccountMargin(this.extend(request, params));
2238
+ //
2239
+ // {
2240
+ // "account": "0x6343248026a845b39a8a73fbe9c7ef0a841db31ed5c61ec1446aa9d25e54dbc",
2241
+ // "configs": [
2242
+ // {
2243
+ // "market": "SOL-USD-PERP",
2244
+ // "leverage": 50,
2245
+ // "margin_type": "CROSS"
2246
+ // }
2247
+ // ]
2248
+ // }
2249
+ //
2250
+ const configs = this.safeList(response, 'configs');
2251
+ return this.parseLeverage(this.safeDict(configs, 0), market);
2252
+ }
2253
+ parseLeverage(leverage, market = undefined) {
2254
+ const marketId = this.safeString(leverage, 'market');
2255
+ market = this.safeMarket(marketId, market);
2256
+ const marginMode = this.safeStringLower(leverage, 'margin_type');
2257
+ return {
2258
+ 'info': leverage,
2259
+ 'symbol': this.safeSymbol(marketId, market),
2260
+ 'marginMode': marginMode,
2261
+ 'longLeverage': this.safeInteger(leverage, 'leverage'),
2262
+ 'shortLeverage': this.safeInteger(leverage, 'leverage'),
2263
+ };
2264
+ }
2265
+ encodeMarginMode(mode) {
2266
+ const modes = {
2267
+ 'cross': 'CROSS',
2268
+ 'isolated': 'ISOLATED',
2269
+ };
2270
+ return this.safeString(modes, mode, mode);
2271
+ }
2272
+ /**
2273
+ * @method
2274
+ * @name paradex#setLeverage
2275
+ * @description set the level of leverage for a market
2276
+ * @see https://docs.api.testnet.paradex.trade/#set-margin-configuration
2277
+ * @param {float} leverage the rate of leverage
2278
+ * @param {string} [symbol] unified market symbol (is mandatory for swap markets)
2279
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2280
+ * @param {string} [params.marginMode] 'cross' or 'isolated'
2281
+ * @returns {object} response from the exchange
2282
+ */
2283
+ async setLeverage(leverage, symbol = undefined, params = {}) {
2284
+ this.checkRequiredArgument('setLeverage', symbol, 'symbol');
2285
+ await this.authenticateRest();
2286
+ await this.loadMarkets();
2287
+ const market = this.market(symbol);
2288
+ let marginMode = undefined;
2289
+ [marginMode, params] = this.handleMarginModeAndParams('setLeverage', params, 'cross');
2290
+ const request = {
2291
+ 'market': market['id'],
2292
+ 'leverage': leverage,
2293
+ 'margin_type': this.encodeMarginMode(marginMode),
2294
+ };
2295
+ return await this.privatePostAccountMarginMarket(this.extend(request, params));
2296
+ }
2129
2297
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2130
2298
  let url = this.implodeHostname(this.urls['api'][this.version]) + '/' + this.implodeParams(path, params);
2131
2299
  const query = this.omit(params, this.extractParams(path));
@@ -3801,7 +3801,7 @@ class phemex extends phemex$1 {
3801
3801
  * @see https://phemex-docs.github.io/#query-account-positions-with-unrealized-pnl
3802
3802
  * @param {string[]} [symbols] list of unified market symbols
3803
3803
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3804
- * @param {string} [params.code] the currency code to fetch positions for, USD, BTC or USDT, USD is the default
3804
+ * @param {string} [params.code] the currency code to fetch positions for, USD, BTC or USDT, USDT is the default
3805
3805
  * @param {string} [params.method] *USDT contracts only* 'privateGetGAccountsAccountPositions' or 'privateGetAccountsPositions' default is 'privateGetGAccountsAccountPositions'
3806
3806
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3807
3807
  */
@@ -3809,7 +3809,7 @@ class phemex extends phemex$1 {
3809
3809
  await this.loadMarkets();
3810
3810
  symbols = this.marketSymbols(symbols);
3811
3811
  let subType = undefined;
3812
- let code = this.safeString2(params, 'currency', 'code', 'USD');
3812
+ let code = this.safeString2(params, 'currency', 'code', 'USDT');
3813
3813
  params = this.omit(params, ['currency', 'code']);
3814
3814
  let settle = undefined;
3815
3815
  let market = undefined;
@@ -45,6 +45,10 @@ class bitget extends bitget$1 {
45
45
  'public': 'wss://ws.bitget.com/v2/ws/public',
46
46
  'private': 'wss://ws.bitget.com/v2/ws/private',
47
47
  },
48
+ 'demo': {
49
+ 'public': 'wss://wspap.bitget.com/v2/ws/public',
50
+ 'private': 'wss://wspap.bitget.com/v2/ws/private',
51
+ },
48
52
  },
49
53
  },
50
54
  'options': {
@@ -1165,7 +1169,7 @@ class bitget extends bitget$1 {
1165
1169
  else {
1166
1170
  [instType, params] = this.getInstType(market, params);
1167
1171
  }
1168
- if (type === 'spot') {
1172
+ if (type === 'spot' && (symbol !== undefined)) {
1169
1173
  subscriptionHash = subscriptionHash + ':' + symbol;
1170
1174
  }
1171
1175
  if (isTrigger) {
@@ -1779,7 +1783,14 @@ class bitget extends bitget$1 {
1779
1783
  client.resolve(this.balance, messageHash);
1780
1784
  }
1781
1785
  async watchPublic(messageHash, args, params = {}) {
1782
- const url = this.urls['api']['ws']['public'];
1786
+ let url = this.urls['api']['ws']['public'];
1787
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1788
+ if (sandboxMode) {
1789
+ const instType = this.safeString(args, 'instType');
1790
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1791
+ url = this.urls['api']['demo']['public'];
1792
+ }
1793
+ }
1783
1794
  const request = {
1784
1795
  'op': 'subscribe',
1785
1796
  'args': [args],
@@ -1788,7 +1799,14 @@ class bitget extends bitget$1 {
1788
1799
  return await this.watch(url, messageHash, message, messageHash);
1789
1800
  }
1790
1801
  async unWatchPublic(messageHash, args, params = {}) {
1791
- const url = this.urls['api']['ws']['public'];
1802
+ let url = this.urls['api']['ws']['public'];
1803
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1804
+ if (sandboxMode) {
1805
+ const instType = this.safeString(args, 'instType');
1806
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1807
+ url = this.urls['api']['demo']['public'];
1808
+ }
1809
+ }
1792
1810
  const request = {
1793
1811
  'op': 'unsubscribe',
1794
1812
  'args': [args],
@@ -1797,7 +1815,15 @@ class bitget extends bitget$1 {
1797
1815
  return await this.watch(url, messageHash, message, messageHash);
1798
1816
  }
1799
1817
  async watchPublicMultiple(messageHashes, argsArray, params = {}) {
1800
- const url = this.urls['api']['ws']['public'];
1818
+ let url = this.urls['api']['ws']['public'];
1819
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1820
+ if (sandboxMode) {
1821
+ const argsArrayFirst = this.safeDict(argsArray, 0, {});
1822
+ const instType = this.safeString(argsArrayFirst, 'instType');
1823
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1824
+ url = this.urls['api']['demo']['public'];
1825
+ }
1826
+ }
1801
1827
  const request = {
1802
1828
  'op': 'subscribe',
1803
1829
  'args': argsArray,
@@ -1807,7 +1833,7 @@ class bitget extends bitget$1 {
1807
1833
  }
1808
1834
  async authenticate(params = {}) {
1809
1835
  this.checkRequiredCredentials();
1810
- const url = this.urls['api']['ws']['private'];
1836
+ const url = this.safeString(params, 'url');
1811
1837
  const client = this.client(url);
1812
1838
  const messageHash = 'authenticated';
1813
1839
  const future = client.future(messageHash);
@@ -1834,8 +1860,15 @@ class bitget extends bitget$1 {
1834
1860
  return await future;
1835
1861
  }
1836
1862
  async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
1837
- await this.authenticate();
1838
- const url = this.urls['api']['ws']['private'];
1863
+ let url = this.urls['api']['ws']['private'];
1864
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1865
+ if (sandboxMode) {
1866
+ const instType = this.safeString(args, 'instType');
1867
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1868
+ url = this.urls['api']['demo']['private'];
1869
+ }
1870
+ }
1871
+ await this.authenticate({ 'url': url });
1839
1872
  const request = {
1840
1873
  'op': 'subscribe',
1841
1874
  'args': [args],
@@ -1563,6 +1563,7 @@ class bybit extends bybit$1 {
1563
1563
  * @param {int} [since] the earliest time in ms to fetch liquidations for
1564
1564
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
1565
1565
  * @param {object} [params] exchange specific parameters for the bitmex api endpoint
1566
+ * @param {string} [params.method] exchange specific method, supported: liquidation, allLiquidation
1566
1567
  * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
1567
1568
  */
1568
1569
  async watchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
@@ -1571,8 +1572,10 @@ class bybit extends bybit$1 {
1571
1572
  symbol = market['symbol'];
1572
1573
  const url = await this.getUrlByMarketType(symbol, false, 'watchLiquidations', params);
1573
1574
  params = this.cleanParams(params);
1575
+ let method = undefined;
1576
+ [method, params] = this.handleOptionAndParams(params, 'watchLiquidations', 'method', 'liquidation');
1574
1577
  const messageHash = 'liquidations::' + symbol;
1575
- const topic = 'liquidation.' + market['id'];
1578
+ const topic = method + '.' + market['id'];
1576
1579
  const newLiquidation = await this.watchTopics(url, [messageHash], [topic], params);
1577
1580
  if (this.newUpdates) {
1578
1581
  return newLiquidation;
@@ -1581,53 +1584,97 @@ class bybit extends bybit$1 {
1581
1584
  }
1582
1585
  handleLiquidation(client, message) {
1583
1586
  //
1584
- // {
1585
- // "data": {
1586
- // "price": "0.03803",
1587
- // "side": "Buy",
1588
- // "size": "1637",
1589
- // "symbol": "GALAUSDT",
1590
- // "updatedTime": 1673251091822
1591
- // },
1592
- // "topic": "liquidation.GALAUSDT",
1593
- // "ts": 1673251091822,
1594
- // "type": "snapshot"
1595
- // }
1587
+ // {
1588
+ // "data": {
1589
+ // "price": "0.03803",
1590
+ // "side": "Buy",
1591
+ // "size": "1637",
1592
+ // "symbol": "GALAUSDT",
1593
+ // "updatedTime": 1673251091822
1594
+ // },
1595
+ // "topic": "liquidation.GALAUSDT",
1596
+ // "ts": 1673251091822,
1597
+ // "type": "snapshot"
1598
+ // }
1596
1599
  //
1597
- const rawLiquidation = this.safeDict(message, 'data', {});
1598
- const marketId = this.safeString(rawLiquidation, 'symbol');
1599
- const market = this.safeMarket(marketId, undefined, '', 'contract');
1600
- const symbol = market['symbol'];
1601
- const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1602
- let liquidations = this.safeValue(this.liquidations, symbol);
1603
- if (liquidations === undefined) {
1604
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1605
- liquidations = new Cache.ArrayCache(limit);
1606
- }
1607
- liquidations.append(liquidation);
1608
- this.liquidations[symbol] = liquidations;
1609
- client.resolve([liquidation], 'liquidations');
1610
- client.resolve([liquidation], 'liquidations::' + symbol);
1600
+ // {
1601
+ // "topic": "allLiquidation.ROSEUSDT",
1602
+ // "type": "snapshot",
1603
+ // "ts": 1739502303204,
1604
+ // "data": [
1605
+ // {
1606
+ // "T": 1739502302929,
1607
+ // "s": "ROSEUSDT",
1608
+ // "S": "Sell",
1609
+ // "v": "20000",
1610
+ // "p": "0.04499"
1611
+ // }
1612
+ // ]
1613
+ // }
1614
+ //
1615
+ if (Array.isArray(message['data'])) {
1616
+ const rawLiquidations = this.safeList(message, 'data', []);
1617
+ for (let i = 0; i < rawLiquidations.length; i++) {
1618
+ const rawLiquidation = rawLiquidations[i];
1619
+ const marketId = this.safeString(rawLiquidation, 's');
1620
+ const market = this.safeMarket(marketId, undefined, '', 'contract');
1621
+ const symbol = market['symbol'];
1622
+ const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1623
+ let liquidations = this.safeValue(this.liquidations, symbol);
1624
+ if (liquidations === undefined) {
1625
+ const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1626
+ liquidations = new Cache.ArrayCache(limit);
1627
+ }
1628
+ liquidations.append(liquidation);
1629
+ this.liquidations[symbol] = liquidations;
1630
+ client.resolve([liquidation], 'liquidations');
1631
+ client.resolve([liquidation], 'liquidations::' + symbol);
1632
+ }
1633
+ }
1634
+ else {
1635
+ const rawLiquidation = this.safeDict(message, 'data', {});
1636
+ const marketId = this.safeString(rawLiquidation, 'symbol');
1637
+ const market = this.safeMarket(marketId, undefined, '', 'contract');
1638
+ const symbol = market['symbol'];
1639
+ const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1640
+ let liquidations = this.safeValue(this.liquidations, symbol);
1641
+ if (liquidations === undefined) {
1642
+ const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1643
+ liquidations = new Cache.ArrayCache(limit);
1644
+ }
1645
+ liquidations.append(liquidation);
1646
+ this.liquidations[symbol] = liquidations;
1647
+ client.resolve([liquidation], 'liquidations');
1648
+ client.resolve([liquidation], 'liquidations::' + symbol);
1649
+ }
1611
1650
  }
1612
1651
  parseWsLiquidation(liquidation, market = undefined) {
1613
1652
  //
1614
- // {
1615
- // "price": "0.03803",
1616
- // "side": "Buy",
1617
- // "size": "1637",
1618
- // "symbol": "GALAUSDT",
1619
- // "updatedTime": 1673251091822
1620
- // }
1653
+ // {
1654
+ // "price": "0.03803",
1655
+ // "side": "Buy",
1656
+ // "size": "1637",
1657
+ // "symbol": "GALAUSDT",
1658
+ // "updatedTime": 1673251091822
1659
+ // }
1660
+ //
1661
+ // {
1662
+ // "T": 1739502302929,
1663
+ // "s": "ROSEUSDT",
1664
+ // "S": "Sell",
1665
+ // "v": "20000",
1666
+ // "p": "0.04499"
1667
+ // }
1621
1668
  //
1622
- const marketId = this.safeString(liquidation, 'symbol');
1669
+ const marketId = this.safeString2(liquidation, 'symbol', 's');
1623
1670
  market = this.safeMarket(marketId, market, '', 'contract');
1624
- const timestamp = this.safeInteger(liquidation, 'updatedTime');
1671
+ const timestamp = this.safeInteger2(liquidation, 'updatedTime', 'T');
1625
1672
  return this.safeLiquidation({
1626
1673
  'info': liquidation,
1627
1674
  'symbol': market['symbol'],
1628
- 'contracts': this.safeNumber(liquidation, 'size'),
1675
+ 'contracts': this.safeNumber2(liquidation, 'size', 'v'),
1629
1676
  'contractSize': this.safeNumber(market, 'contractSize'),
1630
- 'price': this.safeNumber(liquidation, 'price'),
1677
+ 'price': this.safeNumber2(liquidation, 'price', 'p'),
1631
1678
  'baseValue': undefined,
1632
1679
  'quoteValue': undefined,
1633
1680
  'timestamp': timestamp,
@@ -2441,6 +2488,7 @@ class bybit extends bybit$1 {
2441
2488
  'user.openapi.perp.trade': this.handleMyTrades,
2442
2489
  'position': this.handlePositions,
2443
2490
  'liquidation': this.handleLiquidation,
2491
+ 'allLiquidation': this.handleLiquidation,
2444
2492
  'pong': this.handlePong,
2445
2493
  'order.create': this.handleOrderWs,
2446
2494
  'order.amend': this.handleOrderWs,
@@ -128,12 +128,12 @@ class tradeogre extends tradeogre$1 {
128
128
  'orders/{market}': 1,
129
129
  'ticker/{market}': 1,
130
130
  'history/{market}': 1,
131
+ 'chart/{interval}/{market}/{timestamp}': 1,
131
132
  'chart/{interval}/{market}': 1,
132
133
  },
133
134
  },
134
135
  'private': {
135
136
  'get': {
136
- 'account/balance': 1,
137
137
  'account/balances': 1,
138
138
  'account/order/{uuid}': 1,
139
139
  },
@@ -143,6 +143,7 @@ class tradeogre extends tradeogre$1 {
143
143
  'order/cancel': 1,
144
144
  'orders': 1,
145
145
  'account/orders': 1,
146
+ 'account/balance': 1,
146
147
  },
147
148
  },
148
149
  },
@@ -420,15 +421,15 @@ class tradeogre extends tradeogre$1 {
420
421
  'ask': this.safeString(ticker, 'ask'),
421
422
  'askVolume': undefined,
422
423
  'vwap': undefined,
423
- 'open': this.safeString(ticker, 'open'),
424
- 'close': undefined,
424
+ 'open': this.safeString(ticker, 'initialprice'),
425
+ 'close': this.safeString(ticker, 'price'),
425
426
  'last': undefined,
426
427
  'previousClose': undefined,
427
428
  'change': undefined,
428
429
  'percentage': undefined,
429
430
  'average': undefined,
430
- 'baseVolume': this.safeString(ticker, 'volume'),
431
- 'quoteVolume': undefined,
431
+ 'baseVolume': undefined,
432
+ 'quoteVolume': this.safeString(ticker, 'volume'),
432
433
  'info': ticker,
433
434
  }, market);
434
435
  }
@@ -451,12 +452,16 @@ class tradeogre extends tradeogre$1 {
451
452
  'market': market['id'],
452
453
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
453
454
  };
455
+ let response = undefined;
454
456
  const until = this.safeInteger(params, 'until');
455
457
  if (until !== undefined) {
456
458
  params = this.omit(params, 'until');
457
- request['timestamp'] = until;
459
+ request['timestamp'] = this.parseToInt(until / 1000);
460
+ response = await this.publicGetChartIntervalMarketTimestamp(this.extend(request, params));
461
+ }
462
+ else {
463
+ response = await this.publicGetChartIntervalMarket(this.extend(request, params));
458
464
  }
459
- const response = await this.publicGetChartIntervalMarket(this.extend(request, params));
460
465
  //
461
466
  // [
462
467
  // [
@@ -485,9 +490,9 @@ class tradeogre extends tradeogre$1 {
485
490
  return [
486
491
  this.safeTimestamp(ohlcv, 0),
487
492
  this.safeNumber(ohlcv, 1),
493
+ this.safeNumber(ohlcv, 2),
488
494
  this.safeNumber(ohlcv, 3),
489
495
  this.safeNumber(ohlcv, 4),
490
- this.safeNumber(ohlcv, 2),
491
496
  this.safeNumber(ohlcv, 5),
492
497
  ];
493
498
  }
@@ -591,11 +596,29 @@ class tradeogre extends tradeogre$1 {
591
596
  * @name tradeogre#fetchBalance
592
597
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
593
598
  * @param {object} [params] extra parameters specific to the exchange API endpoint
599
+ * @param {string} [params.currency] currency to fetch the balance for
594
600
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
595
601
  */
596
602
  async fetchBalance(params = {}) {
597
603
  await this.loadMarkets();
598
- const response = await this.privateGetAccountBalances(params);
604
+ let response = undefined;
605
+ const currency = this.safeString(params, 'currency');
606
+ if (currency !== undefined) {
607
+ response = await this.privatePostAccountBalance(params);
608
+ const singleCurrencyresult = {
609
+ 'info': response,
610
+ };
611
+ const code = this.safeCurrencyCode(currency);
612
+ const account = {
613
+ 'total': this.safeNumber(response, 'balance'),
614
+ 'free': this.safeNumber(response, 'available'),
615
+ };
616
+ singleCurrencyresult[code] = account;
617
+ return this.safeBalance(singleCurrencyresult);
618
+ }
619
+ else {
620
+ response = await this.privateGetAccountBalances(params);
621
+ }
599
622
  const result = this.safeDict(response, 'balances', {});
600
623
  return this.parseBalance(result);
601
624
  }
@@ -759,11 +782,11 @@ class tradeogre extends tradeogre$1 {
759
782
  'side': this.safeString(order, 'type'),
760
783
  'price': this.safeString(order, 'price'),
761
784
  'triggerPrice': undefined,
762
- 'amount': this.safeString(order, 'quantity'),
785
+ 'amount': undefined,
763
786
  'cost': undefined,
764
787
  'average': undefined,
765
788
  'filled': this.safeString(order, 'fulfilled'),
766
- 'remaining': undefined,
789
+ 'remaining': this.safeString(order, 'quantity'),
767
790
  'status': undefined,
768
791
  'fee': {
769
792
  'currency': undefined,