ccxt 4.2.64 → 4.2.66

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 (54) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +358 -96
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +12 -0
  6. package/dist/cjs/src/bigone.js +6 -2
  7. package/dist/cjs/src/binance.js +26 -3
  8. package/dist/cjs/src/bingx.js +13 -4
  9. package/dist/cjs/src/bitfinex2.js +4 -4
  10. package/dist/cjs/src/bitget.js +16 -2
  11. package/dist/cjs/src/bitmex.js +3 -1
  12. package/dist/cjs/src/blofin.js +35 -0
  13. package/dist/cjs/src/btcmarkets.js +12 -0
  14. package/dist/cjs/src/coinbase.js +12 -2
  15. package/dist/cjs/src/delta.js +95 -1
  16. package/dist/cjs/src/hitbtc.js +1 -1
  17. package/dist/cjs/src/kucoin.js +85 -61
  18. package/dist/cjs/src/pro/bitfinex2.js +5 -4
  19. package/dist/cjs/src/pro/bitget.js +3 -3
  20. package/dist/cjs/src/pro/bitmart.js +28 -6
  21. package/dist/cjs/src/pro/currencycom.js +1 -1
  22. package/doc/manual.rst +1 -0
  23. package/js/ccxt.d.ts +1 -1
  24. package/js/ccxt.js +1 -1
  25. package/js/src/abstract/bitget.d.ts +5 -0
  26. package/js/src/abstract/blofin.d.ts +1 -0
  27. package/js/src/abstract/kucoin.d.ts +9 -0
  28. package/js/src/abstract/kucoinfutures.d.ts +9 -0
  29. package/js/src/base/Exchange.js +12 -0
  30. package/js/src/bigone.js +6 -2
  31. package/js/src/binance.d.ts +1 -1
  32. package/js/src/binance.js +26 -3
  33. package/js/src/bingx.js +13 -4
  34. package/js/src/bitfinex2.js +4 -4
  35. package/js/src/bitget.js +16 -2
  36. package/js/src/bitmex.js +3 -1
  37. package/js/src/blofin.d.ts +3 -1
  38. package/js/src/blofin.js +35 -0
  39. package/js/src/btcmarkets.js +12 -0
  40. package/js/src/coinbase.js +12 -2
  41. package/js/src/delta.d.ts +3 -1
  42. package/js/src/delta.js +95 -1
  43. package/js/src/gate.d.ts +1 -1
  44. package/js/src/hitbtc.js +1 -1
  45. package/js/src/kucoin.js +85 -61
  46. package/js/src/okx.d.ts +1 -1
  47. package/js/src/pro/bitfinex2.js +5 -4
  48. package/js/src/pro/bitget.js +3 -3
  49. package/js/src/pro/bitmart.js +28 -6
  50. package/js/src/pro/currencycom.d.ts +1 -1
  51. package/js/src/pro/currencycom.js +1 -1
  52. package/js/src/woo.d.ts +1 -1
  53. package/package.json +2 -2
  54. package/skip-tests.json +35 -13
