ccxt 4.4.37 → 4.4.39

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 (52) 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/alpaca.js +73 -2
  5. package/dist/cjs/src/base/Exchange.js +31 -10
  6. package/dist/cjs/src/binance.js +0 -2
  7. package/dist/cjs/src/bingx.js +93 -8
  8. package/dist/cjs/src/bitget.js +0 -2
  9. package/dist/cjs/src/bithumb.js +1 -1
  10. package/dist/cjs/src/bitmart.js +163 -15
  11. package/dist/cjs/src/bybit.js +3 -2
  12. package/dist/cjs/src/digifinex.js +58 -18
  13. package/dist/cjs/src/htx.js +154 -32
  14. package/dist/cjs/src/kucoin.js +77 -2
  15. package/dist/cjs/src/kucoinfutures.js +93 -5
  16. package/dist/cjs/src/mexc.js +36 -25
  17. package/dist/cjs/src/ndax.js +7 -2
  18. package/dist/cjs/src/okx.js +1 -1
  19. package/dist/cjs/src/pro/woo.js +1 -1
  20. package/dist/cjs/src/probit.js +3 -1
  21. package/dist/cjs/src/woo.js +4 -4
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/bingx.d.ts +0 -1
  25. package/js/src/abstract/digifinex.d.ts +1 -0
  26. package/js/src/abstract/mexc.d.ts +1 -0
  27. package/js/src/alpaca.d.ts +11 -1
  28. package/js/src/alpaca.js +73 -2
  29. package/js/src/base/Exchange.js +31 -10
  30. package/js/src/binance.js +0 -2
  31. package/js/src/bingx.d.ts +14 -1
  32. package/js/src/bingx.js +93 -8
  33. package/js/src/bitget.js +0 -2
  34. package/js/src/bithumb.js +1 -1
  35. package/js/src/bitmart.js +163 -15
  36. package/js/src/bybit.js +3 -2
  37. package/js/src/digifinex.d.ts +4 -2
  38. package/js/src/digifinex.js +58 -18
  39. package/js/src/htx.d.ts +5 -5
  40. package/js/src/htx.js +154 -32
  41. package/js/src/kucoin.js +77 -2
  42. package/js/src/kucoinfutures.js +93 -5
  43. package/js/src/mexc.d.ts +7 -7
  44. package/js/src/mexc.js +36 -25
  45. package/js/src/ndax.d.ts +2 -0
  46. package/js/src/ndax.js +7 -2
  47. package/js/src/okx.d.ts +1 -0
  48. package/js/src/okx.js +1 -1
  49. package/js/src/pro/woo.js +1 -1
  50. package/js/src/probit.js +3 -1
  51. package/js/src/woo.js +4 -4
  52. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -200,7 +200,7 @@ var xt$1 = require('./src/pro/xt.js');
200
200
 
201
201
  //-----------------------------------------------------------------------------
202
202
  // this is updated by vss.js when building
203
- const version = '4.4.37';
203
+ const version = '4.4.39';
204
204
  Exchange["default"].ccxtVersion = version;
