ccxt 4.5.45 → 4.5.46

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 +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +3 -0
  5. package/dist/cjs/src/binance.js +11 -2
  6. package/dist/cjs/src/bitget.js +3 -1
  7. package/dist/cjs/src/bitmart.js +144 -21
  8. package/dist/cjs/src/bybit.js +58 -56
  9. package/dist/cjs/src/bydfi.js +102 -100
  10. package/dist/cjs/src/gate.js +37 -2
  11. package/dist/cjs/src/kraken.js +2 -0
  12. package/dist/cjs/src/kucoin.js +4 -2
  13. package/dist/cjs/src/okx.js +75 -57
  14. package/dist/cjs/src/paradex.js +2 -6
  15. package/dist/cjs/src/pro/bydfi.js +19 -19
  16. package/dist/cjs/src/pro/gate.js +79 -54
  17. package/dist/cjs/src/pro/grvt.js +5 -3
  18. package/dist/cjs/src/pro/htx.js +4 -4
  19. package/dist/cjs/src/pro/okx.js +1 -1
  20. package/index.d.cts +2 -0
  21. package/js/ccxt.d.ts +1 -1
  22. package/js/ccxt.js +1 -1
  23. package/js/src/abstract/bitmart.d.ts +7 -0
  24. package/js/src/abstract/bydfi.d.ts +29 -29
  25. package/js/src/abstract/kraken.d.ts +1 -0
  26. package/js/src/abstract/kucoin.d.ts +1 -0
  27. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  28. package/js/src/base/Exchange.d.ts +1 -0
  29. package/js/src/base/Exchange.js +3 -0
  30. package/js/src/binance.js +11 -2
  31. package/js/src/bitget.js +3 -1
  32. package/js/src/bitmart.d.ts +18 -4
  33. package/js/src/bitmart.js +144 -21
  34. package/js/src/bybit.d.ts +1 -0
  35. package/js/src/bybit.js +58 -56
  36. package/js/src/bydfi.d.ts +31 -31
  37. package/js/src/bydfi.js +102 -100
  38. package/js/src/gate.js +37 -2
  39. package/js/src/kraken.js +2 -0
  40. package/js/src/kucoin.js +4 -2
  41. package/js/src/okx.d.ts +1 -0
  42. package/js/src/okx.js +75 -57
  43. package/js/src/paradex.d.ts +0 -1
  44. package/js/src/paradex.js +2 -6
  45. package/js/src/pro/bydfi.d.ts +18 -18
  46. package/js/src/pro/bydfi.js +19 -19
  47. package/js/src/pro/gate.d.ts +2 -2
  48. package/js/src/pro/gate.js +79 -54
  49. package/js/src/pro/grvt.js +5 -3
  50. package/js/src/pro/htx.js +4 -4
  51. package/js/src/pro/okx.js +1 -1
  52. package/package.json +2 -2