@@ -167,6 +167,8 @@ interface Exchange {
167
167
  privateSpotPostV2SpotWalletTransfer(params?: {}): Promise<implicitReturnType>;
168
168
  privateSpotPostV2SpotWalletSubaccountTransfer(params?: {}): Promise<implicitReturnType>;
169
169
  privateSpotPostV2SpotWalletWithdrawal(params?: {}): Promise<implicitReturnType>;
170
+ privateSpotPostV2SpotWalletCancelWithdrawal(params?: {}): Promise<implicitReturnType>;
171
+ privateSpotPostV2SpotWalletModifyDepositAccount(params?: {}): Promise<implicitReturnType>;
170
172
  privateMixGetMixV1AccountAccount(params?: {}): Promise<implicitReturnType>;
171
173
  privateMixGetMixV1AccountAccounts(params?: {}): Promise<implicitReturnType>;
172
174
  privateMixGetMixV1PositionSinglePosition(params?: {}): Promise<implicitReturnType>;
@@ -469,7 +471,10 @@ interface Exchange {
469
471
  privateConvertGetV2ConvertCurrencies(params?: {}): Promise<implicitReturnType>;
470
472
  privateConvertGetV2ConvertQuotedPrice(params?: {}): Promise<implicitReturnType>;
471
473
  privateConvertGetV2ConvertConvertRecord(params?: {}): Promise<implicitReturnType>;
474
+ privateConvertGetV2ConvertBgbConvertCoinList(params?: {}): Promise<implicitReturnType>;
475
+ privateConvertGetV2ConvertBgbConvertRecords(params?: {}): Promise<implicitReturnType>;
472
476
  privateConvertPostV2ConvertTrade(params?: {}): Promise<implicitReturnType>;
477
+ privateConvertPostV2ConvertBgbConvert(params?: {}): Promise<implicitReturnType>;
473
478
  privateEarnGetV2EarnSavingsProduct(params?: {}): Promise<implicitReturnType>;
474
479
  privateEarnGetV2EarnSavingsAccount(params?: {}): Promise<implicitReturnType>;
475
480
  privateEarnGetV2EarnSavingsAssets(params?: {}): Promise<implicitReturnType>;
@@ -18,6 +18,7 @@ interface Exchange {
18
18
  privateGetAccountBalance(params?: {}): Promise<implicitReturnType>;
19
19
  privateGetAccountPositions(params?: {}): Promise<implicitReturnType>;
20
20
  privateGetAccountLeverageInfo(params?: {}): Promise<implicitReturnType>;
21
+ privateGetAccountMarginMode(params?: {}): Promise<implicitReturnType>;
21
22
  privateGetAccountBatchLeverageInfo(params?: {}): Promise<implicitReturnType>;
22
23
  privateGetTradeOrdersTpslPending(params?: {}): Promise<implicitReturnType>;
23
24
  privateGetTradeOrdersHistory(params?: {}): Promise<implicitReturnType>;
@@ -187,6 +187,15 @@ interface Exchange {
187
187
  futuresPrivateDeleteOrders(params?: {}): Promise<implicitReturnType>;
188
188
  futuresPrivateDeleteStopOrders(params?: {}): Promise<implicitReturnType>;
189
189
  webExchangeGetCurrencyCurrencyChainInfo(params?: {}): Promise<implicitReturnType>;
190
+ brokerGetBrokerNdInfo(params?: {}): Promise<implicitReturnType>;
191
+ brokerGetBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
192
+ brokerGetBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
193
+ brokerGetBrokerNdRebaseDownload(params?: {}): Promise<implicitReturnType>;
194
+ brokerPostBrokerNdTransfer(params?: {}): Promise<implicitReturnType>;
195
+ brokerPostBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
196
+ brokerPostBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
197
+ brokerPostBrokerNdAccountUpdateApikey(params?: {}): Promise<implicitReturnType>;
198
+ brokerDeleteBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
190
199
  }
191
200
  declare abstract class Exchange extends _Exchange {
192
201
  }
@@ -204,6 +204,15 @@ interface kucoin {
204
204
  futuresPrivateDeleteSubApiKey(params?: {}): Promise<implicitReturnType>;
205
205
  webExchangeGetCurrencyCurrencyChainInfo(params?: {}): Promise<implicitReturnType>;
206
206
  webExchangeGetContractSymbolFundingRates(params?: {}): Promise<implicitReturnType>;
207
+ brokerGetBrokerNdInfo(params?: {}): Promise<implicitReturnType>;
208
+ brokerGetBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
209
+ brokerGetBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
210
+ brokerGetBrokerNdRebaseDownload(params?: {}): Promise<implicitReturnType>;
211
+ brokerPostBrokerNdTransfer(params?: {}): Promise<implicitReturnType>;
212
+ brokerPostBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
213
+ brokerPostBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
214
+ brokerPostBrokerNdAccountUpdateApikey(params?: {}): Promise<implicitReturnType>;
215
+ brokerDeleteBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
207
216
  }
208
217
  declare abstract class kucoin extends _kucoin {
209
218
  }
@@ -2692,6 +2692,18 @@ export default class Exchange {
2692
2692
  return this.filterBySymbolSinceLimit(results, symbol, since, limit);
2693
2693
  }
2694
2694
  calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
2695
+ /**
2696
+ * @method
2697
+ * @description calculates the presumptive fee that would be charged for an order
2698
+ * @param {string} symbol unified market symbol
2699
+ * @param {string} type 'market' or 'limit'
2700
+ * @param {string} side 'buy' or 'sell'
2701
+ * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts
2702
+ * @param {float} price the price for the order to be filled at, in units of the quote currency
2703
+ * @param {string} takerOrMaker 'taker' or 'maker'
2704
+ * @param {object} params
2705
+ * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
2706
+ */
2695
2707
  if (type === 'market' && takerOrMaker === 'maker') {
2696
2708
  throw new ArgumentsRequired(this.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.');
2697
2709
  }
package/js/src/bigone.js CHANGED
@@ -1544,7 +1544,11 @@ export default class bigone extends Exchange {
1544
1544
  }
1545
1545
  }
1546
1546
  request['type'] = uppercaseType;
1547
- params = this.omit(params, ['stop_price', 'stopPrice', 'triggerPrice', 'timeInForce']);
1547
+ const clientOrderId = this.safeString(params, 'clientOrderId');
1548
+ if (clientOrderId !== undefined) {
1549
+ request['client_order_id'] = clientOrderId;
1550
+ }
1551
+ params = this.omit(params, ['stop_price', 'stopPrice', 'triggerPrice', 'timeInForce', 'clientOrderId']);
1548
1552
  const response = await this.privatePostOrders(this.extend(request, params));
1549
1553
  //
1550
1554
  // {
@@ -1825,7 +1829,7 @@ export default class bigone extends Exchange {
1825
1829
  }
1826
1830
  else if (method === 'POST') {
1827
1831
  headers['Content-Type'] = 'application/json';
1828
- body = query;
1832
+ body = this.json(query);
1829
1833
  }
1830
1834
  }
1831
1835
  headers['User-Agent'] = 'ccxt/' + this.id + '-' + this.version;
@@ -8,7 +8,7 @@ export default class binance extends Exchange {
8
8
  describe(): any;
9
9
  isInverse(type: any, subType?: any): boolean;
10
10
  isLinear(type: any, subType?: any): boolean;
11
- setSandboxMode(enable: any): void;
11
+ setSandboxMode(enable: boolean): void;
12
12
  convertExpireDate(date: any): string;
13
13
  createExpiredOptionMarket(symbol: string): MarketInterface;
14
14
  market(symbol: any): any;
package/js/src/binance.js CHANGED
@@ -2528,6 +2528,7 @@ export default class binance extends Exchange {
2528
2528
  * @see https://binance-docs.github.io/apidocs/futures/en/#check-server-time // swap
2529
2529
  * @see https://binance-docs.github.io/apidocs/delivery/en/#check-server-time // future
2530
2530
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2531
+ * @param {string} [params.subType] "linear" or "inverse"
2531
2532
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
2532
2533
  */
2533
2534
  const defaultType = this.safeString2(this.options, 'fetchTime', 'defaultType', 'spot');
@@ -3323,6 +3324,7 @@ export default class binance extends Exchange {
3323
3324
  * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
3324
3325
  * @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
3325
3326
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
3327
+ * @param {string} [params.subType] "linear" or "inverse"
3326
3328
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
3327
3329
  */
3328
3330
  await this.loadMarkets();
@@ -3901,6 +3903,7 @@ export default class binance extends Exchange {
3901
3903
  * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker // future
3902
3904
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
3903
3905
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3906
+ * @param {string} [params.subType] "linear" or "inverse"
3904
3907
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
3905
3908
  */
3906
3909
  await this.loadMarkets();
@@ -3941,6 +3944,7 @@ export default class binance extends Exchange {
3941
3944
  * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
3942
3945
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
3943
3946
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3947
+ * @param {string} [params.subType] "linear" or "inverse"
3944
3948
  * @returns {object} a dictionary of lastprices structures
3945
3949
  */
3946
3950
  await this.loadMarkets();
@@ -4046,6 +4050,7 @@ export default class binance extends Exchange {
4046
4050
  * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
4047
4051
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
4048
4052
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4053
+ * @param {string} [params.subType] "linear" or "inverse"
4049
4054
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
4050
4055
  */
4051
4056
  await this.loadMarkets();
@@ -6472,6 +6477,7 @@ export default class binance extends Exchange {
6472
6477
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
6473
6478
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch open orders in the portfolio margin account
6474
6479
  * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account conditional orders
6480
+ * @param {string} [params.subType] "linear" or "inverse"
6475
6481
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6476
6482
  */
6477
6483
  await this.loadMarkets();
@@ -8615,6 +8621,7 @@ export default class binance extends Exchange {
8615
8621
  * @param {string} symbol unified market symbol
8616
8622
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8617
8623
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
8624
+ * @param {string} [params.subType] "linear" or "inverse"
8618
8625
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
8619
8626
  */
8620
8627
  await this.loadMarkets();
@@ -8683,6 +8690,7 @@ export default class binance extends Exchange {
8683
8690
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
8684
8691
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
8685
8692
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8693
+ * @param {string} [params.subType] "linear" or "inverse"
8686
8694
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
8687
8695
  */
8688
8696
  await this.loadMarkets();
@@ -8940,6 +8948,7 @@ export default class binance extends Exchange {
8940
8948
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8941
8949
  * @param {int} [params.until] timestamp in ms of the latest funding rate
8942
8950
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
8951
+ * @param {string} [params.subType] "linear" or "inverse"
8943
8952
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
8944
8953
  */
8945
8954
  await this.loadMarkets();
@@ -9013,6 +9022,7 @@ export default class binance extends Exchange {
9013
9022
  * @see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
9014
9023
  * @param {string[]|undefined} symbols list of unified market symbols
9015
9024
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9025
+ * @param {string} [params.subType] "linear" or "inverse"
9016
9026
  * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
9017
9027
  */
9018
9028
  await this.loadMarkets();
@@ -9636,6 +9646,7 @@ export default class binance extends Exchange {
9636
9646
  * @param {string[]|undefined} symbols list of unified market symbols
9637
9647
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9638
9648
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
9649
+ * @param {string} [params.subType] "linear" or "inverse"
9639
9650
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
9640
9651
  */
9641
9652
  await this.loadMarkets();
@@ -9950,6 +9961,7 @@ export default class binance extends Exchange {
9950
9961
  * @param {string[]|undefined} symbols list of unified market symbols
9951
9962
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9952
9963
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
9964
+ * @param {string} [params.subType] "linear" or "inverse"
9953
9965
  * @returns {object} data on account positions
9954
9966
  */
9955
9967
  if (symbols !== undefined) {
@@ -10003,6 +10015,7 @@ export default class binance extends Exchange {
10003
10015
  * @param {string[]|undefined} symbols list of unified market symbols
10004
10016
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10005
10017
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
10018
+ * @param {string} [params.subType] "linear" or "inverse"
10006
10019
  * @returns {object} data on the positions risk
10007
10020
  */
10008
10021
  if (symbols !== undefined) {
@@ -10162,6 +10175,7 @@ export default class binance extends Exchange {
10162
10175
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10163
10176
  * @param {int} [params.until] timestamp in ms of the latest funding history entry
10164
10177
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
10178
+ * @param {string} [params.subType] "linear" or "inverse"
10165
10179
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
10166
10180
  */
10167
10181
  await this.loadMarkets();
@@ -10346,6 +10360,7 @@ export default class binance extends Exchange {
10346
10360
  * @param {string} symbol not used by binance setPositionMode ()
10347
10361
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10348
10362
  * @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
10363
+ * @param {string} [params.subType] "linear" or "inverse"
10349
10364
  * @returns {object} response from the exchange
10350
10365
  */
10351
10366
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
@@ -10374,7 +10389,7 @@ export default class binance extends Exchange {
10374
10389
  response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
10375
10390
  }
10376
10391
  }
10377
- else {
10392
+ else if (this.isLinear(type, subType)) {
10378
10393
  if (isPortfolioMargin) {
10379
10394
  response = await this.papiPostUmPositionSideDual(this.extend(request, params));
10380
10395
  }
@@ -10382,6 +10397,9 @@ export default class binance extends Exchange {
10382
10397
  response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
10383
10398
  }
10384
10399
  }
10400
+ else {
10401
+ throw new BadRequest(this.id + ' setPositionMode() supports linear and inverse contracts only');
10402
+ }
10385
10403
  //
10386
10404
  // {
10387
10405
  // "code": 200,
@@ -10401,6 +10419,7 @@ export default class binance extends Exchange {
10401
10419
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10402
10420
  * @param {string[]} [symbols] a list of unified market symbols
10403
10421
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10422
+ * @param {string} [params.subType] "linear" or "inverse"
10404
10423
  * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
10405
10424
  */
10406
10425
  await this.loadMarkets();
@@ -10675,6 +10694,7 @@ export default class binance extends Exchange {
10675
10694
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
10676
10695
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
10677
10696
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
10697
+ * @param {string} [params.subType] "linear" or "inverse"
10678
10698
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
10679
10699
  */
10680
10700
  await this.loadMarkets();
@@ -11818,6 +11838,8 @@ export default class binance extends Exchange {
11818
11838
  * @param {int} [params.until] timestamp in ms of the latest liquidation
11819
11839
  * @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
11820
11840
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
11841
+ * @param {string} [params.type] "spot"
11842
+ * @param {string} [params.subType] "linear" or "inverse"
11821
11843
  * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
11822
11844
  */
11823
11845
  await this.loadMarkets();
@@ -12143,8 +12165,8 @@ export default class binance extends Exchange {
12143
12165
  * @name binance#fetchPositionMode
12144
12166
  * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
12145
12167
  * @param {string} symbol unified symbol of the market to fetch the order book for
12146
- * @param {object} params extra parameters specific to the exchange API endpoint
12147
- * @param {string} params.subType "linear" or "inverse"
12168
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12169
+ * @param {string} [params.subType] "linear" or "inverse"
12148
12170
  * @returns {object} an object detailing whether the market is in hedged or one-way mode
12149
12171
  */
12150
12172
  let market = undefined;
@@ -12182,6 +12204,7 @@ export default class binance extends Exchange {
12182
12204
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
12183
12205
  * @param {string} symbol unified symbol of the market the order was made in
12184
12206
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12207
+ * @param {string} [params.subType] "linear" or "inverse"
12185
12208
  * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
12186
12209
  */
12187
12210
  await this.loadMarkets();
package/js/src/bingx.js CHANGED
@@ -1867,6 +1867,7 @@ export default class bingx extends Exchange {
1867
1867
  const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
1868
1868
  const trailingAmount = this.safeString(params, 'trailingAmount');
1869
1869
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
1870
+ const trailingType = this.safeString(params, 'trailingType', 'TRAILING_STOP_MARKET');
1870
1871
  const isTriggerOrder = triggerPrice !== undefined;
1871
1872
  const isStopLossPriceOrder = stopLossPrice !== undefined;
1872
1873
  const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
@@ -1913,7 +1914,7 @@ export default class bingx extends Exchange {
1913
1914
  }
1914
1915
  }
1915
1916
  else if (isTrailing) {
1916
- request['type'] = 'TRAILING_STOP_MARKET';
1917
+ request['type'] = trailingType;
1917
1918
  if (isTrailingAmountOrder) {
1918
1919
  request['price'] = this.parseToNumeric(trailingAmount);
1919
1920
  }
@@ -1968,7 +1969,7 @@ export default class bingx extends Exchange {
1968
1969
  }
1969
1970
  request['positionSide'] = positionSide;
1970
1971
  request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
1971
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId']);
1972
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
1972
1973
  }
1973
1974
  return this.extend(request, params);
1974
1975
  }
@@ -1999,14 +2000,22 @@ export default class bingx extends Exchange {
1999
2000
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
2000
2001
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
2001
2002
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
2003
+ * @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
2002
2004
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2003
2005
  */
2004
2006
  await this.loadMarkets();
2005
2007
  const market = this.market(symbol);
2008
+ const test = this.safeBool(params, 'test', false);
2009
+ params = this.omit(params, 'test');
2006
2010
  const request = this.createOrderRequest(symbol, type, side, amount, price, params);
2007
2011
  let response = undefined;
2008
2012
  if (market['swap']) {
2009
- response = await this.swapV2PrivatePostTradeOrder(request);
2013
+ if (test) {
2014
+ response = await this.swapV2PrivatePostTradeOrderTest(request);
2015
+ }
2016
+ else {
2017
+ response = await this.swapV2PrivatePostTradeOrder(request);
2018
+ }
2010
2019
  }
2011
2020
  else {
2012
2021
  response = await this.spotV1PrivatePostTradeOrder(request);
@@ -4060,7 +4069,7 @@ export default class bingx extends Exchange {
4060
4069
  * @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
4061
4070
  * @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
4062
4071
  * @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
4063
- * @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
4072
+ * @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
4064
4073
  * @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
4065
4074
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4066
4075
  */
@@ -3085,10 +3085,10 @@ export default class bitfinex2 extends Exchange {
3085
3085
  }
3086
3086
  const reversedArray = [];
3087
3087
  const rawRates = this.filterBySymbolSinceLimit(rates, symbol, since, limit);
3088
- const rawRatesLength = rawRates.length;
3089
- const ratesLength = Math.max(rawRatesLength - 1, 0);
3090
- for (let i = ratesLength; i >= 0; i--) {
3091
- const valueAtIndex = rawRates[i];
3088
+ const ratesLength = rawRates.length;
3089
+ for (let i = 0; i < ratesLength; i++) {
3090
+ const index = ratesLength - i - 1;
3091
+ const valueAtIndex = rawRates[index];
3092
3092
  reversedArray.push(valueAtIndex);
3093
3093
  }
3094
3094
  return reversedArray;
package/js/src/bitget.js CHANGED
@@ -374,6 +374,8 @@ export default class bitget extends Exchange {
374
374
  'v2/spot/wallet/transfer': 2,
375
375
  'v2/spot/wallet/subaccount-transfer': 2,
376
376
  'v2/spot/wallet/withdrawal': 2,
377
+ 'v2/spot/wallet/cancel-withdrawal': 2,
378
+ 'v2/spot/wallet/modify-deposit-account': 2,
377
379
  },
378
380
  },
379
381
  'mix': {
@@ -718,9 +720,12 @@ export default class bitget extends Exchange {
718
720
  'v2/convert/currencies': 2,
719
721
  'v2/convert/quoted-price': 2,
720
722
  'v2/convert/convert-record': 2,
723
+ 'v2/convert/bgb-convert-coin-list': 2,
724
+ 'v2/convert/bgb-convert-records': 2,
721
725
  },
722
726
  'post': {
723
727
  'v2/convert/trade': 2,
728
+ 'v2/convert/bgb-convert': 2,
724
729
  },
725
730
  },
726
731
  'earn': {
@@ -4925,6 +4930,7 @@ export default class bitget extends Exchange {
4925
4930
  * @name bitget#cancelAllOrders
4926
4931
  * @description cancel all open orders
4927
4932
  * @see https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
4933
+ * @see https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
4928
4934
  * @see https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
4929
4935
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
4930
4936
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
@@ -4952,7 +4958,7 @@ export default class bitget extends Exchange {
4952
4958
  const request = {
4953
4959
  'symbol': market['id'],
4954
4960
  };
4955
- const stop = this.safeValue2(params, 'stop', 'trigger');
4961
+ const stop = this.safeBool2(params, 'stop', 'trigger');
4956
4962
  params = this.omit(params, ['stop', 'trigger']);
4957
4963
  let response = undefined;
4958
4964
  if (market['spot']) {
@@ -4965,7 +4971,15 @@ export default class bitget extends Exchange {
4965
4971
  }
4966
4972
  }
4967
4973
  else {
4968
- response = await this.privateSpotPostV2SpotTradeCancelSymbolOrder(this.extend(request, params));
4974
+ if (stop) {
4975
+ const stopRequest = {
4976
+ 'symbolList': [market['id']],
4977
+ };
4978
+ response = await this.privateSpotPostV2SpotTradeBatchCancelPlanOrder(this.extend(stopRequest, params));
4979
+ }
4980
+ else {
4981
+ response = await this.privateSpotPostV2SpotTradeCancelSymbolOrder(this.extend(request, params));
4982
+ }
4969
4983
  }
4970
4984
  }
4971
4985
  else {
package/js/src/bitmex.js CHANGED
@@ -2550,7 +2550,9 @@ export default class bitmex extends Exchange {
2550
2550
  if (until !== undefined) {
2551
2551
  request['endTime'] = this.iso8601(until);
2552
2552
  }
2553
- request['reverse'] = true;
2553
+ if ((since === undefined) && (until === undefined)) {
2554
+ request['reverse'] = true;
2555
+ }
2554
2556
  const response = await this.publicGetFunding(this.extend(request, params));
2555
2557
  //
2556
2558
  // [
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/blofin.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages, MarginMode } from './base/types.js';
3
3
  /**
4
4
  * @class blofin
5
5
  * @augments Exchange
@@ -116,6 +116,8 @@ export default class blofin extends Exchange {
116
116
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
117
117
  closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
118
118
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
119
+ fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
120
+ parseMarginMode(marginMode: any, market?: any): MarginMode;
119
121
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
120
122
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
121
123
  url: string;
package/js/src/blofin.js CHANGED
@@ -85,6 +85,8 @@ export default class blofin extends Exchange {
85
85
  'fetchLeverage': true,
86
86
  'fetchLeverages': true,
87
87
  'fetchLeverageTiers': false,
88
+ 'fetchMarginMode': true,
89
+ 'fetchMarginModes': false,
88
90
  'fetchMarketLeverageTiers': false,
89
91
  'fetchMarkets': true,
90
92
  'fetchMarkOHLCV': false,
@@ -188,6 +190,7 @@ export default class blofin extends Exchange {
188
190
  'account/balance': 1,
189
191
  'account/positions': 1,
190
192
  'account/leverage-info': 1,
193
+ 'account/margin-mode': 1,
191
194
  'account/batch-leverage-info': 1,
192
195
  'trade/orders-tpsl-pending': 1,
193
196
  'trade/orders-history': 1,
@@ -2108,6 +2111,38 @@ export default class blofin extends Exchange {
2108
2111
  const data = this.safeList(response, 'data', []);
2109
2112
  return this.parseOrders(data, market, since, limit);
2110
2113
  }
2114
+ async fetchMarginMode(symbol, params = {}) {
2115
+ /**
2116
+ * @method
2117
+ * @name blofin#fetchMarginMode
2118
+ * @description fetches the margin mode of a trading pair
2119
+ * @see https://docs.blofin.com/index.html#get-margin-mode
2120
+ * @param {string} symbol unified symbol of the market to fetch the margin mode for
2121
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2122
+ * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
2123
+ */
2124
+ await this.loadMarkets();
2125
+ const market = this.market(symbol);
2126
+ const response = await this.privateGetAccountMarginMode(params);
2127
+ //
2128
+ // {
2129
+ // "code": "0",
2130
+ // "msg": "success",
2131
+ // "data": {
2132
+ // "marginMode": "cross"
2133
+ // }
2134
+ // }
2135
+ //
2136
+ const data = this.safeDict(response, 'data', {});
2137
+ return this.parseMarginMode(data, market);
2138
+ }
2139
+ parseMarginMode(marginMode, market = undefined) {
2140
+ return {
2141
+ 'info': marginMode,
2142
+ 'symbol': market['symbol'],
2143
+ 'marginMode': this.safeString(marginMode, 'marginMode'),
2144
+ };
2145
+ }
2111
2146
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2112
2147
  if (response === undefined) {
2113
2148
  return undefined; // fallback to default error handler
@@ -917,6 +917,18 @@ export default class btcmarkets extends Exchange {
917
917
  return await this.privateDeleteOrdersId(this.extend(request, params));
918
918
  }
919
919
  calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
920
+ /**
921
+ * @method
922
+ * @description calculates the presumptive fee that would be charged for an order
923
+ * @param {string} symbol unified market symbol
924
+ * @param {string} type not used by btcmarkets.calculateFee
925
+ * @param {string} side not used by btcmarkets.calculateFee
926
+ * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts
927
+ * @param {float} price the price for the order to be filled at, in units of the quote currency
928
+ * @param {string} takerOrMaker 'taker' or 'maker'
929
+ * @param {object} params
930
+ * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
931
+ */
920
932
  const market = this.markets[symbol];
921
933
  let currency = undefined;
922
934
  let cost = undefined;
@@ -3724,7 +3724,8 @@ export default class coinbase extends Exchange {
3724
3724
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
3725
3725
  const version = api[0];
3726
3726
  const signed = api[1] === 'private';
3727
- const pathPart = (version === 'v3') ? 'api/v3' : 'v2';
3727
+ const isV3 = version === 'v3';
3728
+ const pathPart = (isV3) ? 'api/v3' : 'v2';
3728
3729
  let fullPath = '/' + pathPart + '/' + this.implodeParams(path, params);
3729
3730
  const query = this.omit(params, this.extractParams(path));
3730
3731
  const savedPath = fullPath;
@@ -3768,8 +3769,17 @@ export default class coinbase extends Exchange {
3768
3769
  payload = body;
3769
3770
  }
3770
3771
  }
3771
- // 'GET' doesn't need payload in the signature. inside url is enough
3772
+ else {
3773
+ if (!isV3) {
3774
+ if (Object.keys(query).length) {
3775
+ payload += '?' + this.urlencode(query);
3776
+ }
3777
+ }
3778
+ }
3779
+ // v3: 'GET' doesn't need payload in the signature. inside url is enough
3772
3780
  // https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
3781
+ // v2: 'GET' require payload in the signature
3782
+ // https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-key-authentication
3773
3783
  const auth = timestampString + method + savedPath + payload;
3774
3784
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
3775
3785
  headers = {
package/js/src/delta.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/delta.js';
2
- import type { Balances, Currency, Greeks, Int, Market, MarketInterface, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Position, Leverage } from './base/types.js';
2
+ import type { Balances, Currency, Greeks, Int, Market, MarketInterface, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Position, Leverage, MarginMode } from './base/types.js';
3
3
  /**
4
4
  * @class delta
5
5
  * @augments Exchange
@@ -188,6 +188,8 @@ export default class delta extends Exchange {
188
188
  info: any;
189
189
  };
190
190
  closeAllPositions(params?: {}): Promise<Position[]>;
191
+ fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
192
+ parseMarginMode(marginMode: any, market?: any): MarginMode;
191
193
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
192
194
  url: string;
193
195
  method: string;