ccxt 4.2.39 → 4.2.41

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 (57) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1140 -341
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ascendex.js +28 -24
  6. package/dist/cjs/src/base/Exchange.js +14 -14
  7. package/dist/cjs/src/binance.js +561 -168
  8. package/dist/cjs/src/bingx.js +271 -25
  9. package/dist/cjs/src/bitforex.js +2 -2
  10. package/dist/cjs/src/bitget.js +13 -2
  11. package/dist/cjs/src/bybit.js +3 -1
  12. package/dist/cjs/src/coinbase.js +8 -6
  13. package/dist/cjs/src/coinbasepro.js +1 -0
  14. package/dist/cjs/src/coinlist.js +9 -7
  15. package/dist/cjs/src/coinmetro.js +2 -1
  16. package/dist/cjs/src/currencycom.js +1 -1
  17. package/dist/cjs/src/htx.js +1 -1
  18. package/dist/cjs/src/krakenfutures.js +126 -2
  19. package/dist/cjs/src/mexc.js +44 -44
  20. package/dist/cjs/src/okx.js +9 -15
  21. package/dist/cjs/src/phemex.js +1 -0
  22. package/dist/cjs/src/pro/bitmart.js +38 -20
  23. package/dist/cjs/src/pro/bybit.js +5 -5
  24. package/dist/cjs/src/pro/cex.js +1 -1
  25. package/dist/cjs/src/pro/gemini.js +1 -1
  26. package/js/ccxt.d.ts +1 -1
  27. package/js/ccxt.js +1 -1
  28. package/js/src/abstract/bingx.d.ts +4 -0
  29. package/js/src/abstract/coinbasepro.d.ts +1 -0
  30. package/js/src/ascendex.js +28 -24
  31. package/js/src/base/Exchange.d.ts +8 -8
  32. package/js/src/base/Exchange.js +14 -14
  33. package/js/src/binance.d.ts +1 -1
  34. package/js/src/binance.js +561 -168
  35. package/js/src/bingx.d.ts +2 -0
  36. package/js/src/bingx.js +271 -25
  37. package/js/src/bitforex.js +2 -2
  38. package/js/src/bitget.js +13 -2
  39. package/js/src/bybit.js +3 -1
  40. package/js/src/coinbase.js +8 -6
  41. package/js/src/coinbasepro.js +1 -0
  42. package/js/src/coinlist.js +9 -7
  43. package/js/src/coinmetro.js +2 -1
  44. package/js/src/currencycom.js +1 -1
  45. package/js/src/htx.js +1 -1
  46. package/js/src/krakenfutures.d.ts +2 -0
  47. package/js/src/krakenfutures.js +126 -2
  48. package/js/src/mexc.js +44 -44
  49. package/js/src/okx.js +9 -15
  50. package/js/src/phemex.js +1 -0
  51. package/js/src/pro/bitmart.d.ts +2 -0
  52. package/js/src/pro/bitmart.js +38 -20
  53. package/js/src/pro/bybit.d.ts +1 -1
  54. package/js/src/pro/bybit.js +5 -5
  55. package/js/src/pro/cex.js +1 -1
  56. package/js/src/pro/gemini.js +1 -1
  57. package/package.json +1 -1
