ccxt 4.3.1 → 4.3.3

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 (46) hide show
  1. package/README.md +6 -5
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +25 -0
  4. package/dist/cjs/src/binance.js +320 -21
  5. package/dist/cjs/src/bingx.js +2 -2
  6. package/dist/cjs/src/bitget.js +81 -4
  7. package/dist/cjs/src/coinbase.js +11 -2
  8. package/dist/cjs/src/coinbasepro.js +1 -1
  9. package/dist/cjs/src/coinex.js +109 -146
  10. package/dist/cjs/src/cryptocom.js +5 -5
  11. package/dist/cjs/src/hyperliquid.js +161 -13
  12. package/dist/cjs/src/okx.js +116 -0
  13. package/dist/cjs/src/poloniexfutures.js +12 -2
  14. package/dist/cjs/src/pro/hyperliquid.js +8 -7
  15. package/dist/cjs/src/pro/kraken.js +1 -1
  16. package/dist/cjs/src/pro/wazirx.js +2 -1
  17. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +27 -2
  18. package/dist/cjs/src/woo.js +110 -6
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/base/Exchange.d.ts +3 -1
  22. package/js/src/base/Exchange.js +25 -0
  23. package/js/src/base/types.d.ts +5 -0
  24. package/js/src/binance.d.ts +3 -0
  25. package/js/src/binance.js +320 -21
  26. package/js/src/bingx.js +3 -3
  27. package/js/src/bitget.d.ts +1 -0
  28. package/js/src/bitget.js +81 -4
  29. package/js/src/coinbase.js +11 -2
  30. package/js/src/coinbasepro.js +1 -1
  31. package/js/src/coinex.js +109 -146
  32. package/js/src/cryptocom.js +5 -5
  33. package/js/src/hyperliquid.d.ts +3 -1
  34. package/js/src/hyperliquid.js +162 -14
  35. package/js/src/okx.d.ts +2 -0
  36. package/js/src/okx.js +116 -0
  37. package/js/src/poloniexfutures.js +12 -2
  38. package/js/src/pro/hyperliquid.js +8 -7
  39. package/js/src/pro/kraken.js +1 -1
  40. package/js/src/pro/wazirx.js +2 -1
  41. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +2 -2
  42. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -357
  43. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +27 -0
  44. package/js/src/woo.d.ts +2 -0
  45. package/js/src/woo.js +110 -6
  46. package/package.json +1 -1
