ccxt 4.4.69 → 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.
package/js/src/bybit.js CHANGED
@@ -246,6 +246,8 @@ export default class bybit extends Exchange {
246
246
  // institutional lending
247
247
  'v5/ins-loan/product-infos': 5,
248
248
  'v5/ins-loan/ensure-tokens-convert': 5,
249
+ // earn
250
+ 'v5/earn/product': 5,
249
251
  },
250
252
  },
251
253
  'private': {
@@ -404,6 +406,9 @@ export default class bybit extends Exchange {
404
406
  'v5/broker/earnings-info': 5,
405
407
  'v5/broker/account-info': 5,
406
408
  'v5/broker/asset/query-sub-member-deposit-record': 10,
409
+ // earn
410
+ 'v5/earn/order': 5,
411
+ 'v5/earn/position': 5,
407
412
  },
408
413
  'post': {
409
414
  // spot
@@ -539,6 +544,8 @@ export default class bybit extends Exchange {
539
544
  'v5/broker/award/info': 5,
540
545
  'v5/broker/award/distribute-award': 5,
541
546
  'v5/broker/award/distribution-record': 5,
547
+ // earn
548
+ 'v5/earn/place-order': 5,
542
549
  },
543
550
  },
544
551
  },
@@ -322,6 +322,7 @@ export default class coinbase extends Exchange {
322
322
  'INSUFFICIENT_FUND': BadRequest,
323
323
  'PERMISSION_DENIED': PermissionDenied,
324
324
  'INVALID_ARGUMENT': BadRequest,
325
+ 'PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE': InvalidOrder,
325
326
  },
326
327
  'broad': {
327
328
  'request timestamp expired': InvalidNonce,
@@ -5080,20 +5081,39 @@ export default class coinbase extends Exchange {
5080
5081
  // ]
5081
5082
  // }
5082
5083
  // or
5083
- // {
5084
+ // {
5085
+ // "success": false,
5086
+ // "error_response": {
5084
5087
  // "error": "UNKNOWN_FAILURE_REASON",
5085
5088
  // "message": "",
5086
5089
  // "error_details": "",
5087
- // "preview_failure_reason": "PREVIEW_STOP_PRICE_BELOW_LAST_TRADE_PRICE"
5088
- // }
5090
+ // "preview_failure_reason": "PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE"
5091
+ // },
5092
+ // "order_configuration": {
5093
+ // "stop_limit_stop_limit_gtc": {
5094
+ // "base_size": "0.0001",
5095
+ // "limit_price": "2000",
5096
+ // "stop_price": "2005",
5097
+ // "stop_direction": "STOP_DIRECTION_STOP_DOWN",
5098
+ // "reduce_only": false
5099
+ // }
5100
+ // }
5101
+ // }
5089
5102
  //
5090
5103
  let errorCode = this.safeString(response, 'error');
5091
5104
  if (errorCode !== undefined) {
5092
- const errorMessage = this.safeString2(response, 'error_description', 'preview_failure_reason');
5105
+ const errorMessage = this.safeString2(response, 'error_description', 'error');
5093
5106
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
5094
5107
  this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
5095
5108
  throw new ExchangeError(feedback);
5096
5109
  }
5110
+ const errorResponse = this.safeDict(response, 'error_response');
5111
+ if (errorResponse !== undefined) {
5112
+ const errorMessageInner = this.safeString2(errorResponse, 'preview_failure_reason', 'preview_failure_reason');
5113
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorMessageInner, feedback);
5114
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessageInner, feedback);
5115
+ throw new ExchangeError(feedback);
5116
+ }
5097
5117
  const errors = this.safeList(response, 'errors');