@@ -39,7 +39,8 @@ class krakenfutures extends krakenfutures$1 {
39
39
  'fetchBalance': true,
40
40
  'fetchBorrowRateHistories': false,
41
41
  'fetchBorrowRateHistory': false,
42
- 'fetchClosedOrders': undefined,
42
+ 'fetchCanceledOrders': true,
43
+ 'fetchClosedOrders': true,
43
44
  'fetchCrossBorrowRate': false,
44
45
  'fetchCrossBorrowRates': false,
45
46
  'fetchDepositAddress': false,
@@ -1186,6 +1187,102 @@ class krakenfutures extends krakenfutures$1 {
1186
1187
  const orders = this.safeValue(response, 'openOrders', []);
1187
1188
  return this.parseOrders(orders, market, since, limit);
1188
1189
  }
1190
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1191
+ /**
1192
+ * @method
1193
+ * @name krakenfutures#fetchClosedOrders
1194
+ * @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
1195
+ * @description Gets all closed orders, including trigger orders, for an account from the exchange api
1196
+ * @param {string} symbol Unified market symbol
1197
+ * @param {int} [since] Timestamp (ms) of earliest order.
1198
+ * @param {int} [limit] How many orders to return.
1199
+ * @param {object} [params] Exchange specific parameters
1200
+ * @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1201
+ */
1202
+ await this.loadMarkets();
1203
+ let market = undefined;
1204
+ if (symbol !== undefined) {
1205
+ market = this.market(symbol);
1206
+ }
1207
+ const request = {};
1208
+ if (limit !== undefined) {
1209
+ request['count'] = limit;
1210
+ }
1211
+ if (since !== undefined) {
1212
+ request['from'] = since;
1213
+ }
1214
+ const response = await this.historyGetOrders(this.extend(request, params));
1215
+ const allOrders = this.safeList(response, 'elements', []);
1216
+ const closedOrders = [];
1217
+ for (let i = 0; i < allOrders.length; i++) {
1218
+ const order = allOrders[i];
1219
+ const event = this.safeDict(order, 'event', {});
1220
+ const orderPlaced = this.safeDict(event, 'OrderPlaced');
1221
+ if (orderPlaced !== undefined) {
1222
+ const innerOrder = this.safeDict(orderPlaced, 'order', {});
1223
+ const filled = this.safeString(innerOrder, 'filled');
1224
+ if (filled !== '0') {
1225
+ innerOrder['status'] = 'closed'; // status not available in the response
1226
+ closedOrders.push(innerOrder);
1227
+ }
1228
+ }
1229
+ }
1230
+ return this.parseOrders(closedOrders, market, since, limit);
1231
+ }
1232
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1233
+ /**
1234
+ * @method
1235
+ * @name krakenfutures#fetchCanceledOrders
1236
+ * @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
1237
+ * @description Gets all canceled orders, including trigger orders, for an account from the exchange api
1238
+ * @param {string} symbol Unified market symbol
1239
+ * @param {int} [since] Timestamp (ms) of earliest order.
1240
+ * @param {int} [limit] How many orders to return.
1241
+ * @param {object} [params] Exchange specific parameters
1242
+ * @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1243
+ */
1244
+ await this.loadMarkets();
1245
+ let market = undefined;
1246
+ if (symbol !== undefined) {
1247
+ market = this.market(symbol);
1248
+ }
1249
+ const request = {};
1250
+ if (limit !== undefined) {
1251
+ request['count'] = limit;
1252
+ }
1253
+ if (since !== undefined) {
1254
+ request['from'] = since;
1255
+ }
1256
+ const response = await this.historyGetOrders(this.extend(request, params));
1257
+ const allOrders = this.safeList(response, 'elements', []);
1258
+ const canceledAndRejected = [];
1259
+ for (let i = 0; i < allOrders.length; i++) {
1260
+ const order = allOrders[i];
1261
+ const event = this.safeDict(order, 'event', {});
1262
+ const orderPlaced = this.safeDict(event, 'OrderPlaced');
1263
+ if (orderPlaced !== undefined) {
1264
+ const innerOrder = this.safeDict(orderPlaced, 'order', {});
1265
+ const filled = this.safeString(innerOrder, 'filled');
1266
+ if (filled === '0') {
1267
+ innerOrder['status'] = 'canceled'; // status not available in the response
1268
+ canceledAndRejected.push(innerOrder);
1269
+ }
1270
+ }
1271
+ const orderCanceled = this.safeDict(event, 'OrderCancelled');
1272
+ if (orderCanceled !== undefined) {
1273
+ const innerOrder = this.safeDict(orderCanceled, 'order', {});
1274
+ innerOrder['status'] = 'canceled'; // status not available in the response
1275
+ canceledAndRejected.push(innerOrder);
1276
+ }
1277
+ const orderRejected = this.safeDict(event, 'OrderRejected');
1278
+ if (orderRejected !== undefined) {
1279
+ const innerOrder = this.safeDict(orderRejected, 'order', {});
1280
+ innerOrder['status'] = 'rejected'; // status not available in the response
1281
+ canceledAndRejected.push(innerOrder);
1282
+ }
1283
+ }
1284
+ return this.parseOrders(canceledAndRejected, market, since, limit);
1285
+ }
1189
1286
  parseOrderType(orderType) {
1190
1287
  const map = {
1191
1288
  'lmt': 'limit',
@@ -1429,6 +1526,32 @@ class krakenfutures extends krakenfutures$1 {
1429
1526
  // "status": "requiredArgumentMissing",
1430
1527
  // "orderEvents": []
1431
1528
  // }
1529
+ // closed orders
1530
+ // {
1531
+ // uid: '2f00cd63-e61d-44f8-8569-adabde885941',
1532
+ // timestamp: '1707258274849',
1533
+ // event: {
1534
+ // OrderPlaced: {
1535
+ // order: {
1536
+ // uid: '85805e01-9eed-4395-8360-ed1a228237c9',
1537
+ // accountUid: '406142dd-7c5c-4a8b-acbc-5f16eca30009',
1538
+ // tradeable: 'PF_LTCUSD',
1539
+ // direction: 'Buy',
1540
+ // quantity: '0',
1541
+ // filled: '0.1',
1542
+ // timestamp: '1707258274849',
1543
+ // limitPrice: '69.2200000000',
1544
+ // orderType: 'IoC',
1545
+ // clientId: '',
1546
+ // reduceOnly: false,
1547
+ // lastUpdateTimestamp: '1707258274849'
1548
+ // },
1549
+ // reason: 'new_user_order',
1550
+ // reducedQuantity: '',
1551
+ // algoId: ''
1552
+ // }
1553
+ // }
1554
+ // }
1432
1555
  //
1433
1556
  const orderEvents = this.safeValue(order, 'orderEvents', []);
1434
1557
  const errorStatus = this.safeString(order, 'status');
@@ -1491,7 +1614,8 @@ class krakenfutures extends krakenfutures$1 {
1491
1614
  let remaining = this.safeString(details, 'unfilledSize');
1492
1615
  let average = undefined;
1493
1616
  let filled2 = '0.0';
1494
- if (trades.length) {
1617
+ const tradesLength = trades.length;
1618
+ if (tradesLength > 0) {
1495
1619
  let vwapSum = '0.0';
1496
1620
  for (let i = 0; i < trades.length; i++) {
1497
1621
  const trade = trades[i];
@@ -822,7 +822,7 @@ class mexc extends mexc$1 {
822
822
  async fetchStatus(params = {}) {
823
823
  /**
824
824
  * @method
825
- * @name mexc3#fetchStatus
825
+ * @name mexc#fetchStatus
826
826
  * @description the latest known information on the availability of the exchange API
827
827
  * @param {object} [params] extra parameters specific to the exchange API endpoint
828
828
  * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
@@ -859,7 +859,7 @@ class mexc extends mexc$1 {
859
859
  async fetchTime(params = {}) {
860
860
  /**
861
861
  * @method
862
- * @name mexc3#fetchTime
862
+ * @name mexc#fetchTime
863
863
  * @description fetches the current integer timestamp in milliseconds from the exchange server
864
864
  * @param {object} [params] extra parameters specific to the exchange API endpoint
865
865
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
@@ -885,7 +885,7 @@ class mexc extends mexc$1 {
885
885
  async fetchCurrencies(params = {}) {
886
886
  /**
887
887
  * @method
888
- * @name mexc3#fetchCurrencies
888
+ * @name mexc#fetchCurrencies
889
889
  * @description fetches all available currencies on an exchange
890
890
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
891
891
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1050,8 +1050,8 @@ class mexc extends mexc$1 {
1050
1050
  async fetchMarkets(params = {}) {
1051
1051
  /**
1052
1052
  * @method
1053
- * @name mexc3#fetchMarkets
1054
- * @description retrieves data on all markets for mexc3
1053
+ * @name mexc#fetchMarkets
1054
+ * @description retrieves data on all markets for mexc
1055
1055
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1056
1056
  * @returns {object[]} an array of objects representing market data
1057
1057
  */
@@ -1291,7 +1291,7 @@ class mexc extends mexc$1 {
1291
1291
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
1292
1292
  /**
1293
1293
  * @method
1294
- * @name mexc3#fetchOrderBook
1294
+ * @name mexc#fetchOrderBook
1295
1295
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
1296
1296
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
1297
1297
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
@@ -1368,7 +1368,7 @@ class mexc extends mexc$1 {
1368
1368
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1369
1369
  /**
1370
1370
  * @method
1371
- * @name mexc3#fetchTrades
1371
+ * @name mexc#fetchTrades
1372
1372
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
1373
1373
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
1374
1374
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
@@ -1644,7 +1644,7 @@ class mexc extends mexc$1 {
1644
1644
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1645
1645
  /**
1646
1646
  * @method
1647
- * @name mexc3#fetchOHLCV
1647
+ * @name mexc#fetchOHLCV
1648
1648
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
1649
1649
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-data
1650
1650
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
@@ -1766,7 +1766,7 @@ class mexc extends mexc$1 {
1766
1766
  async fetchTickers(symbols = undefined, params = {}) {
1767
1767
  /**
1768
1768
  * @method
1769
- * @name mexc3#fetchTickers
1769
+ * @name mexc#fetchTickers
1770
1770
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1771
1771
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1772
1772
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1854,7 +1854,7 @@ class mexc extends mexc$1 {
1854
1854
  async fetchTicker(symbol, params = {}) {
1855
1855
  /**
1856
1856
  * @method
1857
- * @name mexc3#fetchTicker
1857
+ * @name mexc#fetchTicker
1858
1858
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1859
1859
  * @param {string} symbol unified symbol of the market to fetch the ticker for
1860
1860
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2044,7 +2044,7 @@ class mexc extends mexc$1 {
2044
2044
  async fetchBidsAsks(symbols = undefined, params = {}) {
2045
2045
  /**
2046
2046
  * @method
2047
- * @name mexc3#fetchBidsAsks
2047
+ * @name mexc#fetchBidsAsks
2048
2048
  * @description fetches the bid and ask price and volume for multiple markets
2049
2049
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
2050
2050
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2105,7 +2105,7 @@ class mexc extends mexc$1 {
2105
2105
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2106
2106
  /**
2107
2107
  * @method
2108
- * @name mexc3#createOrder
2108
+ * @name mexc#createOrder
2109
2109
  * @description create a trade order
2110
2110
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2111
2111
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
@@ -2386,7 +2386,7 @@ class mexc extends mexc$1 {
2386
2386
  async fetchOrder(id, symbol = undefined, params = {}) {
2387
2387
  /**
2388
2388
  * @method
2389
- * @name mexc3#fetchOrder
2389
+ * @name mexc#fetchOrder
2390
2390
  * @description fetches information on an order made by the user
2391
2391
  * @param {string} symbol unified symbol of the market the order was made in
2392
2392
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2508,7 +2508,7 @@ class mexc extends mexc$1 {
2508
2508
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2509
2509
  /**
2510
2510
  * @method
2511
- * @name mexc3#fetchOrders
2511
+ * @name mexc#fetchOrders
2512
2512
  * @description fetches information on multiple orders made by the user
2513
2513
  * @param {string} symbol unified market symbol of the market orders were made in
2514
2514
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -2740,7 +2740,7 @@ class mexc extends mexc$1 {
2740
2740
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2741
2741
  /**
2742
2742
  * @method
2743
- * @name mexc3#fetchOpenOrders
2743
+ * @name mexc#fetchOpenOrders
2744
2744
  * @description fetch all unfilled currently open orders
2745
2745
  * @param {string} symbol unified market symbol
2746
2746
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -2831,7 +2831,7 @@ class mexc extends mexc$1 {
2831
2831
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2832
2832
  /**
2833
2833
  * @method
2834
- * @name mexc3#fetchClosedOrders
2834
+ * @name mexc#fetchClosedOrders
2835
2835
  * @description fetches information on multiple closed orders made by the user
2836
2836
  * @param {string} symbol unified market symbol of the market orders were made in
2837
2837
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -2844,7 +2844,7 @@ class mexc extends mexc$1 {
2844
2844
  async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2845
2845
  /**
2846
2846
  * @method
2847
- * @name mexc3#fetchCanceledOrders
2847
+ * @name mexc#fetchCanceledOrders
2848
2848
  * @description fetches information on multiple canceled orders made by the user
2849
2849
  * @param {string} symbol unified market symbol of the market orders were made in
2850
2850
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
@@ -2873,7 +2873,7 @@ class mexc extends mexc$1 {
2873
2873
  async cancelOrder(id, symbol = undefined, params = {}) {
2874
2874
  /**
2875
2875
  * @method
2876
- * @name mexc3#cancelOrder
2876
+ * @name mexc#cancelOrder
2877
2877
  * @description cancels an open order
2878
2878
  * @param {string} id order id
2879
2879
  * @param {string} symbol unified symbol of the market the order was made in
@@ -2989,7 +2989,7 @@ class mexc extends mexc$1 {
2989
2989
  async cancelOrders(ids, symbol = undefined, params = {}) {
2990
2990
  /**
2991
2991
  * @method
2992
- * @name mexc3#cancelOrders
2992
+ * @name mexc#cancelOrders
2993
2993
  * @description cancel multiple orders
2994
2994
  * @param {string[]} ids order ids
2995
2995
  * @param {string} symbol unified market symbol, default is undefined
@@ -3024,7 +3024,7 @@ class mexc extends mexc$1 {
3024
3024
  async cancelAllOrders(symbol = undefined, params = {}) {
3025
3025
  /**
3026
3026
  * @method
3027
- * @name mexc3#cancelAllOrders
3027
+ * @name mexc#cancelAllOrders
3028
3028
  * @description cancel all open orders
3029
3029
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
3030
3030
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3427,7 +3427,7 @@ class mexc extends mexc$1 {
3427
3427
  async fetchAccounts(params = {}) {
3428
3428
  /**
3429
3429
  * @method
3430
- * @name mexc3#fetchAccounts
3430
+ * @name mexc#fetchAccounts
3431
3431
  * @description fetch all the accounts associated with a profile
3432
3432
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3433
3433
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
@@ -3454,7 +3454,7 @@ class mexc extends mexc$1 {
3454
3454
  async fetchTradingFees(params = {}) {
3455
3455
  /**
3456
3456
  * @method
3457
- * @name mexc3#fetchTradingFees
3457
+ * @name mexc#fetchTradingFees
3458
3458
  * @description fetch the trading fees for multiple markets
3459
3459
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3460
3460
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
@@ -3605,7 +3605,7 @@ class mexc extends mexc$1 {
3605
3605
  async fetchBalance(params = {}) {
3606
3606
  /**
3607
3607
  * @method
3608
- * @name mexc3#fetchBalance
3608
+ * @name mexc#fetchBalance
3609
3609
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
3610
3610
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3611
3611
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
@@ -3739,7 +3739,7 @@ class mexc extends mexc$1 {
3739
3739
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3740
3740
  /**
3741
3741
  * @method
3742
- * @name mexc3#fetchMyTrades
3742
+ * @name mexc#fetchMyTrades
3743
3743
  * @description fetch all trades made by the user
3744
3744
  * @param {string} symbol unified market symbol
3745
3745
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3829,7 +3829,7 @@ class mexc extends mexc$1 {
3829
3829
  async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
3830
3830
  /**
3831
3831
  * @method
3832
- * @name mexc3#fetchOrderTrades
3832
+ * @name mexc#fetchOrderTrades
3833
3833
  * @description fetch all the trades made from a single order
3834
3834
  * @param {string} id order id
3835
3835
  * @param {string} symbol unified market symbol
@@ -3927,7 +3927,7 @@ class mexc extends mexc$1 {
3927
3927
  async reduceMargin(symbol, amount, params = {}) {
3928
3928
  /**
3929
3929
  * @method
3930
- * @name mexc3#reduceMargin
3930
+ * @name mexc#reduceMargin
3931
3931
  * @description remove margin from a position
3932
3932
  * @param {string} symbol unified market symbol
3933
3933
  * @param {float} amount the amount of margin to remove
@@ -3939,7 +3939,7 @@ class mexc extends mexc$1 {
3939
3939
  async addMargin(symbol, amount, params = {}) {
3940
3940
  /**
3941
3941
  * @method
3942
- * @name mexc3#addMargin
3942
+ * @name mexc#addMargin
3943
3943
  * @description add margin
3944
3944
  * @param {string} symbol unified market symbol
3945
3945
  * @param {float} amount amount of margin to add
@@ -3951,7 +3951,7 @@ class mexc extends mexc$1 {
3951
3951
  async setLeverage(leverage, symbol = undefined, params = {}) {
3952
3952
  /**
3953
3953
  * @method
3954
- * @name mexc3#setLeverage
3954
+ * @name mexc#setLeverage
3955
3955
  * @description set the level of leverage for a market
3956
3956
  * @param {float} leverage the rate of leverage
3957
3957
  * @param {string} symbol unified market symbol
@@ -3984,7 +3984,7 @@ class mexc extends mexc$1 {
3984
3984
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3985
3985
  /**
3986
3986
  * @method
3987
- * @name mexc3#fetchFundingHistory
3987
+ * @name mexc#fetchFundingHistory
3988
3988
  * @description fetch the history of funding payments paid and received on this account
3989
3989
  * @param {string} symbol unified market symbol
3990
3990
  * @param {int} [since] the earliest time in ms to fetch funding history for
@@ -4099,7 +4099,7 @@ class mexc extends mexc$1 {
4099
4099
  async fetchFundingRate(symbol, params = {}) {
4100
4100
  /**
4101
4101
  * @method
4102
- * @name mexc3#fetchFundingRate
4102
+ * @name mexc#fetchFundingRate
4103
4103
  * @description fetch the current funding rate
4104
4104
  * @param {string} symbol unified market symbol
4105
4105
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4200,7 +4200,7 @@ class mexc extends mexc$1 {
4200
4200
  async fetchLeverageTiers(symbols = undefined, params = {}) {
4201
4201
  /**
4202
4202
  * @method
4203
- * @name mexc3#fetchLeverageTiers
4203
+ * @name mexc#fetchLeverageTiers
4204
4204
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
4205
4205
  * @param {string[]|undefined} symbols list of unified market symbols
4206
4206
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4313,7 +4313,7 @@ class mexc extends mexc$1 {
4313
4313
  async fetchDepositAddressesByNetwork(code, params = {}) {
4314
4314
  /**
4315
4315
  * @method
4316
- * @name mexc3#fetchDepositAddressesByNetwork
4316
+ * @name mexc#fetchDepositAddressesByNetwork
4317
4317
  * @description fetch a dictionary of addresses for a currency, indexed by network
4318
4318
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
4319
4319
  * @param {string} code unified currency code of the currency for the deposit address
@@ -4353,7 +4353,7 @@ class mexc extends mexc$1 {
4353
4353
  async createDepositAddress(code, params = {}) {
4354
4354
  /**
4355
4355
  * @method
4356
- * @name mexc3#createDepositAddress
4356
+ * @name mexc#createDepositAddress
4357
4357
  * @description create a currency deposit address
4358
4358
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
4359
4359
  * @param {string} code unified currency code of the currency for the deposit address
@@ -4393,7 +4393,7 @@ class mexc extends mexc$1 {
4393
4393
  async fetchDepositAddress(code, params = {}) {
4394
4394
  /**
4395
4395
  * @method
4396
- * @name mexc3#fetchDepositAddress
4396
+ * @name mexc#fetchDepositAddress
4397
4397
  * @description fetch the deposit address for a currency associated with this account
4398
4398
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
4399
4399
  * @param {string} code unified currency code
@@ -4421,7 +4421,7 @@ class mexc extends mexc$1 {
4421
4421
  async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
4422
4422
  /**
4423
4423
  * @method
4424
- * @name mexc3#fetchDeposits
4424
+ * @name mexc#fetchDeposits
4425
4425
  * @description fetch all deposits made to an account
4426
4426
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
4427
4427
  * @param {string} code unified currency code
@@ -4481,7 +4481,7 @@ class mexc extends mexc$1 {
4481
4481
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
4482
4482
  /**
4483
4483
  * @method
4484
- * @name mexc3#fetchWithdrawals
4484
+ * @name mexc#fetchWithdrawals
4485
4485
  * @description fetch all withdrawals made from an account
4486
4486
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
4487
4487
  * @param {string} code unified currency code
@@ -4658,7 +4658,7 @@ class mexc extends mexc$1 {
4658
4658
  async fetchPosition(symbol, params = {}) {
4659
4659
  /**
4660
4660
  * @method
4661
- * @name mexc3#fetchPosition
4661
+ * @name mexc#fetchPosition
4662
4662
  * @description fetch data on a single open contract trade position
4663
4663
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
4664
4664
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4675,7 +4675,7 @@ class mexc extends mexc$1 {
4675
4675
  async fetchPositions(symbols = undefined, params = {}) {
4676
4676
  /**
4677
4677
  * @method
4678
- * @name mexc3#fetchPositions
4678
+ * @name mexc#fetchPositions
4679
4679
  * @description fetch all open positions
4680
4680
  * @param {string[]|undefined} symbols list of unified market symbols
4681
4681
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4752,7 +4752,7 @@ class mexc extends mexc$1 {
4752
4752
  const marginType = (openType === '1') ? 'isolated' : 'cross';
4753
4753
  const leverage = this.safeNumber(position, 'leverage');
4754
4754
  const liquidationPrice = this.safeNumber(position, 'liquidatePrice');
4755
- const timestamp = this.safeNumber(position, 'updateTime');
4755
+ const timestamp = this.safeInteger(position, 'updateTime');
4756
4756
  return this.safePosition({
4757
4757
  'info': position,
4758
4758
  'id': undefined,
@@ -4815,7 +4815,7 @@ class mexc extends mexc$1 {
4815
4815
  async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
4816
4816
  /**
4817
4817
  * @method
4818
- * @name mexc3#fetchTransfers
4818
+ * @name mexc#fetchTransfers
4819
4819
  * @description fetch a history of internal transfers made on an account
4820
4820
  * @param {string} code unified currency code of the currency transferred
4821
4821
  * @param {int} [since] the earliest time in ms to fetch transfers for
@@ -4902,7 +4902,7 @@ class mexc extends mexc$1 {
4902
4902
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
4903
4903
  /**
4904
4904
  * @method
4905
- * @name mexc3#transfer
4905
+ * @name mexc#transfer
4906
4906
  * @description transfer currency internally between wallets on the same account
4907
4907
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
4908
4908
  * @param {string} code unified currency code
@@ -5035,7 +5035,7 @@ class mexc extends mexc$1 {
5035
5035
  async withdraw(code, amount, address, tag = undefined, params = {}) {
5036
5036
  /**
5037
5037
  * @method
5038
- * @name mexc3#withdraw
5038
+ * @name mexc#withdraw
5039
5039
  * @description make a withdrawal
5040
5040
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw
5041
5041
  * @param {string} code unified currency code
@@ -5103,7 +5103,7 @@ class mexc extends mexc$1 {
5103
5103
  async fetchTransactionFees(codes = undefined, params = {}) {
5104
5104
  /**
5105
5105
  * @method
5106
- * @name mexc3#fetchTransactionFees
5106
+ * @name mexc#fetchTransactionFees
5107
5107
  * @description fetch deposit and withdrawal fees
5108
5108
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
5109
5109
  * @param {string[]|undefined} codes returns fees for all currencies if undefined
@@ -5201,7 +5201,7 @@ class mexc extends mexc$1 {
5201
5201
  async fetchDepositWithdrawFees(codes = undefined, params = {}) {
5202
5202
  /**
5203
5203
  * @method
5204
- * @name mexc3#fetchDepositWithdrawFees
5204
+ * @name mexc#fetchDepositWithdrawFees
5205
5205
  * @description fetch deposit and withdrawal fees
5206
5206
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
5207
5207
  * @param {string[]|undefined} codes returns fees for all currencies if undefined
@@ -3689,12 +3689,8 @@ class okx extends okx$1 {
3689
3689
  if (trailing) {
3690
3690
  request['ordType'] = 'move_order_stop';
3691
3691
  }
3692
- else if (stop || (ordType in algoOrderTypes)) {
3693
- if (stop) {
3694
- if (ordType === undefined) {
3695
- throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
3696
- }
3697
- }
3692
+ else if (stop && (ordType === undefined)) {
3693
+ request['ordType'] = 'trigger';
3698
3694
  }
3699
3695
  const query = this.omit(params, ['method', 'stop', 'trigger', 'trailing']);
3700
3696
  let response = undefined;
@@ -4001,7 +3997,7 @@ class okx extends okx$1 {
4001
3997
  * @param {int} [since] the earliest time in ms to fetch orders for
4002
3998
  * @param {int} [limit] the maximum number of order structures to retrieve
4003
3999
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4004
- * @param {bool} [params.stop] True if fetching trigger or conditional orders
4000
+ * @param {bool} [params.trigger] True if fetching trigger or conditional orders
4005
4001
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
4006
4002
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
4007
4003
  * @param {int} [params.until] timestamp in ms to fetch orders for
@@ -4039,12 +4035,12 @@ class okx extends okx$1 {
4039
4035
  if (limit !== undefined) {
4040
4036
  request['limit'] = limit; // default 100, max 100
4041
4037
  }
4042
- const options = this.safeValue(this.options, 'fetchClosedOrders', {});
4043
- const algoOrderTypes = this.safeValue(this.options, 'algoOrderTypes', {});
4038
+ const options = this.safeDict(this.options, 'fetchClosedOrders', {});
4039
+ const algoOrderTypes = this.safeDict(this.options, 'algoOrderTypes', {});
4044
4040
  const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
4045
4041
  let method = this.safeString(params, 'method', defaultMethod);
4046
4042
  const ordType = this.safeString(params, 'ordType');
4047
- const stop = this.safeValue2(params, 'stop', 'trigger');
4043
+ const stop = this.safeBool2(params, 'stop', 'trigger');
4048
4044
  const trailing = this.safeBool(params, 'trailing', false);
4049
4045
  if (trailing || stop || (ordType in algoOrderTypes)) {
4050
4046
  method = 'privateGetTradeOrdersAlgoHistory';
@@ -4053,11 +4049,9 @@ class okx extends okx$1 {
4053
4049
  if (trailing) {
4054
4050
  request['ordType'] = 'move_order_stop';
4055
4051
  }
4056
- else if (stop || (ordType in algoOrderTypes)) {
4057
- if (stop) {
4058
- if (ordType === undefined) {
4059
- throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
4060
- }
4052
+ else if (stop) {
4053
+ if (ordType === undefined) {
4054
+ request['ordType'] = 'trigger';
4061
4055
  }
4062
4056
  }
4063
4057
  else {
@@ -33,6 +33,7 @@ class phemex extends phemex$1 {
33
33
  'addMargin': false,
34
34
  'cancelAllOrders': true,
35
35
  'cancelOrder': true,
36
+ 'closePosition': false,
36
37
  'createOrder': true,
37
38
  'createReduceOnlyOrder': true,
38
39
  'createStopLimitOrder': true,