package/js/src/bydfi.js CHANGED
@@ -195,16 +195,16 @@ export default class bydfi extends Exchange {
195
195
  'public': {
196
196
  'get': {
197
197
  'v1/public/api_limits': 1,
198
- 'v1/swap/market/exchange_info': 1,
199
- 'v1/swap/market/depth': 1,
200
- 'v1/swap/market/trades': 1,
201
- 'v1/swap/market/klines': 1,
202
- 'v1/swap/market/ticker/24hr': 1,
203
- 'v1/swap/market/ticker/price': 1,
204
- 'v1/swap/market/mark_price': 1,
205
- 'v1/swap/market/funding_rate': 1,
206
- 'v1/swap/market/funding_rate_history': 1,
207
- 'v1/swap/market/risk_limit': 1, // https://developers.bydfi.com/en/swap/market#risk-limit
198
+ 'v1/fapi/market/exchange_info': 1,
199
+ 'v1/fapi/market/depth': 1,
200
+ 'v1/fapi/market/trades': 1,
201
+ 'v1/fapi/market/klines': 1,
202
+ 'v1/fapi/market/ticker/24hr': 1,
203
+ 'v1/fapi/market/ticker/price': 1,
204
+ 'v1/fapi/market/mark_price': 1,
205
+ 'v1/fapi/market/funding_rate': 1,
206
+ 'v1/fapi/market/funding_rate_history': 1,
207
+ 'v1/fapi/market/risk_limit': 1, // https://developers.bydfi.com/en/futures/market#risk-limit
208
208
  },
209
209
  },
210
210
  'private': {
@@ -213,16 +213,16 @@ export default class bydfi extends Exchange {
213
213
  'v1/account/transfer_records': 1,
214
214
  'v1/spot/deposit_records': 1,
215
215
  'v1/spot/withdraw_records': 1,
216
- 'v1/swap/trade/open_order': 1,
217
- 'v1/swap/trade/plan_order': 1,
218
- 'v1/swap/trade/leverage': 1,
219
- 'v1/swap/trade/history_order': 1,
220
- 'v1/swap/trade/history_trade': 1,
221
- 'v1/swap/trade/position_history': 1,
222
- 'v1/swap/trade/positions': 1,
223
- 'v1/swap/account/balance': 1,
224
- 'v1/swap/user_data/assets_margin': 1,
225
- 'v1/swap/user_data/position_side/dual': 1,
216
+ 'v1/fapi/trade/open_order': 1,
217
+ 'v1/fapi/trade/plan_order': 1,
218
+ 'v1/fapi/trade/leverage': 1,
219
+ 'v1/fapi/trade/history_order': 1,
220
+ 'v1/fapi/trade/history_trade': 1,
221
+ 'v1/fapi/trade/position_history': 1,
222
+ 'v1/fapi/trade/positions': 1,
223
+ 'v1/fapi/account/balance': 1,
224
+ 'v1/fapi/user_data/assets_margin': 1,
225
+ 'v1/fapi/user_data/position_side/dual': 1,
226
226
  'v1/agent/teams': 1,
227
227
  'v1/agent/agent_links': 1,
228
228
  'v1/agent/regular_overview': 1,
@@ -235,15 +235,15 @@ export default class bydfi extends Exchange {
235
235
  },
236
236
  'post': {
237
237
  'v1/account/transfer': 1,
238
- 'v1/swap/trade/place_order': 1,
239
- 'v1/swap/trade/batch_place_order': 1,
240
- 'v1/swap/trade/edit_order': 1,
241
- 'v1/swap/trade/batch_edit_order': 1,
242
- 'v1/swap/trade/cancel_all_order': 1,
243
- 'v1/swap/trade/leverage': 1,
244
- 'v1/swap/trade/batch_leverage_margin': 1,
245
- 'v1/swap/user_data/margin_type': 1,
246
- 'v1/swap/user_data/position_side/dual': 1,
238
+ 'v1/fapi/trade/place_order': 1,
239
+ 'v1/fapi/trade/batch_place_order': 1,
240
+ 'v1/fapi/trade/edit_order': 1,
241
+ 'v1/fapi/trade/batch_edit_order': 1,
242
+ 'v1/fapi/trade/cancel_all_order': 1,
243
+ 'v1/fapi/trade/leverage': 1,
244
+ 'v1/fapi/trade/batch_leverage_margin': 1,
245
+ 'v1/fapi/user_data/margin_type': 1,
246
+ 'v1/fapi/user_data/position_side/dual': 1,
247
247
  'v1/agent/internal_withdrawal': 1, // https://developers.bydfi.com/en/agent/#internal-withdrawal
248
248
  },
249
249
  },
@@ -375,13 +375,15 @@ export default class bydfi extends Exchange {
375
375
  },
376
376
  'accountsByType': {
377
377
  'spot': 'SPOT',
378
- 'swap': 'SWAP',
379
- 'funding': 'FUND',
378
+ 'swap': 'UMFUTURE',
379
+ 'funding': 'FUNDING',
380
+ 'inverse': 'CMFUTURE',
380
381
  },
381
382
  'accountsById': {
382
383
  'SPOT': 'spot',
383
- 'SWAP': 'swap',
384
- 'FUND': 'funding',
384
+ 'UMFUTURE': 'swap',
385
+ 'FUNDING': 'funding',
386
+ 'CMFUTURE': 'inverse',
385
387
  },
386
388
  },
387
389
  });