5098
5118
  if (errors !== undefined) {
5099
5119
  if (Array.isArray(errors)) {
@@ -1807,12 +1807,13 @@ export default class hyperliquid extends Exchange {
1807
1807
  const isTrigger = (stopLossPrice || takeProfitPrice);
1808
1808
  const reduceOnly = this.safeBool(orderParams, 'reduceOnly', false);
1809
1809
  orderParams = this.omit(orderParams, ['slippage', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'clientOrderId', 'client_id', 'postOnly', 'reduceOnly']);
1810
- let px = price.toString();
1810
+ let px = this.numberToString(price);
1811
1811
  if (isMarket) {
1812
- px = (isBuy) ? Precise.stringMul(price.toString(), Precise.stringAdd('1', slippage)) : Precise.stringMul(price.toString(), Precise.stringSub('1', slippage));
1812
+ px = (isBuy) ? Precise.stringMul(px, Precise.stringAdd('1', slippage)) : Precise.stringMul(px, Precise.stringSub('1', slippage));
1813
+ px = this.priceToPrecision(symbol, px);
1813
1814
  }
1814
1815
  else {
1815
- px = this.priceToPrecision(symbol, price.toString());
1816
+ px = this.priceToPrecision(symbol, px);
1816
1817
  }
1817
1818
  const sz = this.amountToPrecision(symbol, amount);
1818
1819
  const orderType = {};
@@ -2324,6 +2325,11 @@ export default class hyperliquid extends Exchange {
2324
2325
  }
2325
2326
  const totalAmount = this.safeString2(entry, 'origSz', 'totalSz');
2326
2327
  const remaining = this.safeString(entry, 'sz');
2328
+ const tif = this.safeStringUpper(entry, 'tif');
2329
+ let postOnly = undefined;
2330
+ if (tif !== undefined) {
2331
+ postOnly = (tif === 'ALO');
2332
+ }
2327
2333
  return this.safeOrder({
2328
2334
  'info': order,
2329
2335
  'id': this.safeString(entry, 'oid'),
@@ -2334,8 +2340,8 @@ export default class hyperliquid extends Exchange {
2334
2340
  'lastUpdateTimestamp': this.safeInteger(order, 'statusTimestamp'),
2335
2341
  'symbol': symbol,
2336
2342
  'type': this.parseOrderType(this.safeStringLower(entry, 'orderType')),
2337
- 'timeInForce': this.safeStringUpper(entry, 'tif'),
2338
- 'postOnly': undefined,
2343
+ 'timeInForce': tif,
2344
+ 'postOnly': postOnly,
2339
2345
  'reduceOnly': this.safeBool(entry, 'reduceOnly'),
2340
2346
  'side': side,
2341
2347
  'price': this.safeString(entry, 'limitPx'),
@@ -2457,6 +2463,11 @@ export default class hyperliquid extends Exchange {
2457
2463
  side = (side === 'A') ? 'sell' : 'buy';
2458
2464
  }
2459
2465
  const fee = this.safeString(trade, 'fee');
2466
+ let takerOrMaker = undefined;
2467
+ const crossed = this.safeBool(trade, 'crossed');
2468
+ if (crossed !== undefined) {
2469
+ takerOrMaker = crossed ? 'taker' : 'maker';
2470
+ }
2460
2471
  return this.safeTrade({
2461
2472
  'info': trade,
2462
2473
  'timestamp': timestamp,
@@ -2466,7 +2477,7 @@ export default class hyperliquid extends Exchange {
2466
2477
  'order': this.safeString(trade, 'oid'),
2467
2478
  'type': undefined,
2468
2479
  'side': side,
2469
- 'takerOrMaker': undefined,
2480
+ 'takerOrMaker': takerOrMaker,
2470
2481
  'price': price,
2471
2482
  'amount': amount,
2472
2483
  'cost': undefined,
@@ -3040,7 +3051,7 @@ export default class hyperliquid extends Exchange {
3040
3051
  'tagTo': undefined,
3041
3052
  'tagFrom': undefined,
3042
3053
  'type': undefined,
3043
- 'amount': this.safeInteger(delta, 'usdc'),
3054
+ 'amount': this.safeNumber(delta, 'usdc'),
3044
3055
  'currency': undefined,
3045
3056
  'status': this.safeString(transaction, 'status'),
3046
3057
  'updated': undefined,
package/js/src/okx.d.ts CHANGED
@@ -237,6 +237,7 @@ export default class okx extends Exchange {
237
237
  * @param {string} [params.trailingPercent] the percent to trail away from the current market price
238
238
  * @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
239
239
  * @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode
240
+ * @param {string} [params.marginMode] 'cross' or 'isolated', the default is 'cross'
240
241
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
241
242
  */
242
243
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
package/js/src/okx.js CHANGED
@@ -304,7 +304,9 @@ export default class okx extends Exchange {
304
304
  'trade/easy-convert-currency-list': 20,
305
305
  'trade/easy-convert-history': 20,
306
306
  'trade/one-click-repay-currency-list': 20,
307
+ 'trade/one-click-repay-currency-list-v2': 20,
307
308
  'trade/one-click-repay-history': 20,
309
+ 'trade/one-click-repay-history-v2': 20,
308
310
  'trade/account-rate-limit': 1,
309
311
  // asset
310
312
  'asset/currencies': 5 / 3,
@@ -461,6 +463,7 @@ export default class okx extends Exchange {
461
463
  'trade/cancel-advance-algos': 1,
462
464
  'trade/easy-convert': 20,
463
465
  'trade/one-click-repay': 20,
466
+ 'trade/one-click-repay-v2': 20,
464
467
  'trade/mass-cancel': 4,
465
468
  'trade/cancel-all-after': 10,
466
469
  // asset
@@ -3156,6 +3159,7 @@ export default class okx extends Exchange {
3156
3159
  * @param {string} [params.trailingPercent] the percent to trail away from the current market price
3157
3160
  * @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
3158
3161
  * @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode
3162
+ * @param {string} [params.marginMode] 'cross' or 'isolated', the default is 'cross'
3159
3163
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3160
3164
  */
3161
3165
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -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>;
@@ -131,7 +131,6 @@ export default class tradeogre extends Exchange {
131
131
  },
132
132
  'private': {
133
133
  'get': {
134
- 'account/balance': 1,
135
134
  'account/balances': 1,
136
135
  'account/order/{uuid}': 1,
137
136
  },
@@ -141,6 +140,7 @@ export default class tradeogre extends Exchange {
141
140
  'order/cancel': 1,
142
141
  'orders': 1,
143
142
  'account/orders': 1,
143
+ 'account/balance': 1,
144
144
  },
145
145
  },
146
146
  },
@@ -593,11 +593,29 @@ export default class tradeogre extends Exchange {
593
593
  * @name tradeogre#fetchBalance
594
594
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
595
595
  * @param {object} [params] extra parameters specific to the exchange API endpoint
596
+ * @param {string} [params.currency] currency to fetch the balance for
596
597
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
597
598
  */
598
599
  async fetchBalance(params = {}) {
599
600
  await this.loadMarkets();
600
- 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
+ }
601
619
  const result = this.safeDict(response, 'balances', {});
602
620
  return this.parseBalance(result);
603
621
  }
@@ -761,11 +779,11 @@ export default class tradeogre extends Exchange {
761
779
  'side': this.safeString(order, 'type'),
762
780
  'price': this.safeString(order, 'price'),
763
781
  'triggerPrice': undefined,
764
- 'amount': this.safeString(order, 'quantity'),
782
+ 'amount': undefined,
765
783
  'cost': undefined,
766
784
  'average': undefined,
767
785
  'filled': this.safeString(order, 'fulfilled'),
768
- 'remaining': undefined,
786
+ 'remaining': this.safeString(order, 'quantity'),
769
787
  'status': undefined,
770
788
  'fee': {
771
789
  'currency': undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.69",
3
+ "version": "4.4.70",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",