package/README.md CHANGED
@@ -41,6 +41,7 @@ Current feature list:
41
41
  | [![bitmart](https://user-images.githubusercontent.com/1294454/129991357-8f47464b-d0f4-41d6-8a82-34122f0d1398.jpg)](http://www.bitmart.com/?r=rQCFLh) | bitmart | [BitMart](http://www.bitmart.com/?r=rQCFLh) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://developer-pro.bitmart.com/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with BitMart using CCXT's referral link for a 30% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d30%25&color=orange)](http://www.bitmart.com/?r=rQCFLh) |
42
42
  | [![bitmex](https://github.com/ccxt/ccxt/assets/43336371/cea9cfe5-c57e-4b84-b2ac-77b960b04445)](https://www.bitmex.com/app/register/NZTR1q) | bitmex | [BitMEX](https://www.bitmex.com/app/register/NZTR1q) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://www.bitmex.com/app/apiOverview) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with BitMEX using CCXT's referral link for a 10% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d10%25&color=orange)](https://www.bitmex.com/app/register/NZTR1q) |
43
43
  | [![bybit](https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg)](https://www.bybit.com/register?affiliate_id=35953) | bybit | [Bybit](https://www.bybit.com/register?affiliate_id=35953) | [![API Version 5](https://img.shields.io/badge/5-lightgray)](https://bybit-exchange.github.io/docs/inverse/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | |
44
+ | [![coinbase](https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg)](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | coinbase | [Coinbase Advanced](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://developers.coinbase.com/api/v2) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | |
44
45
  | [![coinbaseinternational](https://github.com/ccxt/ccxt/assets/43336371/866ae638-6ab5-4ebf-ab2c-cdcce9545625)](https://international.coinbase.com) | coinbaseinternational | [Coinbase International](https://international.coinbase.com) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.cloud.coinbase.com/intx/docs) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | |
45
46
  | [![coinex](https://user-images.githubusercontent.com/51840849/87182089-1e05fa00-c2ec-11ea-8da9-cc73b45abbbc.jpg)](https://www.coinex.com/register?refer_code=yw5fz) | coinex | [CoinEx](https://www.coinex.com/register?refer_code=yw5fz) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.coinex.com/api/v2) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | |
46
47
  | [![cryptocom](https://user-images.githubusercontent.com/1294454/147792121-38ed5e36-c229-48d6-b49a-48d05fc19ed4.jpeg)](https://crypto.com/exch/kdacthrnxt) | cryptocom | [Crypto.com](https://crypto.com/exch/kdacthrnxt) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with Crypto.com using CCXT's referral link for a 15% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d15%25&color=orange)](https://crypto.com/exch/kdacthrnxt) |
@@ -93,9 +94,9 @@ The CCXT library currently supports the following 97 cryptocurrency exchange mar
93
94
  | [![btcturk](https://user-images.githubusercontent.com/51840849/87153926-efbef500-c2c0-11ea-9842-05b63612c4b9.jpg)](https://www.btcturk.com) | btcturk | [BTCTurk](https://www.btcturk.com) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://github.com/BTCTrader/broker-api-docs) | | |
94
95
  | [![bybit](https://user-images.githubusercontent.com/51840849/76547799-daff5b80-649e-11ea-87fb-3be9bac08954.jpg)](https://www.bybit.com/register?affiliate_id=35953) | bybit | [Bybit](https://www.bybit.com/register?affiliate_id=35953) | [![API Version 5](https://img.shields.io/badge/5-lightgray)](https://bybit-exchange.github.io/docs/inverse/) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
95
96
  | [![cex](https://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpg)](https://cex.io/r/0/up105393824/0/) | cex | [CEX.IO](https://cex.io/r/0/up105393824/0/) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://cex.io/cex-api) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
96
- | [![coinbase](https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg)](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | coinbase | [Coinbase](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://developers.coinbase.com/api/v2) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
97
+ | [![coinbase](https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg)](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | coinbase | [Coinbase Advanced](https://www.coinbase.com/join/58cbe25a355148797479dbd2) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://developers.coinbase.com/api/v2) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
97
98
  | [![coinbaseinternational](https://github.com/ccxt/ccxt/assets/43336371/866ae638-6ab5-4ebf-ab2c-cdcce9545625)](https://international.coinbase.com) | coinbaseinternational | [Coinbase International](https://international.coinbase.com) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.cloud.coinbase.com/intx/docs) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
98
- | [![coinbasepro](https://user-images.githubusercontent.com/1294454/41764625-63b7ffde-760a-11e8-996d-a6328fa9347a.jpg)](https://pro.coinbase.com/) | coinbasepro | [Coinbase Pro](https://pro.coinbase.com/) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://docs.pro.coinbase.com) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
99
+ | [![coinbasepro](https://user-images.githubusercontent.com/1294454/41764625-63b7ffde-760a-11e8-996d-a6328fa9347a.jpg)](https://pro.coinbase.com/) | coinbasepro | [Coinbase Pro(Deprecated)](https://pro.coinbase.com/) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://docs.pro.coinbase.com) | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
99
100
  | [![coincheck](https://user-images.githubusercontent.com/51840849/87182088-1d6d6380-c2ec-11ea-9c64-8ab9f9b289f5.jpg)](https://coincheck.com) | coincheck | [coincheck](https://coincheck.com) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://coincheck.com/documents/exchange/api) | | |
100
101
  | [![coinex](https://user-images.githubusercontent.com/51840849/87182089-1e05fa00-c2ec-11ea-8da9-cc73b45abbbc.jpg)](https://www.coinex.com/register?refer_code=yw5fz) | coinex | [CoinEx](https://www.coinex.com/register?refer_code=yw5fz) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.coinex.com/api/v2) | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
101
102
  | [![coinlist](https://github-production-user-asset-6210df.s3.amazonaws.com/1294454/281108917-eff2ae1d-ce8a-4b2a-950d-8678b12da965.jpg)](https://coinlist.co) | coinlist | [Coinlist](https://coinlist.co) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://trade-docs.coinlist.co) | | |
@@ -212,13 +213,13 @@ console.log(version, Object.keys(exchanges));
212
213
 
213
214
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
214
215
 
215
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.1/dist/ccxt.browser.js
216
- * unpkg: https://unpkg.com/ccxt@4.3.1/dist/ccxt.browser.js
216
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.3/dist/ccxt.browser.js
217
+ * unpkg: https://unpkg.com/ccxt@4.3.3/dist/ccxt.browser.js
217
218
 
218
219
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
219
220
 
220
221
  ```HTML
221
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.1/dist/ccxt.browser.js"></script>
222
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.3/dist/ccxt.browser.js"></script>
222
223
  ```
223
224
 
224
225
  Creates a global `ccxt` object:
package/dist/cjs/ccxt.js CHANGED
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.3.1';
185
+ const version = '4.3.3';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -4477,6 +4477,9 @@ class Exchange {
4477
4477
  async cancelAllOrders(symbol = undefined, params = {}) {
4478
4478
  throw new errors.NotSupported(this.id + ' cancelAllOrders() is not supported yet');
4479
4479
  }
4480
+ async cancelOrdersForSymbols(orders, params = {}) {
4481
+ throw new errors.NotSupported(this.id + ' cancelOrdersForSymbols() is not supported yet');
4482
+ }
4480
4483
  async cancelAllOrdersWs(symbol = undefined, params = {}) {
4481
4484
  throw new errors.NotSupported(this.id + ' cancelAllOrdersWs() is not supported yet');
4482
4485
  }
@@ -5806,6 +5809,28 @@ class Exchange {
5806
5809
  parseLeverage(leverage, market = undefined) {
5807
5810
  throw new errors.NotSupported(this.id + ' parseLeverage () is not supported yet');
5808
5811
  }
5812
+ parseConversions(conversions, fromCurrencyKey = undefined, toCurrencyKey = undefined, since = undefined, limit = undefined, params = {}) {
5813
+ conversions = this.toArray(conversions);
5814
+ const result = [];
5815
+ let fromCurrency = undefined;
5816
+ let toCurrency = undefined;
5817
+ for (let i = 0; i < conversions.length; i++) {
5818
+ const entry = conversions[i];
5819
+ const fromId = this.safeString(entry, fromCurrencyKey);
5820
+ const toId = this.safeString(entry, toCurrencyKey);
5821
+ if (fromId !== undefined) {
5822
+ fromCurrency = this.currency(fromId);
5823
+ }
5824
+ if (toId !== undefined) {
5825
+ toCurrency = this.currency(toId);
5826
+ }
5827
+ const conversion = this.extend(this.parseConversion(entry, fromCurrency, toCurrency), params);
5828
+ result.push(conversion);
5829
+ }
5830
+ const sorted = this.sortBy(result, 'timestamp');
5831
+ const code = (fromCurrency !== undefined) ? fromCurrency['code'] : undefined;
5832
+ return this.filterByCurrencySinceLimit(sorted, code, since, limit);
5833
+ }
5809
5834
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
5810
5835
  throw new errors.NotSupported(this.id + ' parseConversion () is not supported yet');
5811
5836
  }
@@ -73,7 +73,9 @@ class binance extends binance$1 {
73
73
  'fetchClosedOrder': false,
74
74
  'fetchClosedOrders': 'emulated',
75
75
  'fetchConvertCurrencies': true,
76
- 'fetchConvertQuote': false,
76
+ 'fetchConvertQuote': true,
77
+ 'fetchConvertTrade': true,
78
+ 'fetchConvertTradeHistory': true,
77
79
  'fetchCrossBorrowRate': true,
78
80
  'fetchCrossBorrowRates': false,
79
81
  'fetchCurrencies': true,
@@ -12647,57 +12649,354 @@ class binance extends binance$1 {
12647
12649
  }
12648
12650
  return result;
12649
12651
  }
12650
- async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
12652
+ async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
12651
12653
  /**
12652
12654
  * @method
12653
- * @name binance#createConvertTrade
12654
- * @description convert from one currency to another
12655
- * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade
12656
- * @param {string} id the id of the trade that you want to make
12655
+ * @name binance#fetchConvertQuote
12656
+ * @description fetch a quote for converting from one currency to another
12657
+ * @see https://binance-docs.github.io/apidocs/spot/en/#send-quote-request-user_data
12657
12658
  * @param {string} fromCode the currency that you want to sell and convert from
12658
12659
  * @param {string} toCode the currency that you want to buy and convert into
12659
- * @param {float} [amount] how much you want to trade in units of the from currency
12660
+ * @param {float} amount how much you want to trade in units of the from currency
12660
12661
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12662
+ * @param {string} [params.walletType] either 'SPOT' or 'FUNDING', the default is 'SPOT'
12661
12663
  * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12662
12664
  */
12665
+ if (amount === undefined) {
12666
+ throw new errors.ArgumentsRequired(this.id + ' fetchConvertQuote() requires an amount argument');
12667
+ }
12663
12668
  await this.loadMarkets();
12664
12669
  const request = {
12665
- 'clientTranId': id,
12666
- 'asset': fromCode,
12667
- 'targetAsset': toCode,
12668
- 'amount': amount,
12670
+ 'fromAsset': fromCode,
12671
+ 'toAsset': toCode,
12672
+ 'fromAmount': amount,
12669
12673
  };
12670
- const response = await this.sapiPostAssetConvertTransfer(this.extend(request, params));
12674
+ const response = await this.sapiPostConvertGetQuote(this.extend(request, params));
12671
12675
  //
12672
12676
  // {
12673
- // "tranId": 118263407119,
12674
- // "status": "S"
12677
+ // "quoteId":"12415572564",
12678
+ // "ratio":"38163.7",
12679
+ // "inverseRatio":"0.0000262",
12680
+ // "validTimestamp":1623319461670,
12681
+ // "toAmount":"3816.37",
12682
+ // "fromAmount":"0.1"
12675
12683
  // }
12676
12684
  //
12677
12685
  const fromCurrency = this.currency(fromCode);
12678
12686
  const toCurrency = this.currency(toCode);
12679
12687
  return this.parseConversion(response, fromCurrency, toCurrency);
12680
12688
  }
12689
+ async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
12690
+ /**
12691
+ * @method
12692
+ * @name binance#createConvertTrade
12693
+ * @description convert from one currency to another
12694
+ * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade
12695
+ * @see https://binance-docs.github.io/apidocs/spot/en/#accept-quote-trade
12696
+ * @param {string} id the id of the trade that you want to make
12697
+ * @param {string} fromCode the currency that you want to sell and convert from
12698
+ * @param {string} toCode the currency that you want to buy and convert into
12699
+ * @param {float} [amount] how much you want to trade in units of the from currency
12700
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12701
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12702
+ */
12703
+ await this.loadMarkets();
12704
+ const request = {};
12705
+ let response = undefined;
12706
+ if ((fromCode === 'BUSD') || (toCode === 'BUSD')) {
12707
+ if (amount === undefined) {
12708
+ throw new errors.ArgumentsRequired(this.id + ' createConvertTrade() requires an amount argument');
12709
+ }
12710
+ request['clientTranId'] = id;
12711
+ request['asset'] = fromCode;
12712
+ request['targetAsset'] = toCode;
12713
+ request['amount'] = amount;
12714
+ response = await this.sapiPostAssetConvertTransfer(this.extend(request, params));
12715
+ //
12716
+ // {
12717
+ // "tranId": 118263407119,
12718
+ // "status": "S"
12719
+ // }
12720
+ //
12721
+ }
12722
+ else {
12723
+ request['quoteId'] = id;
12724
+ response = await this.sapiPostConvertAcceptQuote(this.extend(request, params));
12725
+ //
12726
+ // {
12727
+ // "orderId":"933256278426274426",
12728
+ // "createTime":1623381330472,
12729
+ // "orderStatus":"PROCESS"
12730
+ // }
12731
+ //
12732
+ }
12733
+ const fromCurrency = this.currency(fromCode);
12734
+ const toCurrency = this.currency(toCode);
12735
+ return this.parseConversion(response, fromCurrency, toCurrency);
12736
+ }
12737
+ async fetchConvertTrade(id, code = undefined, params = {}) {
12738
+ /**
12739
+ * @method
12740
+ * @name binance#fetchConvertTrade
12741
+ * @description fetch the data for a conversion trade
12742
+ * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data
12743
+ * @see https://binance-docs.github.io/apidocs/spot/en/#order-status-user_data
12744
+ * @param {string} id the id of the trade that you want to fetch
12745
+ * @param {string} [code] the unified currency code of the conversion trade
12746
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12747
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12748
+ */
12749
+ await this.loadMarkets();
12750
+ const request = {};
12751
+ let response = undefined;
12752
+ if (code === 'BUSD') {
12753
+ const msInDay = 86400000;
12754
+ const now = this.milliseconds();
12755
+ if (code !== undefined) {
12756
+ const currency = this.currency(code);
12757
+ request['asset'] = currency['id'];
12758
+ }
12759
+ request['tranId'] = id;
12760
+ request['startTime'] = now - msInDay;
12761
+ request['endTime'] = now;
12762
+ response = await this.sapiGetAssetConvertTransferQueryByPage(this.extend(request, params));
12763
+ //
12764
+ // {
12765
+ // "total": 3,
12766
+ // "rows": [
12767
+ // {
12768
+ // "tranId": 118263615991,
12769
+ // "type": 244,
12770
+ // "time": 1664442078000,
12771
+ // "deductedAsset": "BUSD",
12772
+ // "deductedAmount": "1",
12773
+ // "targetAsset": "USDC",
12774
+ // "targetAmount": "1",
12775
+ // "status": "S",
12776
+ // "accountType": "MAIN"
12777
+ // },
12778
+ // ]
12779
+ // }
12780
+ //
12781
+ }
12782
+ else {
12783
+ request['orderId'] = id;
12784
+ response = await this.sapiGetConvertOrderStatus(this.extend(request, params));
12785
+ //
12786
+ // {
12787
+ // "orderId":933256278426274426,
12788
+ // "orderStatus":"SUCCESS",
12789
+ // "fromAsset":"BTC",
12790
+ // "fromAmount":"0.00054414",
12791
+ // "toAsset":"USDT",
12792
+ // "toAmount":"20",
12793
+ // "ratio":"36755",
12794
+ // "inverseRatio":"0.00002721",
12795
+ // "createTime":1623381330472
12796
+ // }
12797
+ //
12798
+ }
12799
+ let data = response;
12800
+ if (code === 'BUSD') {
12801
+ const rows = this.safeList(response, 'rows', []);
12802
+ data = this.safeDict(rows, 0, {});
12803
+ }
12804
+ const fromCurrencyId = this.safeString2(data, 'deductedAsset', 'fromAsset');
12805
+ const toCurrencyId = this.safeString2(data, 'targetAsset', 'toAsset');
12806
+ let fromCurrency = undefined;
12807
+ let toCurrency = undefined;
12808
+ if (fromCurrencyId !== undefined) {
12809
+ fromCurrency = this.currency(fromCurrencyId);
12810
+ }
12811
+ if (toCurrencyId !== undefined) {
12812
+ toCurrency = this.currency(toCurrencyId);
12813
+ }
12814
+ return this.parseConversion(data, fromCurrency, toCurrency);
12815
+ }
12816
+ async fetchConvertTradeHistory(code = undefined, since = undefined, limit = undefined, params = {}) {
12817
+ /**
12818
+ * @method
12819
+ * @name binance#fetchConvertTradeHistory
12820
+ * @description fetch the users history of conversion trades
12821
+ * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data
12822
+ * @see https://binance-docs.github.io/apidocs/spot/en/#get-convert-trade-history-user_data
12823
+ * @param {string} [code] the unified currency code
12824
+ * @param {int} [since] the earliest time in ms to fetch conversions for
12825
+ * @param {int} [limit] the maximum number of conversion structures to retrieve
12826
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12827
+ * @param {int} [params.until] timestamp in ms of the latest conversion to fetch
12828
+ * @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12829
+ */
12830
+ await this.loadMarkets();
12831
+ const request = {};
12832
+ const msInThirtyDays = 2592000000;
12833
+ const now = this.milliseconds();
12834
+ if (since !== undefined) {
12835
+ request['startTime'] = since;
12836
+ }
12837
+ else {
12838
+ request['startTime'] = now - msInThirtyDays;
12839
+ }
12840
+ const endTime = this.safeString2(params, 'endTime', 'until');
12841
+ if (endTime !== undefined) {
12842
+ request['endTime'] = endTime;
12843
+ }
12844
+ else {
12845
+ request['endTime'] = now;
12846
+ }
12847
+ params = this.omit(params, 'until');
12848
+ let response = undefined;
12849
+ let responseQuery = undefined;
12850
+ let fromCurrencyKey = undefined;
12851
+ let toCurrencyKey = undefined;
12852
+ if (code === 'BUSD') {
12853
+ const currency = this.currency(code);
12854
+ request['asset'] = currency['id'];
12855
+ if (limit !== undefined) {
12856
+ request['size'] = limit;
12857
+ }
12858
+ fromCurrencyKey = 'deductedAsset';
12859
+ toCurrencyKey = 'targetAsset';
12860
+ responseQuery = 'rows';
12861
+ response = await this.sapiGetAssetConvertTransferQueryByPage(this.extend(request, params));
12862
+ //
12863
+ // {
12864
+ // "total": 3,
12865
+ // "rows": [
12866
+ // {
12867
+ // "tranId": 118263615991,
12868
+ // "type": 244,
12869
+ // "time": 1664442078000,
12870
+ // "deductedAsset": "BUSD",
12871
+ // "deductedAmount": "1",
12872
+ // "targetAsset": "USDC",
12873
+ // "targetAmount": "1",
12874
+ // "status": "S",
12875
+ // "accountType": "MAIN"
12876
+ // },
12877
+ // ]
12878
+ // }
12879
+ //
12880
+ }
12881
+ else {
12882
+ if (limit !== undefined) {
12883
+ request['limit'] = limit;
12884
+ }
12885
+ fromCurrencyKey = 'fromAsset';
12886
+ toCurrencyKey = 'toAsset';
12887
+ responseQuery = 'list';
12888
+ response = await this.sapiGetConvertTradeFlow(this.extend(request, params));
12889
+ //
12890
+ // {
12891
+ // "list": [
12892
+ // {
12893
+ // "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
12894
+ // "orderId": 940708407462087195,
12895
+ // "orderStatus": "SUCCESS",
12896
+ // "fromAsset": "USDT",
12897
+ // "fromAmount": "20",
12898
+ // "toAsset": "BNB",
12899
+ // "toAmount": "0.06154036",
12900
+ // "ratio": "0.00307702",
12901
+ // "inverseRatio": "324.99",
12902
+ // "createTime": 1624248872184
12903
+ // }
12904
+ // ],
12905
+ // "startTime": 1623824139000,
12906
+ // "endTime": 1626416139000,
12907
+ // "limit": 100,
12908
+ // "moreData": false
12909
+ // }
12910
+ //
12911
+ }
12912
+ const rows = this.safeList(response, responseQuery, []);
12913
+ return this.parseConversions(rows, fromCurrencyKey, toCurrencyKey, since, limit);
12914
+ }
12681
12915
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
12916
+ //
12917
+ // fetchConvertQuote
12918
+ //
12919
+ // {
12920
+ // "quoteId":"12415572564",
12921
+ // "ratio":"38163.7",
12922
+ // "inverseRatio":"0.0000262",
12923
+ // "validTimestamp":1623319461670,
12924
+ // "toAmount":"3816.37",
12925
+ // "fromAmount":"0.1"
12926
+ // }
12682
12927
  //
12683
12928
  // createConvertTrade
12684
12929
  //
12685
12930
  // {
12931
+ // "orderId":"933256278426274426",
12932
+ // "createTime":1623381330472,
12933
+ // "orderStatus":"PROCESS"
12934
+ // }
12935
+ //
12936
+ // createConvertTrade BUSD
12937
+ //
12938
+ // {
12686
12939
  // "tranId": 118263407119,
12687
12940
  // "status": "S"
12688
12941
  // }
12689
12942
  //
12690
- const fromCode = this.safeCurrencyCode(undefined, fromCurrency);
12691
- const toCode = this.safeCurrencyCode(undefined, toCurrency);
12943
+ // fetchConvertTrade, fetchConvertTradeHistory BUSD
12944
+ //
12945
+ // {
12946
+ // "tranId": 118263615991,
12947
+ // "type": 244,
12948
+ // "time": 1664442078000,
12949
+ // "deductedAsset": "BUSD",
12950
+ // "deductedAmount": "1",
12951
+ // "targetAsset": "USDC",
12952
+ // "targetAmount": "1",
12953
+ // "status": "S",
12954
+ // "accountType": "MAIN"
12955
+ // }
12956
+ //
12957
+ // fetchConvertTrade
12958
+ //
12959
+ // {
12960
+ // "orderId":933256278426274426,
12961
+ // "orderStatus":"SUCCESS",
12962
+ // "fromAsset":"BTC",
12963
+ // "fromAmount":"0.00054414",
12964
+ // "toAsset":"USDT",
12965
+ // "toAmount":"20",
12966
+ // "ratio":"36755",
12967
+ // "inverseRatio":"0.00002721",
12968
+ // "createTime":1623381330472
12969
+ // }
12970
+ //
12971
+ // fetchConvertTradeHistory
12972
+ //
12973
+ // {
12974
+ // "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
12975
+ // "orderId": 940708407462087195,
12976
+ // "orderStatus": "SUCCESS",
12977
+ // "fromAsset": "USDT",
12978
+ // "fromAmount": "20",
12979
+ // "toAsset": "BNB",
12980
+ // "toAmount": "0.06154036",
12981
+ // "ratio": "0.00307702",
12982
+ // "inverseRatio": "324.99",
12983
+ // "createTime": 1624248872184
12984
+ // }
12985
+ //
12986
+ const timestamp = this.safeIntegerN(conversion, ['time', 'validTimestamp', 'createTime']);
12987
+ const fromCur = this.safeString2(conversion, 'deductedAsset', 'fromAsset');
12988
+ const fromCode = this.safeCurrencyCode(fromCur, fromCurrency);
12989
+ const to = this.safeString2(conversion, 'targetAsset', 'toAsset');
12990
+ const toCode = this.safeCurrencyCode(to, toCurrency);
12692
12991
  return {
12693
12992
  'info': conversion,
12694
- 'timestamp': undefined,
12695
- 'datetime': undefined,
12696
- 'id': this.safeString(conversion, 'tranId'),
12993
+ 'timestamp': timestamp,
12994
+ 'datetime': this.iso8601(timestamp),
12995
+ 'id': this.safeStringN(conversion, ['tranId', 'orderId', 'quoteId']),
12697
12996
  'fromCurrency': fromCode,
12698
- 'fromAmount': undefined,
12997
+ 'fromAmount': this.safeNumber2(conversion, 'deductedAmount', 'fromAmount'),
12699
12998
  'toCurrency': toCode,
12700
- 'toAmount': undefined,
12999
+ 'toAmount': this.safeNumber2(conversion, 'targetAmount', 'toAmount'),
12701
13000
  'price': undefined,
12702
13001
  'fee': undefined,
12703
13002
  };
@@ -384,7 +384,7 @@ class bingx extends bingx$1 {
384
384
  '100400': errors.BadRequest,
385
385
  '100421': errors.BadSymbol,
386
386
  '100440': errors.ExchangeError,
387
- '100500': errors.ExchangeNotAvailable,
387
+ '100500': errors.OperationFailed,
388
388
  '100503': errors.ExchangeError,
389
389
  '80001': errors.BadRequest,
390
390
  '80012': errors.InsufficientFunds,
@@ -394,7 +394,7 @@ class bingx extends bingx$1 {
394
394
  '100414': errors.AccountSuspended,
395
395
  '100419': errors.PermissionDenied,
396
396
  '100437': errors.BadRequest,
397
- '101204': errors.InsufficientFunds, // bingx {"code":101204,"msg":"","data":{}}
397
+ '101204': errors.InsufficientFunds, // {"code":101204,"msg":"","data":{}}
398
398
  },
399
399
  'broad': {},
400
400
  },
@@ -66,6 +66,8 @@ class bitget extends bitget$1 {
66
66
  'fetchClosedOrders': true,
67
67
  'fetchConvertCurrencies': true,
68
68
  'fetchConvertQuote': true,
69
+ 'fetchConvertTrade': false,
70
+ 'fetchConvertTradeHistory': true,
69
71
  'fetchCrossBorrowRate': true,
70
72
  'fetchCrossBorrowRates': false,
71
73
  'fetchCurrencies': true,
@@ -8539,6 +8541,66 @@ class bitget extends bitget$1 {
8539
8541
  const toCurrency = this.currency(toCurrencyId);
8540
8542
  return this.parseConversion(data, undefined, toCurrency);
8541
8543
  }
8544
+ async fetchConvertTradeHistory(code = undefined, since = undefined, limit = undefined, params = {}) {
8545
+ /**
8546
+ * @method
8547
+ * @name bitget#fetchConvertTradeHistory
8548
+ * @description fetch the users history of conversion trades
8549
+ * @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Record
8550
+ * @param {string} [code] the unified currency code
8551
+ * @param {int} [since] the earliest time in ms to fetch conversions for
8552
+ * @param {int} [limit] the maximum number of conversion structures to retrieve
8553
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8554
+ * @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
8555
+ */
8556
+ await this.loadMarkets();
8557
+ const request = {};
8558
+ const msInDay = 86400000;
8559
+ const now = this.milliseconds();
8560
+ if (since !== undefined) {
8561
+ request['startTime'] = since;
8562
+ }
8563
+ else {
8564
+ request['startTime'] = now - msInDay;
8565
+ }
8566
+ const endTime = this.safeString2(params, 'endTime', 'until');
8567
+ if (endTime !== undefined) {
8568
+ request['endTime'] = endTime;
8569
+ }
8570
+ else {
8571
+ request['endTime'] = now;
8572
+ }
8573
+ if (limit !== undefined) {
8574
+ request['limit'] = limit;
8575
+ }
8576
+ params = this.omit(params, 'until');
8577
+ const response = await this.privateConvertGetV2ConvertConvertRecord(this.extend(request, params));
8578
+ //
8579
+ // {
8580
+ // "code": "00000",
8581
+ // "msg": "success",
8582
+ // "requestTime": 1712124371799,
8583
+ // "data": {
8584
+ // "dataList": [
8585
+ // {
8586
+ // "id": "1159296505255219205",
8587
+ // "fromCoin": "USDT",
8588
+ // "fromCoinSize": "5",
8589
+ // "cnvtPrice": "0.99940076",
8590
+ // "toCoin": "USDC",
8591
+ // "toCoinSize": "4.99700379",
8592
+ // "ts": "1712123746217",
8593
+ // "fee": "0"
8594
+ // }
8595
+ // ],
8596
+ // "endId": "1159296505255219205"
8597
+ // }
8598
+ // }
8599
+ //
8600
+ const data = this.safeDict(response, 'data', {});
8601
+ const dataList = this.safeList(data, 'dataList', []);
8602
+ return this.parseConversions(dataList, 'fromCoin', 'toCoin', since, limit);
8603
+ }
8542
8604
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
8543
8605
  //
8544
8606
  // fetchConvertQuote
@@ -8562,6 +8624,19 @@ class bitget extends bitget$1 {
8562
8624
  // "ts": "1712123746217"
8563
8625
  // }
8564
8626
  //
8627
+ // fetchConvertTradeHistory
8628
+ //
8629
+ // {
8630
+ // "id": "1159296505255219205",
8631
+ // "fromCoin": "USDT",
8632
+ // "fromCoinSize": "5",
8633
+ // "cnvtPrice": "0.99940076",
8634
+ // "toCoin": "USDC",
8635
+ // "toCoinSize": "4.99700379",
8636
+ // "ts": "1712123746217",
8637
+ // "fee": "0"
8638
+ // }
8639
+ //
8565
8640
  const timestamp = this.safeInteger(conversion, 'ts');
8566
8641
  const fromCoin = this.safeString(conversion, 'fromCoin');
8567
8642
  const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
@@ -8571,7 +8646,7 @@ class bitget extends bitget$1 {
8571
8646
  'info': conversion,
8572
8647
  'timestamp': timestamp,
8573
8648
  'datetime': this.iso8601(timestamp),
8574
- 'id': this.safeString(conversion, 'traceId'),
8649
+ 'id': this.safeString2(conversion, 'id', 'traceId'),
8575
8650
  'fromCurrency': fromCode,
8576
8651
  'fromAmount': this.safeNumber(conversion, 'fromCoinSize'),
8577
8652
  'toCurrency': toCode,
@@ -8650,6 +8725,8 @@ class bitget extends bitget$1 {
8650
8725
  //
8651
8726
  // spot
8652
8727
  //
8728
+ // {"code":"00000","msg":"success","requestTime":1713294492511,"data":[...]}"
8729
+ //
8653
8730
  // {"status":"fail","err_code":"01001","err_msg":"系统异常,请稍后重试"}
8654
8731
  // {"status":"error","ts":1595594160149,"err_code":"invalid-parameter","err_msg":"invalid size, valid range: [1,2000]"}
8655
8732
  // {"status":"error","ts":1595684716042,"err_code":"invalid-parameter","err_msg":"illegal sign invalid"}
@@ -8671,14 +8748,14 @@ class bitget extends bitget$1 {
8671
8748
  // {"code":"40108","msg":"","requestTime":1595885064600,"data":null}
8672
8749
  // {"order_id":"513468410013679613","client_oid":null,"symbol":"ethusd","result":false,"err_code":"order_no_exist_error","err_msg":"订单不存在!"}
8673
8750
  //
8674
- const message = this.safeString(response, 'err_msg');
8675
- const errorCode = this.safeString2(response, 'code', 'err_code');
8751
+ const message = this.safeString2(response, 'err_msg', 'msg');
8676
8752
  const feedback = this.id + ' ' + body;
8677
- const nonEmptyMessage = ((message !== undefined) && (message !== ''));
8753
+ const nonEmptyMessage = ((message !== undefined) && (message !== '') && (message !== 'success'));
8678
8754
  if (nonEmptyMessage) {
8679
8755
  this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
8680
8756
  this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
8681
8757
  }
8758
+ const errorCode = this.safeString2(response, 'code', 'err_code');
8682
8759
  const nonZeroErrorCode = (errorCode !== undefined) && (errorCode !== '00000');
8683
8760
  if (nonZeroErrorCode) {
8684
8761
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);