205
205
  const exchanges = {
206
206
  'ace': ace,
@@ -34,7 +34,7 @@ class alpaca extends alpaca$1 {
34
34
  'test': {
35
35
  'broker': 'https://broker-api.sandbox.{hostname}',
36
36
  'trader': 'https://paper-api.{hostname}',
37
- 'market': 'https://data.sandbox.{hostname}',
37
+ 'market': 'https://data.{hostname}',
38
38
  },
39
39
  'doc': 'https://alpaca.markets/docs/',
40
40
  'fees': 'https://docs.alpaca.markets/docs/crypto-fees',
@@ -54,7 +54,7 @@ class alpaca extends alpaca$1 {
54
54
  'createStopOrder': true,
55
55
  'createTriggerOrder': true,
56
56
  'editOrder': true,
57
- 'fetchBalance': false,
57
+ 'fetchBalance': true,
58
58
  'fetchBidsAsks': false,
59
59
  'fetchClosedOrders': true,
60
60
  'fetchCurrencies': false,
@@ -1586,6 +1586,77 @@ class alpaca extends alpaca$1 {
1586
1586
  };
1587
1587
  return this.safeString(types, type, type);
1588
1588
  }
1589
+ /**
1590
+ * @method
1591
+ * @name alpaca#fetchBalance
1592
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1593
+ * @see https://docs.alpaca.markets/reference/getaccount-1
1594
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1595
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1596
+ */
1597
+ async fetchBalance(params = {}) {
1598
+ await this.loadMarkets();
1599
+ const response = await this.traderPrivateGetV2Account(params);
1600
+ //
1601
+ // {
1602
+ // "id": "43a01bde-4eb1-64fssc26adb5",
1603
+ // "admin_configurations": {
1604
+ // "allow_instant_ach": true,
1605
+ // "max_margin_multiplier": "4"
1606
+ // },
1607
+ // "user_configurations": {
1608
+ // "fractional_trading": true,
1609
+ // "max_margin_multiplier": "4"
1610
+ // },
1611
+ // "account_number": "744873727",
1612
+ // "status": "ACTIVE",
1613
+ // "crypto_status": "ACTIVE",
1614
+ // "currency": "USD",
1615
+ // "buying_power": "5.92",
1616
+ // "regt_buying_power": "5.92",
1617
+ // "daytrading_buying_power": "0",
1618
+ // "effective_buying_power": "5.92",
1619
+ // "non_marginable_buying_power": "5.92",
1620
+ // "bod_dtbp": "0",
1621
+ // "cash": "5.92",
1622
+ // "accrued_fees": "0",
1623
+ // "portfolio_value": "48.6",
1624
+ // "pattern_day_trader": false,
1625
+ // "trading_blocked": false,
1626
+ // "transfers_blocked": false,
1627
+ // "account_blocked": false,
1628
+ // "created_at": "2022-06-13T14:59:18.318096Z",
1629
+ // "trade_suspended_by_user": false,
1630
+ // "multiplier": "1",
1631
+ // "shorting_enabled": false,
1632
+ // "equity": "48.6",
1633
+ // "last_equity": "48.8014266",
1634
+ // "long_market_value": "42.68",
1635
+ // "short_market_value": "0",
1636
+ // "position_market_value": "42.68",
1637
+ // "initial_margin": "0",
1638
+ // "maintenance_margin": "0",
1639
+ // "last_maintenance_margin": "0",
1640
+ // "sma": "5.92",
1641
+ // "daytrade_count": 0,
1642
+ // "balance_asof": "2024-12-10",
1643
+ // "crypto_tier": 1,
1644
+ // "intraday_adjustments": "0",
1645
+ // "pending_reg_taf_fees": "0"
1646
+ // }
1647
+ //
1648
+ return this.parseBalance(response);
1649
+ }
1650
+ parseBalance(response) {
1651
+ const result = { 'info': response };
1652
+ const account = this.account();
1653
+ const currencyId = this.safeString(response, 'currency');
1654
+ const code = this.safeCurrencyCode(currencyId);
1655
+ account['free'] = this.safeString(response, 'cash');
1656
+ account['total'] = this.safeString(response, 'equity');
1657
+ result[code] = account;
1658
+ return this.safeBalance(result);
1659
+ }
1589
1660
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1590
1661
  let endpoint = '/' + this.implodeParams(path, params);
1591
1662
  let url = this.implodeHostname(this.urls['api'][api[0]]);
@@ -2390,6 +2390,10 @@ class Exchange {
2390
2390
  }
2391
2391
  featuresMapper(initialFeatures, marketType, subType = undefined) {
2392
2392
  let featuresObj = (subType !== undefined) ? initialFeatures[marketType][subType] : initialFeatures[marketType];
2393
+ // if exchange does not have that market-type (eg. future>inverse)
2394
+ if (featuresObj === undefined) {
2395
+ return undefined;
2396
+ }
2393
2397
  const extendsStr = this.safeString(featuresObj, 'extends');
2394
2398
  if (extendsStr !== undefined) {
2395
2399
  featuresObj = this.omit(featuresObj, 'extends');
@@ -2412,7 +2416,7 @@ class Exchange {
2412
2416
  // default 'GTC' to true
2413
2417
  const gtcValue = this.safeBool(featuresObj['createOrder']['timeInForce'], 'gtc');
2414
2418
  if (gtcValue === undefined) {
2415
- featuresObj['createOrder']['timeInForce']['gtc'] = true;
2419
+ featuresObj['createOrder']['timeInForce']['GTC'] = true;
2416
2420
  }
2417
2421
  }
2418
2422
  return featuresObj;
@@ -6809,8 +6813,10 @@ class Exchange {
6809
6813
  const symbolAndTimeFrame = symbolsAndTimeFrames[i];
6810
6814
  const symbol = this.safeString(symbolAndTimeFrame, 0);
6811
6815
  const timeframe = this.safeString(symbolAndTimeFrame, 1);
6812
- if (timeframe in this.ohlcvs[symbol]) {
6813
- delete this.ohlcvs[symbol][timeframe];
6816
+ if (symbol in this.ohlcvs) {
6817
+ if (timeframe in this.ohlcvs[symbol]) {
6818
+ delete this.ohlcvs[symbol][timeframe];
6819
+ }
6814
6820
  }
6815
6821
  }
6816
6822
  }
@@ -6818,35 +6824,50 @@ class Exchange {
6818
6824
  for (let i = 0; i < symbols.length; i++) {
6819
6825
  const symbol = symbols[i];
6820
6826
  if (topic === 'trades') {
6821
- delete this.trades[symbol];
6827
+ if (symbol in this.trades) {
6828
+ delete this.trades[symbol];
6829
+ }
6822
6830
  }
6823
6831
  else if (topic === 'orderbook') {
6824
- delete this.orderbooks[symbol];
6832
+ if (symbol in this.orderbooks) {
6833
+ delete this.orderbooks[symbol];
6834
+ }
6825
6835
  }
6826
6836
  else if (topic === 'ticker') {
6827
- delete this.tickers[symbol];
6837
+ if (symbol in this.tickers) {
6838
+ delete this.tickers[symbol];
6839
+ }
6828
6840
  }
6829
6841
  }
6830
6842
  }
6831
6843
  else {
6832
6844
  if (topic === 'myTrades') {
6833
6845
  // don't reset this.myTrades directly here
6834
- // because in c# we need to use a different object
6846
+ // because in c# we need to use a different object (thread-safe dict)
6835
6847
  const keys = Object.keys(this.myTrades);
6836
6848
  for (let i = 0; i < keys.length; i++) {
6837
- delete this.myTrades[keys[i]];
6849
+ const key = keys[i];
6850
+ if (key in this.myTrades) {
6851
+ delete this.myTrades[key];
6852
+ }
6838
6853
  }
6839
6854
  }
6840
6855
  else if (topic === 'orders') {
6841
6856
  const orderSymbols = Object.keys(this.orders);
6842
6857
  for (let i = 0; i < orderSymbols.length; i++) {
6843
- delete this.orders[orderSymbols[i]];
6858
+ const orderSymbol = orderSymbols[i];
6859
+ if (orderSymbol in this.orders) {
6860
+ delete this.orders[orderSymbol];
6861
+ }
6844
6862
  }
6845
6863
  }
6846
6864
  else if (topic === 'ticker') {
6847
6865
  const tickerSymbols = Object.keys(this.tickers);
6848
6866
  for (let i = 0; i < tickerSymbols.length; i++) {
6849
- delete this.tickers[tickerSymbols[i]];
6867
+ const tickerSymbol = tickerSymbols[i];
6868
+ if (tickerSymbol in this.tickers) {
6869
+ delete this.tickers[tickerSymbol];
6870
+ }
6850
6871
  }
6851
6872
  }
6852
6873
  }
@@ -1568,7 +1568,6 @@ class binance extends binance$1 {
1568
1568
  'takeProfitPrice': true,
1569
1569
  'attachedStopLossTakeProfit': undefined,
1570
1570
  'timeInForce': {
1571
- 'GTC': true,
1572
1571
  'IOC': true,
1573
1572
  'FOK': true,
1574
1573
  'PO': true,
@@ -1635,7 +1634,6 @@ class binance extends binance$1 {
1635
1634
  'takeProfitPrice': true,
1636
1635
  'attachedStopLossTakeProfit': undefined,
1637
1636
  'timeInForce': {
1638
- 'GTC': true,
1639
1637
  'IOC': true,
1640
1638
  'FOK': true,
1641
1639
  'PO': true,
@@ -80,7 +80,7 @@ class bingx extends bingx$1 {
80
80
  'fetchPositionHistory': false,
81
81
  'fetchPositionMode': true,
82
82
  'fetchPositions': true,
83
- 'fetchPositionsHistory': false,
83
+ 'fetchPositionsHistory': true,
84
84
  'fetchTicker': true,
85
85
  'fetchTickers': true,
86
86
  'fetchTime': true,
@@ -204,7 +204,6 @@ class bingx extends bingx$1 {
204
204
  'private': {
205
205
  'get': {
206
206
  'positionSide/dual': 5,
207
- 'market/markPriceKlines': 1,
208
207
  'trade/batchCancelReplace': 5,
209
208
  'trade/fullOrder': 2,
210
209
  'maintMarginRatio': 2,
@@ -538,7 +537,6 @@ class bingx extends bingx$1 {
538
537
  'limitPrice': true,
539
538
  },
540
539
  'timeInForce': {
541
- 'GTC': true,
542
540
  'IOC': true,
543
541
  'FOK': true,
544
542
  'PO': true,
@@ -1015,7 +1013,7 @@ class bingx extends bingx$1 {
1015
1013
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
1016
1014
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
1017
1015
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
1018
- * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
1016
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20Kline/Candlestick%20Data
1019
1017
  * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20K-line%20Data
1020
1018
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1021
1019
  * @param {string} timeframe the length of time each candle represents
@@ -1061,7 +1059,7 @@ class bingx extends bingx$1 {
1061
1059
  const price = this.safeString(params, 'price');
1062
1060
  params = this.omit(params, 'price');
1063
1061
  if (price === 'mark') {
1064
- response = await this.swapV1PrivateGetMarketMarkPriceKlines(this.extend(request, params));
1062
+ response = await this.swapV1PublicGetMarketMarkPriceKlines(this.extend(request, params));
1065
1063
  }
1066
1064
  else {
1067
1065
  response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
@@ -2334,6 +2332,71 @@ class bingx extends bingx$1 {
2334
2332
  }
2335
2333
  return this.safeBalance(result);
2336
2334
  }
2335
+ /**
2336
+ * @method
2337
+ * @name bingx#fetchPositionHistory
2338
+ * @description fetches historical positions
2339
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Position%20History
2340
+ * @param {string} symbol unified contract symbol
2341
+ * @param {int} [since] the earliest time in ms to fetch positions for
2342
+ * @param {int} [limit] the maximum amount of records to fetch
2343
+ * @param {object} [params] extra parameters specific to the exchange api endpoint
2344
+ * @param {int} [params.until] the latest time in ms to fetch positions for
2345
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
2346
+ */
2347
+ async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
2348
+ await this.loadMarkets();
2349
+ const market = this.market(symbol);
2350
+ let request = {
2351
+ 'symbol': market['id'],
2352
+ };
2353
+ if (limit !== undefined) {
2354
+ request['pageSize'] = limit;
2355
+ }
2356
+ if (since !== undefined) {
2357
+ request['startTs'] = since;
2358
+ }
2359
+ [request, params] = this.handleUntilOption('endTs', request, params);
2360
+ let response = undefined;
2361
+ if (market['linear']) {
2362
+ response = await this.swapV1PrivateGetTradePositionHistory(this.extend(request, params));
2363
+ }
2364
+ else {
2365
+ throw new errors.NotSupported(this.id + ' fetchPositionHistory() is not supported for inverse swap positions');
2366
+ }
2367
+ //
2368
+ // {
2369
+ // "code": 0,
2370
+ // "msg": "",
2371
+ // "data": {
2372
+ // "positionHistory": [
2373
+ // {
2374
+ // "positionId": "1861675561156571136",
2375
+ // "symbol": "LTC-USDT",
2376
+ // "isolated": false,
2377
+ // "positionSide": "LONG",
2378
+ // "openTime": 1732693017000,
2379
+ // "updateTime": 1733310292000,
2380
+ // "avgPrice": "95.18",
2381
+ // "avgClosePrice": "129.48",
2382
+ // "realisedProfit": "102.89",
2383
+ // "netProfit": "99.63",
2384
+ // "positionAmt": "30.0",
2385
+ // "closePositionAmt": "30.0",
2386
+ // "leverage": 6,
2387
+ // "closeAllPositions": true,
2388
+ // "positionCommission": "-0.33699650000000003",
2389
+ // "totalFunding": "-2.921461693902908"
2390
+ // },
2391
+ // ]
2392
+ // }
2393
+ // }
2394
+ //
2395
+ const data = this.safeDict(response, 'data', {});
2396
+ const records = this.safeList(data, 'positionHistory', []);
2397
+ const positions = this.parsePositions(records);
2398
+ return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
2399
+ }
2337
2400
  /**
2338
2401
  * @method
2339
2402
  * @name bingx#fetchPositions
@@ -2582,6 +2645,27 @@ class bingx extends bingx$1 {
2582
2645
  // "positionAmt": "1.20365912",
2583
2646
  // }
2584
2647
  //
2648
+ // linear swap fetchPositionHistory
2649
+ //
2650
+ // {
2651
+ // "positionId": "1861675561156571136",
2652
+ // "symbol": "LTC-USDT",
2653
+ // "isolated": false,
2654
+ // "positionSide": "LONG",
2655
+ // "openTime": 1732693017000,
2656
+ // "updateTime": 1733310292000,
2657
+ // "avgPrice": "95.18",
2658
+ // "avgClosePrice": "129.48",
2659
+ // "realisedProfit": "102.89",
2660
+ // "netProfit": "99.63",
2661
+ // "positionAmt": "30.0",
2662
+ // "closePositionAmt": "30.0",
2663
+ // "leverage": 6,
2664
+ // "closeAllPositions": true,
2665
+ // "positionCommission": "-0.33699650000000003",
2666
+ // "totalFunding": "-2.921461693902908"
2667
+ // }
2668
+ //
2585
2669
  let marketId = this.safeString(position, 'symbol', '');
2586
2670
  marketId = marketId.replace('/', '-'); // standard return different format
2587
2671
  const isolated = this.safeBool(position, 'isolated');
@@ -2589,6 +2673,7 @@ class bingx extends bingx$1 {
2589
2673
  if (isolated !== undefined) {
2590
2674
  marginMode = isolated ? 'isolated' : 'cross';
2591
2675
  }
2676
+ const timestamp = this.safeInteger(position, 'openTime');
2592
2677
  return this.safePosition({
2593
2678
  'info': position,
2594
2679
  'id': this.safeString(position, 'positionId'),
@@ -2606,8 +2691,8 @@ class bingx extends bingx$1 {
2606
2691
  'lastPrice': undefined,
2607
2692
  'side': this.safeStringLower(position, 'positionSide'),
2608
2693
  'hedged': undefined,
2609
- 'timestamp': undefined,
2610
- 'datetime': undefined,
2694
+ 'timestamp': timestamp,
2695
+ 'datetime': this.iso8601(timestamp),
2611
2696
  'lastUpdateTimestamp': this.safeInteger(position, 'updateTime'),
2612
2697
  'maintenanceMargin': undefined,
2613
2698
  'maintenanceMarginPercentage': undefined,
@@ -6381,7 +6466,7 @@ class bingx extends bingx$1 {
6381
6466
  }
6382
6467
  else {
6383
6468
  const query = this.urlencode(parsedParams);
6384
- url += '?' + query + '&signature=' + signature;
6469
+ url += '?' + query + '&' + 'signature=' + signature;
6385
6470
  }
6386
6471
  }
6387
6472
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
@@ -1462,7 +1462,6 @@ class bitget extends bitget$1 {
1462
1462
  'limitPrice': true,
1463
1463
  },
1464
1464
  'timeInForce': {
1465
- 'GTC': true,
1466
1465
  'IOC': true,
1467
1466
  'FOK': true,
1468
1467
  'PO': true,
@@ -1533,7 +1532,6 @@ class bitget extends bitget$1 {
1533
1532
  'limitPrice': false,
1534
1533
  },
1535
1534
  'timeInForce': {
1536
- 'GTC': true,
1537
1535
  'IOC': true,
1538
1536
  'FOK': true,
1539
1537
  'PO': true,
@@ -1049,7 +1049,7 @@ class bithumb extends bithumb$1 {
1049
1049
  'address': address,
1050
1050
  'currency': currency['id'],
1051
1051
  };
1052
- if (code === 'XRP' || code === 'XMR' || code === 'EOS' || code === 'STEEM') {
1052
+ if (code === 'XRP' || code === 'XMR' || code === 'EOS' || code === 'STEEM' || code === 'TON') {
1053
1053
  const destination = this.safeString(params, 'destination');
1054
1054
  if ((tag === undefined) && (destination === undefined)) {
1055
1055
  throw new errors.ArgumentsRequired(this.id + ' ' + code + ' withdraw() requires a tag argument or an extra destination param');
@@ -685,6 +685,151 @@ class bitmart extends bitmart$1 {
685
685
  'createMarketBuyOrderRequiresPrice': true,
686
686
  'brokerId': 'CCXTxBitmart000',
687
687
  },
688
+ 'features': {
689
+ 'default': {
690
+ 'sandbox': false,
691
+ 'createOrder': {
692
+ 'marginMode': true,
693
+ 'triggerPrice': false,
694
+ 'triggerPriceType': undefined,
695
+ 'triggerDirection': false,
696
+ 'stopLossPrice': false,
697
+ 'takeProfitPrice': false,
698
+ 'attachedStopLossTakeProfit': undefined,
699
+ 'timeInForce': {
700
+ 'IOC': true,
701
+ 'FOK': false,
702
+ 'PO': true,
703
+ 'GTD': false,
704
+ },
705
+ 'hedged': false,
706
+ 'trailing': false,
707
+ 'marketBuyRequiresPrice': true,
708
+ 'marketBuyByCost': true,
709
+ // exchange-supported features
710
+ // 'leverage': true,
711
+ // 'selfTradePrevention': false,
712
+ // 'twap': false,
713
+ // 'iceberg': false,
714
+ // 'oco': false,
715
+ },
716
+ 'createOrders': {
717
+ 'max': 10,
718
+ },
719
+ 'fetchMyTrades': {
720
+ 'marginMode': true,
721
+ 'limit': 200,
722
+ 'daysBack': undefined,
723
+ 'untilDays': 99999,
724
+ },
725
+ 'fetchOrder': {
726
+ 'marginMode': false,
727
+ 'trigger': false,
728
+ 'trailing': false,
729
+ },
730
+ 'fetchOpenOrders': {
731
+ 'marginMode': true,
732
+ 'limit': 200,
733
+ 'trigger': false,
734
+ 'trailing': false,
735
+ },
736
+ 'fetchOrders': undefined,
737
+ 'fetchClosedOrders': {
738
+ 'marginMode': true,
739
+ 'limit': 200,
740
+ 'daysBackClosed': undefined,
741
+ 'daysBackCanceled': undefined,
742
+ 'untilDays': undefined,
743
+ 'trigger': false,
744
+ 'trailing': false,
745
+ },
746
+ 'fetchOHLCV': {
747
+ 'limit': 1000, // variable timespans for recent endpoint, 200 for historical
748
+ },
749
+ },
750
+ 'forDerivatives': {
751
+ 'extends': 'default',
752
+ 'createOrder': {
753
+ 'marginMode': true,
754
+ 'triggerPrice': true,
755
+ 'triggerPriceType': {
756
+ 'last': true,
757
+ 'mark': true,
758
+ 'index': false,
759
+ },
760
+ 'triggerDirection': true,
761
+ 'stopLossPrice': true,
762
+ 'takeProfitPrice': true,
763
+ 'attachedStopLossTakeProfit': {
764
+ 'triggerPriceType': {
765
+ 'last': true,
766
+ 'mark': true,
767
+ 'index': false,
768
+ },
769
+ 'limitPrice': false,
770
+ },
771
+ 'timeInForce': {
772
+ 'IOC': true,
773
+ 'FOK': true,
774
+ 'PO': true,
775
+ 'GTD': false,
776
+ },
777
+ 'hedged': false,
778
+ 'trailing': true,
779
+ 'marketBuyRequiresPrice': true,
780
+ 'marketBuyByCost': true,
781
+ // exchange-supported features
782
+ // 'selfTradePrevention': true,
783
+ // 'twap': false,
784
+ // 'iceberg': false,
785
+ // 'oco': false,
786
+ },
787
+ 'fetchMyTrades': {
788
+ 'marginMode': true,
789
+ 'limit': undefined,
790
+ 'daysBack': undefined,
791
+ 'untilDays': 99999,
792
+ },
793
+ 'fetchOrder': {
794
+ 'marginMode': false,
795
+ 'trigger': false,
796
+ 'trailing': true,
797
+ },
798
+ 'fetchOpenOrders': {
799
+ 'marginMode': false,
800
+ 'limit': 100,
801
+ 'trigger': true,
802
+ 'trailing': false,
803
+ },
804
+ 'fetchClosedOrders': {
805
+ 'marginMode': true,
806
+ 'limit': 200,
807
+ 'daysBackClosed': undefined,
808
+ 'daysBackCanceled': undefined,
809
+ 'untilDays': undefined,
810
+ 'trigger': false,
811
+ 'trailing': false,
812
+ },
813
+ 'fetchOHLCV': {
814
+ 'limit': 500,
815
+ },
816
+ },
817
+ 'spot': {
818
+ 'extends': 'default',
819
+ },
820
+ 'swap': {
821
+ 'linear': {
822
+ 'extends': 'forDerivatives',
823
+ },
824
+ 'inverse': {
825
+ 'extends': 'forDerivatives',
826
+ },
827
+ },
828
+ 'future': {
829
+ 'linear': undefined,
830
+ 'inverse': undefined,
831
+ },
832
+ },
688
833
  });
689
834
  }
690
835
  /**
@@ -1951,11 +2096,12 @@ class bitmart extends bitmart$1 {
1951
2096
  request['orderMode'] = 'iso_margin';
1952
2097
  }
1953
2098
  const options = this.safeDict(this.options, 'fetchMyTrades', {});
1954
- const defaultLimit = this.safeInteger(options, 'limit', 200);
2099
+ const maxLimit = 200;
2100
+ const defaultLimit = this.safeInteger(options, 'limit', maxLimit);
1955
2101
  if (limit === undefined) {
1956
2102
  limit = defaultLimit;
1957
2103
  }
1958
- request['limit'] = limit;
2104
+ request['limit'] = Math.min(limit, maxLimit);
1959
2105
  if (since !== undefined) {
1960
2106
  request['startTime'] = since;
1961
2107
  }
@@ -2639,8 +2785,7 @@ class bitmart extends bitmart$1 {
2639
2785
  * @name bitmart#createSwapOrderRequest
2640
2786
  * @ignore
2641
2787
  * @description create a trade order
2642
- * @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
2643
- * @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
2788
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-order-signed
2644
2789
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
2645
2790
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-tp-or-sl-order-signed
2646
2791
  * @param {string} symbol unified symbol of the market to create an order in
@@ -3159,13 +3304,13 @@ class bitmart extends bitmart$1 {
3159
3304
  market = this.market(symbol);
3160
3305
  request['symbol'] = market['id'];
3161
3306
  }
3162
- if (limit !== undefined) {
3163
- request['limit'] = limit;
3164
- }
3165
3307
  let type = undefined;
3166
3308
  let response = undefined;
3167
3309
  [type, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
3168
3310
  if (type === 'spot') {
3311
+ if (limit !== undefined) {
3312
+ request['limit'] = Math.min(limit, 200);
3313
+ }
3169
3314
  let marginMode = undefined;
3170
3315
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
3171
3316
  if (marginMode === 'isolated') {
@@ -3182,9 +3327,12 @@ class bitmart extends bitmart$1 {
3182
3327
  response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
3183
3328
  }
3184
3329
  else if (type === 'swap') {
3185
- const isStop = this.safeBool2(params, 'stop', 'trigger');
3330
+ if (limit !== undefined) {
3331
+ request['limit'] = Math.min(limit, 100);
3332
+ }
3333
+ const isTrigger = this.safeBool2(params, 'stop', 'trigger');
3186
3334
  params = this.omit(params, ['stop', 'trigger']);
3187
- if (isStop) {
3335
+ if (isTrigger) {
3188
3336
  response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
3189
3337
  }
3190
3338
  else {
@@ -3290,13 +3438,8 @@ class bitmart extends bitmart$1 {
3290
3438
  throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
3291
3439
  }
3292
3440
  }
3293
- let marginMode = undefined;
3294
- [marginMode, params] = this.handleMarginModeAndParams('fetchClosedOrders', params);
3295
- if (marginMode === 'isolated') {
3296
- request['orderMode'] = 'iso_margin';
3297
- }
3298
- const startTimeKey = (type === 'spot') ? 'startTime' : 'start_time';
3299
3441
  if (since !== undefined) {
3442
+ const startTimeKey = (type === 'spot') ? 'startTime' : 'start_time';
3300
3443
  request[startTimeKey] = since;
3301
3444
  }
3302
3445
  const endTimeKey = (type === 'spot') ? 'endTime' : 'end_time';
@@ -3307,6 +3450,11 @@ class bitmart extends bitmart$1 {
3307
3450
  }
3308
3451
  let response = undefined;
3309
3452
  if (type === 'spot') {
3453
+ let marginMode = undefined;
3454
+ [marginMode, params] = this.handleMarginModeAndParams('fetchClosedOrders', params);
3455
+ if (marginMode === 'isolated') {
3456
+ request['orderMode'] = 'iso_margin';
3457
+ }
3310
3458
  response = await this.privatePostSpotV4QueryHistoryOrders(this.extend(request, params));
3311
3459
  }
3312
3460
  else {