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