@@ -390,12 +392,12 @@ export default class bydfi extends Exchange {
390
392
  * @method
391
393
  * @name bydfi#fetchMarkets
392
394
  * @description retrieves data on all markets for bydfi
393
- * @see https://developers.bydfi.com/en/swap/market#fetching-trading-rules-and-pairs
395
+ * @see https://developers.bydfi.com/en/futures/market#fetching-trading-rules-and-pairs
394
396
  * @param {object} [params] extra parameters specific to the exchange API endpoint
395
397
  * @returns {object[]} an array of objects representing market data
396
398
  */
397
399
  async fetchMarkets(params = {}) {
398
- const response = await this.publicGetV1SwapMarketExchangeInfo(params);
400
+ const response = await this.publicGetV1FapiMarketExchangeInfo(params);
399
401
  //
400
402
  // {
401
403
  // "code": "200",
@@ -550,7 +552,7 @@ export default class bydfi extends Exchange {
550
552
  * @method
551
553
  * @name bydfi#fetchOrderBook
552
554
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
553
- * @see https://developers.bydfi.com/en/swap/market#depth-information
555
+ * @see https://developers.bydfi.com/en/futures/market#depth-information
554
556
  * @param {string} symbol unified symbol of the market to fetch the order book for
555
557
  * @param {int} [limit] the maximum amount of order book entries to return, could be 5, 10, 20, 50, 100, 500 or 1000 (default 500)
556
558
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -566,7 +568,7 @@ export default class bydfi extends Exchange {
566
568
  if (limit !== undefined) {
567
569
  request['limit'] = this.getClosestLimit(limit);
568
570
  }
569
- const response = await this.publicGetV1SwapMarketDepth(this.extend(request, params));
571
+ const response = await this.publicGetV1FapiMarketDepth(this.extend(request, params));
570
572
  //
571
573
  // {
572
574
  // "code": 200,
@@ -614,7 +616,7 @@ export default class bydfi extends Exchange {
614
616
  * @method
615
617
  * @name bydfi#fetchTrades
616
618
  * @description get the list of most recent trades for a particular symbol
617
- * @see https://developers.bydfi.com/en/swap/market#recent-trades
619
+ * @see https://developers.bydfi.com/en/futures/market#recent-trades
618
620
  * @param {string} symbol unified symbol of the market to fetch trades for
619
621
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
620
622
  * @param {int} [limit] the maximum amount of trades to fetch (default 500, max 1000)
@@ -631,7 +633,7 @@ export default class bydfi extends Exchange {
631
633
  if (limit !== undefined) {
632
634
  request['limit'] = limit;
633
635
  }
634
- const response = await this.publicGetV1SwapMarketTrades(this.extend(request, params));
636
+ const response = await this.publicGetV1FapiMarketTrades(this.extend(request, params));
635
637
  //
636
638
  // {
637
639
  // "code": 200,
@@ -656,7 +658,7 @@ export default class bydfi extends Exchange {
656
658
  * @method
657
659
  * @name bydfi#fetchMyTrades
658
660
  * @description fetch all trades made by the user
659
- * @see https://developers.bydfi.com/en/swap/trade#historical-trades-query
661
+ * @see https://developers.bydfi.com/en/futures/trade#historical-trades-query
660
662
  * @param {string} symbol unified market symbol
661
663
  * @param {int} [since] the earliest time in ms to fetch trades for
662
664
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -691,7 +693,7 @@ export default class bydfi extends Exchange {
691
693
  if (limit !== undefined) {
692
694
  request['limit'] = limit;
693
695
  }
694
- const response = await this.privateGetV1SwapTradeHistoryTrade(this.extend(request, params));
696
+ const response = await this.privateGetV1FapiTradeHistoryTrade(this.extend(request, params));
695
697
  //
696
698
  // {
697
699
  // "code": 200,
@@ -798,7 +800,7 @@ export default class bydfi extends Exchange {
798
800
  * @method
799
801
  * @name bydfi#fetchOHLCV
800
802
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
801
- * @see https://developers.bydfi.com/en/swap/market#candlestick-data
803
+ * @see https://developers.bydfi.com/en/futures/market#candlestick-data
802
804
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
803
805
  * @param {string} timeframe the length of time each candle represents
804
806
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -846,7 +848,7 @@ export default class bydfi extends Exchange {
846
848
  if (limit !== undefined) {
847
849
  request['limit'] = limit;
848
850
  }
849
- const response = await this.publicGetV1SwapMarketKlines(this.extend(request, params));
851
+ const response = await this.publicGetV1FapiMarketKlines(this.extend(request, params));
850
852
  //
851
853
  // {
852
854
  // "code": 200,
@@ -893,7 +895,7 @@ export default class bydfi extends Exchange {
893
895
  /**
894
896
  * @method
895
897
  * @name bydfi#fetchTickers
896
- * @see https://developers.bydfi.com/en/swap/market#24hr-price-change-statistics
898
+ * @see https://developers.bydfi.com/en/futures/market#24hr-price-change-statistics
897
899
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
898
900
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
899
901
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -901,7 +903,7 @@ export default class bydfi extends Exchange {
901
903
  */
902
904
  async fetchTickers(symbols = undefined, params = {}) {
903
905
  await this.loadMarkets();
904
- const response = await this.publicGetV1SwapMarketTicker24hr(params);
906
+ const response = await this.publicGetV1FapiMarketTicker24hr(params);
905
907
  //
906
908
  // {
907
909
  // "code": 200,
@@ -927,7 +929,7 @@ export default class bydfi extends Exchange {
927
929
  * @method
928
930
  * @name bydfi#fetchTicker
929
931
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
930
- * @see https://developers.bydfi.com/en/swap/market#24hr-price-change-statistics
932
+ * @see https://developers.bydfi.com/en/futures/market#24hr-price-change-statistics
931
933
  * @param {string} symbol unified symbol of the market to fetch the ticker for
932
934
  * @param {object} [params] extra parameters specific to the exchange API endpoint
933
935
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
@@ -938,7 +940,7 @@ export default class bydfi extends Exchange {
938
940
  const request = {
939
941
  'symbol': market['id'],
940
942
  };
941
- const response = await this.publicGetV1SwapMarketTicker24hr(this.extend(request, params));
943
+ const response = await this.publicGetV1FapiMarketTicker24hr(this.extend(request, params));
942
944
  const data = this.safeList(response, 'data', []);
943
945
  const ticker = this.safeDict(data, 0, {});
944
946
  return this.parseTicker(ticker, market);
@@ -989,7 +991,7 @@ export default class bydfi extends Exchange {
989
991
  * @method
990
992
  * @name bydfi#fetchFundingRate
991
993
  * @description fetch the current funding rate
992
- * @see https://developers.bydfi.com/en/swap/market#recent-funding-rate
994
+ * @see https://developers.bydfi.com/en/futures/market#recent-funding-rate
993
995
  * @param {string} symbol unified market symbol
994
996
  * @param {object} [params] extra parameters specific to the exchange API endpoint
995
997
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
@@ -1000,7 +1002,7 @@ export default class bydfi extends Exchange {
1000
1002
  const request = {
1001
1003
  'symbol': market['id'],
1002
1004
  };
1003
- const response = await this.publicGetV1SwapMarketFundingRate(this.extend(request, params));
1005
+ const response = await this.publicGetV1FapiMarketFundingRate(this.extend(request, params));
1004
1006
  //
1005
1007
  // {
1006
1008
  // "code": 200,
@@ -1055,7 +1057,7 @@ export default class bydfi extends Exchange {
1055
1057
  * @method
1056
1058
  * @name bydfi#fetchFundingRateHistory
1057
1059
  * @description fetches historical funding rate prices
1058
- * @see https://developers.bydfi.com/en/swap/market#historical-funding-rates
1060
+ * @see https://developers.bydfi.com/en/futures/market#historical-funding-rates
1059
1061
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1060
1062
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1061
1063
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
@@ -1083,7 +1085,7 @@ export default class bydfi extends Exchange {
1083
1085
  if (until !== undefined) {
1084
1086
  request['endTime'] = until;
1085
1087
  }
1086
- const response = await this.publicGetV1SwapMarketFundingRateHistory(this.extend(request, params));
1088
+ const response = await this.publicGetV1FapiMarketFundingRateHistory(this.extend(request, params));
1087
1089
  //
1088
1090
  // {
1089
1091
  // "code": 200,
@@ -1125,7 +1127,7 @@ export default class bydfi extends Exchange {
1125
1127
  * @method
1126
1128
  * @name bydfi#createOrder
1127
1129
  * @description create a trade order
1128
- * @see https://developers.bydfi.com/en/swap/trade#placing-an-order
1130
+ * @see https://developers.bydfi.com/en/futures/trade#placing-an-order
1129
1131
  * @param {string} symbol unified symbol of the market to create an order in
1130
1132
  * @param {string} type 'market' or 'limit'
1131
1133
  * @param {string} side 'buy' or 'sell'
@@ -1153,7 +1155,7 @@ export default class bydfi extends Exchange {
1153
1155
  let wallet = 'W001';
1154
1156
  [wallet, params] = this.handleOptionAndParams(params, 'createOrder', 'wallet', wallet);
1155
1157
  orderRequest = this.extend(orderRequest, { 'wallet': wallet });
1156
- const response = await this.privatePostV1SwapTradePlaceOrder(orderRequest);
1158
+ const response = await this.privatePostV1FapiTradePlaceOrder(orderRequest);
1157
1159
  //
1158
1160
  // {
1159
1161
  // "code": 200,
@@ -1306,7 +1308,7 @@ export default class bydfi extends Exchange {
1306
1308
  * @method
1307
1309
  * @name bydfi#createOrders
1308
1310
  * @description create a list of trade orders
1309
- * @see https://developers.bydfi.com/en/swap/trade#batch-order-placement
1311
+ * @see https://developers.bydfi.com/en/futures/trade#batch-order-placement
1310
1312
  * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
1311
1313
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1312
1314
  * @param {string} [params.wallet] The unique code of a sub-wallet. W001 is the default wallet and the main wallet code of the contract
@@ -1336,7 +1338,7 @@ export default class bydfi extends Exchange {
1336
1338
  'wallet': wallet,
1337
1339
  'orders': ordersRequests,
1338
1340
  };
1339
- const response = await this.privatePostV1SwapTradeBatchPlaceOrder(this.extend(request, params));
1341
+ const response = await this.privatePostV1FapiTradeBatchPlaceOrder(this.extend(request, params));
1340
1342
  const data = this.safeList(response, 'data', []);
1341
1343
  return this.parseOrders(data);
1342
1344
  }
@@ -1344,7 +1346,7 @@ export default class bydfi extends Exchange {
1344
1346
  * @method
1345
1347
  * @name bydfi#editOrder
1346
1348
  * @description edit a trade order
1347
- * @see https://developers.bydfi.com/en/swap/trade#order-modification
1349
+ * @see https://developers.bydfi.com/en/futures/trade#order-modification
1348
1350
  * @param {string} id order id (mandatory if params.clientOrderId is not provided)
1349
1351
  * @param {string} [symbol] unified symbol of the market to create an order in
1350
1352
  * @param {string} [type] not used by bydfi editOrder
@@ -1362,7 +1364,7 @@ export default class bydfi extends Exchange {
1362
1364
  let wallet = 'W001';
1363
1365
  [wallet, params] = this.handleOptionAndParams(params, 'editOrder', 'wallet', wallet);
1364
1366
  request['wallet'] = wallet;
1365
- const response = await this.privatePostV1SwapTradeEditOrder(request);
1367
+ const response = await this.privatePostV1FapiTradeEditOrder(request);
1366
1368
  const data = this.safeDict(response, 'data', {});
1367
1369
  return this.parseOrder(data);
1368
1370
  }
@@ -1370,7 +1372,7 @@ export default class bydfi extends Exchange {
1370
1372
  * @method
1371
1373
  * @name bydfi#editOrders
1372
1374
  * @description edit a list of trade orders
1373
- * @see https://developers.bydfi.com/en/swap/trade#batch-order-modification
1375
+ * @see https://developers.bydfi.com/en/futures/trade#batch-order-modification
1374
1376
  * @param {Array} orders list of orders to edit, each object should contain the parameters required by editOrder, namely id, symbol, amount, price and params
1375
1377
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1376
1378
  * @param {string} [params.wallet] The unique code of a sub-wallet. W001 is the default wallet and the main wallet code of the contract
@@ -1400,7 +1402,7 @@ export default class bydfi extends Exchange {
1400
1402
  'wallet': wallet,
1401
1403
  'editOrders': ordersRequests,
1402
1404
  };
1403
- const response = await this.privatePostV1SwapTradeBatchEditOrder(this.extend(request, params));
1405
+ const response = await this.privatePostV1FapiTradeBatchEditOrder(this.extend(request, params));
1404
1406
  const data = this.safeList(response, 'data', []);
1405
1407
  return this.parseOrders(data);
1406
1408
  }
@@ -1430,7 +1432,7 @@ export default class bydfi extends Exchange {
1430
1432
  * @method
1431
1433
  * @name bydfi#cancelAllOrders
1432
1434
  * @description cancel all open orders in a market
1433
- * @see https://developers.bydfi.com/en/swap/trade#complete-order-cancellation
1435
+ * @see https://developers.bydfi.com/en/futures/trade#complete-order-cancellation
1434
1436
  * @param {string} symbol unified market symbol of the market to cancel orders in
1435
1437
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1436
1438
  * @param {string} [params.wallet] The unique code of a sub-wallet. W001 is the default wallet and the main wallet code of the contract
@@ -1448,7 +1450,7 @@ export default class bydfi extends Exchange {
1448
1450
  'symbol': market['id'],
1449
1451
  'wallet': wallet,
1450
1452
  };
1451
- const response = await this.privatePostV1SwapTradeCancelAllOrder(this.extend(request, params));
1453
+ const response = await this.privatePostV1FapiTradeCancelAllOrder(this.extend(request, params));
1452
1454
  //
1453
1455
  // {
1454
1456
  // "code": 200,
@@ -1488,8 +1490,8 @@ export default class bydfi extends Exchange {
1488
1490
  * @method
1489
1491
  * @name bydfi#fetchOpenOrders
1490
1492
  * @description fetch all unfilled currently open orders
1491
- * @see https://developers.bydfi.com/en/swap/trade#pending-order-query
1492
- * @see https://developers.bydfi.com/en/swap/trade#planned-order-query
1493
+ * @see https://developers.bydfi.com/en/futures/trade#pending-order-query
1494
+ * @see https://developers.bydfi.com/en/futures/trade#planned-order-query
1493
1495
  * @param {string} symbol unified market symbol of the market orders were made in
1494
1496
  * @param {int} [since] the earliest time in ms to fetch orders for
1495
1497
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1546,10 +1548,10 @@ export default class bydfi extends Exchange {
1546
1548
  // "success": true
1547
1549
  // }
1548
1550
  //
1549
- response = await this.privateGetV1SwapTradeOpenOrder(this.extend(request, params));
1551
+ response = await this.privateGetV1FapiTradeOpenOrder(this.extend(request, params));
1550
1552
  }
1551
1553
  else {
1552
- response = await this.privateGetV1SwapTradePlanOrder(this.extend(request, params));
1554
+ response = await this.privateGetV1FapiTradePlanOrder(this.extend(request, params));
1553
1555
  }
1554
1556
  const data = this.safeList(response, 'data', []);
1555
1557
  return this.parseOrders(data, market, since, limit);
@@ -1558,8 +1560,8 @@ export default class bydfi extends Exchange {
1558
1560
  * @method
1559
1561
  * @name bydfi#fetchOpenOrder
1560
1562
  * @description fetch an open order by the id
1561
- * @see https://developers.bydfi.com/en/swap/trade#pending-order-query
1562
- * @see https://developers.bydfi.com/en/swap/trade#planned-order-query
1563
+ * @see https://developers.bydfi.com/en/futures/trade#pending-order-query
1564
+ * @see https://developers.bydfi.com/en/futures/trade#planned-order-query
1563
1565
  * @param {string} id order id (mandatory if params.clientOrderId is not provided)
1564
1566
  * @param {string} symbol unified market symbol
1565
1567
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1591,10 +1593,10 @@ export default class bydfi extends Exchange {
1591
1593
  let trigger = false;
1592
1594
  [trigger, params] = this.handleOptionAndParams(params, 'fetchOpenOrder', 'trigger', trigger);
1593
1595
  if (!trigger) {
1594
- response = await this.privateGetV1SwapTradeOpenOrder(this.extend(request, params));
1596
+ response = await this.privateGetV1FapiTradeOpenOrder(this.extend(request, params));
1595
1597
  }
1596
1598
  else {
1597
- response = await this.privateGetV1SwapTradePlanOrder(this.extend(request, params));
1599
+ response = await this.privateGetV1FapiTradePlanOrder(this.extend(request, params));
1598
1600
  }
1599
1601
  const data = this.safeList(response, 'data', []);
1600
1602
  const order = this.safeDict(data, 0, {});
@@ -1604,7 +1606,7 @@ export default class bydfi extends Exchange {
1604
1606
  * @method
1605
1607
  * @name bydfi#fetchCanceledAndClosedOrders
1606
1608
  * @description fetches information on multiple canceled and closed orders made by the user
1607
- * @see https://developers.bydfi.com/en/swap/trade#historical-orders-query
1609
+ * @see https://developers.bydfi.com/en/futures/trade#historical-orders-query
1608
1610
  * @param {string} symbol unified market symbol of the closed orders
1609
1611
  * @param {int} [since] timestamp in ms of the earliest order
1610
1612
  * @param {int} [limit] the max number of closed orders to return
@@ -1639,7 +1641,7 @@ export default class bydfi extends Exchange {
1639
1641
  if (limit !== undefined) {
1640
1642
  request['limit'] = limit;
1641
1643
  }
1642
- const response = await this.privateGetV1SwapTradeHistoryOrder(this.extend(request, params));
1644
+ const response = await this.privateGetV1FapiTradeHistoryOrder(this.extend(request, params));
1643
1645
  //
1644
1646
  // {
1645
1647
  // "code": 200,
@@ -1873,7 +1875,7 @@ export default class bydfi extends Exchange {
1873
1875
  * @method
1874
1876
  * @name bydfi#setLeverage
1875
1877
  * @description set the level of leverage for a market
1876
- * @see https://developers.bydfi.com/en/swap/trade#set-leverage-for-single-trading-pair
1878
+ * @see https://developers.bydfi.com/en/futures/trade#set-leverage-for-single-trading-pair
1877
1879
  * @param {float} leverage the rate of leverage
1878
1880
  * @param {string} symbol unified market symbol
1879
1881
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1893,7 +1895,7 @@ export default class bydfi extends Exchange {
1893
1895
  'leverage': leverage,
1894
1896
  'wallet': wallet,
1895
1897
  };
1896
- const response = await this.privatePostV1SwapTradeLeverage(this.extend(request, params));
1898
+ const response = await this.privatePostV1FapiTradeLeverage(this.extend(request, params));
1897
1899
  const data = this.safeDict(response, 'data', {});
1898
1900
  return data;
1899
1901
  }
@@ -1901,7 +1903,7 @@ export default class bydfi extends Exchange {
1901
1903
  * @method
1902
1904
  * @name bydfi#fetchLeverage
1903
1905
  * @description fetch the set leverage for a market
1904
- * @see https://developers.bydfi.com/en/swap/trade#get-leverage-for-single-trading-pair
1906
+ * @see https://developers.bydfi.com/en/futures/trade#get-leverage-for-single-trading-pair
1905
1907
  * @param {string} symbol unified market symbol
1906
1908
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1907
1909
  * @param {string} [params.wallet] The unique code of a sub-wallet. W001 is the default wallet and the main wallet code of the contract
@@ -1919,7 +1921,7 @@ export default class bydfi extends Exchange {
1919
1921
  'symbol': market['id'],
1920
1922
  'wallet': wallet,
1921
1923
  };
1922
- const response = await this.privateGetV1SwapTradeLeverage(this.extend(request, params));
1924
+ const response = await this.privateGetV1FapiTradeLeverage(this.extend(request, params));
1923
1925
  //
1924
1926
  // {
1925
1927
  // "code": 200,
@@ -1949,7 +1951,7 @@ export default class bydfi extends Exchange {
1949
1951
  * @method
1950
1952
  * @name bydfi#fetchPositions
1951
1953
  * @description fetch all open positions
1952
- * @see https://developers.bydfi.com/en/swap/trade#positions-query
1954
+ * @see https://developers.bydfi.com/en/futures/trade#positions-query
1953
1955
  * @param {string[]} [symbols] list of unified market symbols
1954
1956
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1955
1957
  * @param {string} [params.contractType] FUTURE or DELIVERY, default is FUTURE
@@ -1963,7 +1965,7 @@ export default class bydfi extends Exchange {
1963
1965
  const request = {
1964
1966
  'contractType': contractType,
1965
1967
  };
1966
- const response = await this.privateGetV1SwapTradePositions(this.extend(request, params));
1968
+ const response = await this.privateGetV1FapiTradePositions(this.extend(request, params));
1967
1969
  //
1968
1970
  // {
1969
1971
  // "code": 200,
@@ -1993,7 +1995,7 @@ export default class bydfi extends Exchange {
1993
1995
  * @method
1994
1996
  * @name bydfi#fetchPositionsForSymbol
1995
1997
  * @description fetch open positions for a single market
1996
- * @see https://developers.bydfi.com/en/swap/trade#positions-query
1998
+ * @see https://developers.bydfi.com/en/futures/trade#positions-query
1997
1999
  * @description fetch all open positions for specific symbol
1998
2000
  * @param {string} symbol unified market symbol
1999
2001
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2009,7 +2011,7 @@ export default class bydfi extends Exchange {
2009
2011
  'contractType': contractType,
2010
2012
  'symbol': market['id'],
2011
2013
  };
2012
- const response = await this.privateGetV1SwapTradePositions(this.extend(request, params));
2014
+ const response = await this.privateGetV1FapiTradePositions(this.extend(request, params));
2013
2015
  const data = this.safeList(response, 'data', []);
2014
2016
  return this.parsePositions(data, [market['symbol']]);
2015
2017
  }
@@ -2129,7 +2131,7 @@ export default class bydfi extends Exchange {
2129
2131
  * @method
2130
2132
  * @name bydfi#fetchPositionHistory
2131
2133
  * @description fetches historical positions
2132
- * @see https://developers.bydfi.com/en/swap/trade#query-historical-position-profit-and-loss-records
2134
+ * @see https://developers.bydfi.com/en/futures/trade#query-historical-position-profit-and-loss-records
2133
2135
  * @param {string} symbol a unified market symbol
2134
2136
  * @param {int} [since] timestamp in ms of the earliest position to fetch , params["until"] - since <= 7 days
2135
2137
  * @param {int} [limit] the maximum amount of records to fetch (default 500, max 500)
@@ -2152,7 +2154,7 @@ export default class bydfi extends Exchange {
2152
2154
  if (limit !== undefined) {
2153
2155
  request['limit'] = limit;
2154
2156
  }
2155
- const response = await this.privateGetV1SwapTradePositionHistory(this.extend(request, params));
2157
+ const response = await this.privateGetV1FapiTradePositionHistory(this.extend(request, params));
2156
2158
  //
2157
2159
  //
2158
2160
  const data = this.safeList(response, 'data', []);
@@ -2163,7 +2165,7 @@ export default class bydfi extends Exchange {
2163
2165
  * @method
2164
2166
  * @name bydfi#fetchPositionsHistory
2165
2167
  * @description fetches historical positions
2166
- * @see https://developers.bydfi.com/en/swap/trade#query-historical-position-profit-and-loss-records
2168
+ * @see https://developers.bydfi.com/en/futures/trade#query-historical-position-profit-and-loss-records
2167
2169
  * @param {string[]} symbols a list of unified market symbols
2168
2170
  * @param {int} [since] timestamp in ms of the earliest position to fetch , params["until"] - since <= 7 days
2169
2171
  * @param {int} [limit] the maximum amount of records to fetch (default 500, max 500)
@@ -2184,7 +2186,7 @@ export default class bydfi extends Exchange {
2184
2186
  if (limit !== undefined) {
2185
2187
  request['limit'] = limit;
2186
2188
  }
2187
- const response = await this.privateGetV1SwapTradePositionHistory(this.extend(request, params));
2189
+ const response = await this.privateGetV1FapiTradePositionHistory(this.extend(request, params));
2188
2190
  //
2189
2191
  // {
2190
2192
  // "code": 200,
@@ -2235,7 +2237,7 @@ export default class bydfi extends Exchange {
2235
2237
  * @method
2236
2238
  * @name bydfi#fetchMarginMode
2237
2239
  * @description fetches the margin mode of a trading pair
2238
- * @see https://developers.bydfi.com/en/swap/user#margin-mode-query
2240
+ * @see https://developers.bydfi.com/en/futures/user#margin-mode-query
2239
2241
  * @param {string} symbol unified symbol of the market to fetch the margin mode for
2240
2242
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2241
2243
  * @param {string} [params.contractType] FUTURE or DELIVERY, default is FUTURE
@@ -2254,7 +2256,7 @@ export default class bydfi extends Exchange {
2254
2256
  'symbol': market['id'],
2255
2257
  'wallet': wallet,
2256
2258
  };
2257
- const response = await this.privateGetV1SwapUserDataAssetsMargin(this.extend(request, params));
2259
+ const response = await this.privateGetV1FapiUserDataAssetsMargin(this.extend(request, params));
2258
2260
  //
2259
2261
  // {
2260
2262
  // "code": 200,
@@ -2282,7 +2284,7 @@ export default class bydfi extends Exchange {
2282
2284
  * @method
2283
2285
  * @name bydfi#setMarginMode
2284
2286
  * @description set margin mode to 'cross' or 'isolated'
2285
- * @see https://developers.bydfi.com/en/swap/user#change-margin-type-cross-margin
2287
+ * @see https://developers.bydfi.com/en/futures/user#change-margin-type-cross-margin
2286
2288
  * @param {string} marginMode 'cross' or 'isolated'
2287
2289
  * @param {string} symbol unified market symbol
2288
2290
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2310,13 +2312,13 @@ export default class bydfi extends Exchange {
2310
2312
  'marginType': marginMode.toUpperCase(),
2311
2313
  'wallet': wallet,
2312
2314
  };
2313
- return await this.privatePostV1SwapUserDataMarginType(this.extend(request, params));
2315
+ return await this.privatePostV1FapiUserDataMarginType(this.extend(request, params));
2314
2316
  }
2315
2317
  /**
2316
2318
  * @method
2317
2319
  * @name bydfi#setPositionMode
2318
2320
  * @description set hedged to true or false for a market, hedged for bydfi is set identically for all markets with same settle currency
2319
- * @see https://developers.bydfi.com/en/swap/user#change-position-mode-dual
2321
+ * @see https://developers.bydfi.com/en/futures/user#change-position-mode-dual
2320
2322
  * @param {bool} hedged set to true to use dualSidePosition
2321
2323
  * @param {string} [symbol] not used by bydfi setPositionMode ()
2322
2324
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2350,13 +2352,13 @@ export default class bydfi extends Exchange {
2350
2352
  // "success": true
2351
2353
  // }
2352
2354
  //
2353
- return await this.privatePostV1SwapUserDataPositionSideDual(this.extend(request, params));
2355
+ return await this.privatePostV1FapiUserDataPositionSideDual(this.extend(request, params));
2354
2356
  }
2355
2357
  /**
2356
2358
  * @method
2357
2359
  * @name bydfi#fetchPositionMode
2358
2360
  * @description fetchs the position mode, hedged or one way, hedged for bydfi is set identically for all markets with same settle currency
2359
- * @see https://developers.bydfi.com/en/swap/user#get-position-mode
2361
+ * @see https://developers.bydfi.com/en/futures/user#get-position-mode
2360
2362
  * @param {string} [symbol] unified symbol of the market to fetch the order book for
2361
2363
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2362
2364
  * @param {string} [params.contractType] FUTURE or DELIVERY, default is FUTURE
@@ -2383,7 +2385,7 @@ export default class bydfi extends Exchange {
2383
2385
  'settleCoin': settleCoin,
2384
2386
  'wallet': wallet,
2385
2387
  };
2386
- const response = await this.privateGetV1SwapUserDataPositionSideDual(this.extend(request, params));
2388
+ const response = await this.privateGetV1FapiUserDataPositionSideDual(this.extend(request, params));
2387
2389
  //
2388
2390
  // {
2389
2391
  // "code": 200,
@@ -2413,22 +2415,24 @@ export default class bydfi extends Exchange {
2413
2415
  * @name bydfi#fetchBalance
2414
2416
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
2415
2417
  * @see https://developers.bydfi.com/en/account#asset-inquiry
2416
- * @see https://developers.bydfi.com/en/swap/user#asset-query
2418
+ * @see https://developers.bydfi.com/en/futures/user#asset-query
2417
2419
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2418
- * @param {string} [params.accountType] the type of account to fetch the balance for, either 'spot' or 'swap' or 'funding' (default is 'spot')
2420
+ * @param {string} [params.account] the type of account to fetch the balance for, either 'SPOT' or 'UMFUTURE' or 'CMFUTURE' or 'COPY' or 'GRID' or 'FUNDING' (default is 'SPOT')
2419
2421
  * @param {string} [params.wallet] *swap only* The unique code of a sub-wallet. W001 is the default wallet and the main wallet code of the contract
2420
2422
  * @param {string} [params.asset] currency id for the balance to fetch
2421
2423
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
2422
2424
  */
2423
2425
  async fetchBalance(params = {}) {
2424
2426
  await this.loadMarkets();
2425
- let accountType = 'spot';
2426
- [accountType, params] = this.handleOptionAndParams2(params, 'fetchBalance', 'accountType', 'type', accountType);
2427
+ let type = undefined;
2428
+ [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
2429
+ let wallet = undefined;
2430
+ [wallet, params] = this.handleOptionAndParams(params, 'fetchBalance', 'wallet');
2427
2431
  const request = {};
2428
2432
  let response = undefined;
2429
- if (accountType !== 'swap') {
2433
+ if (wallet === undefined) {
2430
2434
  const options = this.safeDict(this.options, 'accountsByType', {});
2431
- const parsedAccountType = this.safeString(options, accountType, accountType);
2435
+ const parsedAccountType = this.safeStringUpper(options, type, type);
2432
2436
  request['walletType'] = parsedAccountType;
2433
2437
  //
2434
2438
  // {
@@ -2449,8 +2453,6 @@ export default class bydfi extends Exchange {
2449
2453
  response = await this.privateGetV1AccountAssets(this.extend(request, params));
2450
2454
  }
2451
2455
  else {
2452
- let wallet = 'W001';
2453
- [wallet, params] = this.handleOptionAndParams(params, 'fetchBalance', 'wallet', wallet);
2454
2456
  request['wallet'] = wallet;
2455
2457
  //
2456
2458
  // {
@@ -2480,7 +2482,7 @@ export default class bydfi extends Exchange {
2480
2482
  // ],
2481
2483
  // "success": true
2482
2484
  // }
2483
- response = await this.privateGetV1SwapAccountBalance(this.extend(request, params));
2485
+ response = await this.privateGetV1FapiAccountBalance(this.extend(request, params));
2484
2486
  }
2485
2487
  const data = this.safeList(response, 'data', []);
2486
2488
  return this.parseBalance(data);