ccxt 4.3.2 → 4.3.4

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 (42) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +22 -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 +76 -1
  7. package/dist/cjs/src/coinbase.js +9 -1
  8. package/dist/cjs/src/hyperliquid.js +87 -13
  9. package/dist/cjs/src/okx.js +116 -0
  10. package/dist/cjs/src/phemex.js +5 -0
  11. package/dist/cjs/src/poloniexfutures.js +12 -2
  12. package/dist/cjs/src/pro/hyperliquid.js +8 -7
  13. package/dist/cjs/src/pro/kraken.js +1 -1
  14. package/dist/cjs/src/pro/wazirx.js +2 -1
  15. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +27 -2
  16. package/dist/cjs/src/woo.js +110 -6
  17. package/js/ccxt.d.ts +1 -1
  18. package/js/ccxt.js +1 -1
  19. package/js/src/base/Exchange.d.ts +1 -0
  20. package/js/src/base/Exchange.js +22 -0
  21. package/js/src/binance.d.ts +3 -0
  22. package/js/src/binance.js +320 -21
  23. package/js/src/bingx.js +3 -3
  24. package/js/src/bitget.d.ts +1 -0
  25. package/js/src/bitget.js +76 -1
  26. package/js/src/coinbase.js +9 -1
  27. package/js/src/coinbasepro.d.ts +1 -1
  28. package/js/src/hyperliquid.d.ts +1 -0
  29. package/js/src/hyperliquid.js +87 -13
  30. package/js/src/okx.d.ts +2 -0
  31. package/js/src/okx.js +116 -0
  32. package/js/src/phemex.js +5 -0
  33. package/js/src/poloniexfutures.js +12 -2
  34. package/js/src/pro/hyperliquid.js +8 -7
  35. package/js/src/pro/kraken.js +1 -1
  36. package/js/src/pro/wazirx.js +2 -1
  37. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +2 -2
  38. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -357
  39. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +27 -0
  40. package/js/src/woo.d.ts +2 -0
  41. package/js/src/woo.js +110 -6
  42. package/package.json +1 -1
@@ -5796,6 +5796,28 @@ export default class Exchange {
5796
5796
  parseLeverage(leverage, market = undefined) {
5797
5797
  throw new NotSupported(this.id + ' parseLeverage () is not supported yet');
5798
5798
  }
5799
+ parseConversions(conversions, fromCurrencyKey = undefined, toCurrencyKey = undefined, since = undefined, limit = undefined, params = {}) {
5800
+ conversions = this.toArray(conversions);
5801
+ const result = [];
5802
+ let fromCurrency = undefined;
5803
+ let toCurrency = undefined;
5804
+ for (let i = 0; i < conversions.length; i++) {
5805
+ const entry = conversions[i];
5806
+ const fromId = this.safeString(entry, fromCurrencyKey);
5807
+ const toId = this.safeString(entry, toCurrencyKey);
5808
+ if (fromId !== undefined) {
5809
+ fromCurrency = this.currency(fromId);
5810
+ }
5811
+ if (toId !== undefined) {
5812
+ toCurrency = this.currency(toId);
5813
+ }
5814
+ const conversion = this.extend(this.parseConversion(entry, fromCurrency, toCurrency), params);
5815
+ result.push(conversion);
5816
+ }
5817
+ const sorted = this.sortBy(result, 'timestamp');
5818
+ const code = (fromCurrency !== undefined) ? fromCurrency['code'] : undefined;
5819
+ return this.filterByCurrencySinceLimit(sorted, code, since, limit);
5820
+ }
5799
5821
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
5800
5822
  throw new NotSupported(this.id + ' parseConversion () is not supported yet');
5801
5823
  }
@@ -440,6 +440,9 @@ export default class binance extends Exchange {
440
440
  };
441
441
  fetchMarginAdjustmentHistory(symbol?: Str, type?: Str, since?: Num, limit?: Num, params?: {}): Promise<MarginModification[]>;
442
442
  fetchConvertCurrencies(params?: {}): Promise<Currencies>;
443
+ fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
443
444
  createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
445
+ fetchConvertTrade(id: string, code?: Str, params?: {}): Promise<Conversion>;
446
+ fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
444
447
  parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
445
448
  }
package/js/src/binance.js CHANGED
@@ -76,7 +76,9 @@ export default class binance extends Exchange {
76
76
  'fetchClosedOrder': false,
77
77
  'fetchClosedOrders': 'emulated',
78
78
  'fetchConvertCurrencies': true,
79
- 'fetchConvertQuote': false,
79
+ 'fetchConvertQuote': true,
80
+ 'fetchConvertTrade': true,
81
+ 'fetchConvertTradeHistory': true,
80
82
  'fetchCrossBorrowRate': true,
81
83
  'fetchCrossBorrowRates': false,
82
84
  'fetchCurrencies': true,
@@ -12650,57 +12652,354 @@ export default class binance extends Exchange {
12650
12652
  }
12651
12653
  return result;
12652
12654
  }
12653
- async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
12655
+ async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
12654
12656
  /**
12655
12657
  * @method
12656
- * @name binance#createConvertTrade
12657
- * @description convert from one currency to another
12658
- * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade
12659
- * @param {string} id the id of the trade that you want to make
12658
+ * @name binance#fetchConvertQuote
12659
+ * @description fetch a quote for converting from one currency to another
12660
+ * @see https://binance-docs.github.io/apidocs/spot/en/#send-quote-request-user_data
12660
12661
  * @param {string} fromCode the currency that you want to sell and convert from
12661
12662
  * @param {string} toCode the currency that you want to buy and convert into
12662
- * @param {float} [amount] how much you want to trade in units of the from currency
12663
+ * @param {float} amount how much you want to trade in units of the from currency
12663
12664
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12665
+ * @param {string} [params.walletType] either 'SPOT' or 'FUNDING', the default is 'SPOT'
12664
12666
  * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12665
12667
  */
12668
+ if (amount === undefined) {
12669
+ throw new ArgumentsRequired(this.id + ' fetchConvertQuote() requires an amount argument');
12670
+ }
12666
12671
  await this.loadMarkets();
12667
12672
  const request = {
12668
- 'clientTranId': id,
12669
- 'asset': fromCode,
12670
- 'targetAsset': toCode,
12671
- 'amount': amount,
12673
+ 'fromAsset': fromCode,
12674
+ 'toAsset': toCode,
12675
+ 'fromAmount': amount,
12672
12676
  };
12673
- const response = await this.sapiPostAssetConvertTransfer(this.extend(request, params));
12677
+ const response = await this.sapiPostConvertGetQuote(this.extend(request, params));
12674
12678
  //
12675
12679
  // {
12676
- // "tranId": 118263407119,
12677
- // "status": "S"
12680
+ // "quoteId":"12415572564",
12681
+ // "ratio":"38163.7",
12682
+ // "inverseRatio":"0.0000262",
12683
+ // "validTimestamp":1623319461670,
12684
+ // "toAmount":"3816.37",
12685
+ // "fromAmount":"0.1"
12678
12686
  // }
12679
12687
  //
12680
12688
  const fromCurrency = this.currency(fromCode);
12681
12689
  const toCurrency = this.currency(toCode);
12682
12690
  return this.parseConversion(response, fromCurrency, toCurrency);
12683
12691
  }
12692
+ async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
12693
+ /**
12694
+ * @method
12695
+ * @name binance#createConvertTrade
12696
+ * @description convert from one currency to another
12697
+ * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade
12698
+ * @see https://binance-docs.github.io/apidocs/spot/en/#accept-quote-trade
12699
+ * @param {string} id the id of the trade that you want to make
12700
+ * @param {string} fromCode the currency that you want to sell and convert from
12701
+ * @param {string} toCode the currency that you want to buy and convert into
12702
+ * @param {float} [amount] how much you want to trade in units of the from currency
12703
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12704
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12705
+ */
12706
+ await this.loadMarkets();
12707
+ const request = {};
12708
+ let response = undefined;
12709
+ if ((fromCode === 'BUSD') || (toCode === 'BUSD')) {
12710
+ if (amount === undefined) {
12711
+ throw new ArgumentsRequired(this.id + ' createConvertTrade() requires an amount argument');
12712
+ }
12713
+ request['clientTranId'] = id;
12714
+ request['asset'] = fromCode;
12715
+ request['targetAsset'] = toCode;
12716
+ request['amount'] = amount;
12717
+ response = await this.sapiPostAssetConvertTransfer(this.extend(request, params));
12718
+ //
12719
+ // {
12720
+ // "tranId": 118263407119,
12721
+ // "status": "S"
12722
+ // }
12723
+ //
12724
+ }
12725
+ else {
12726
+ request['quoteId'] = id;
12727
+ response = await this.sapiPostConvertAcceptQuote(this.extend(request, params));
12728
+ //
12729
+ // {
12730
+ // "orderId":"933256278426274426",
12731
+ // "createTime":1623381330472,
12732
+ // "orderStatus":"PROCESS"
12733
+ // }
12734
+ //
12735
+ }
12736
+ const fromCurrency = this.currency(fromCode);
12737
+ const toCurrency = this.currency(toCode);
12738
+ return this.parseConversion(response, fromCurrency, toCurrency);
12739
+ }
12740
+ async fetchConvertTrade(id, code = undefined, params = {}) {
12741
+ /**
12742
+ * @method
12743
+ * @name binance#fetchConvertTrade
12744
+ * @description fetch the data for a conversion trade
12745
+ * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data
12746
+ * @see https://binance-docs.github.io/apidocs/spot/en/#order-status-user_data
12747
+ * @param {string} id the id of the trade that you want to fetch
12748
+ * @param {string} [code] the unified currency code of the conversion trade
12749
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12750
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12751
+ */
12752
+ await this.loadMarkets();
12753
+ const request = {};
12754
+ let response = undefined;
12755
+ if (code === 'BUSD') {
12756
+ const msInDay = 86400000;
12757
+ const now = this.milliseconds();
12758
+ if (code !== undefined) {
12759
+ const currency = this.currency(code);
12760
+ request['asset'] = currency['id'];
12761
+ }
12762
+ request['tranId'] = id;
12763
+ request['startTime'] = now - msInDay;
12764
+ request['endTime'] = now;
12765
+ response = await this.sapiGetAssetConvertTransferQueryByPage(this.extend(request, params));
12766
+ //
12767
+ // {
12768
+ // "total": 3,
12769
+ // "rows": [
12770
+ // {
12771
+ // "tranId": 118263615991,
12772
+ // "type": 244,
12773
+ // "time": 1664442078000,
12774
+ // "deductedAsset": "BUSD",
12775
+ // "deductedAmount": "1",
12776
+ // "targetAsset": "USDC",
12777
+ // "targetAmount": "1",
12778
+ // "status": "S",
12779
+ // "accountType": "MAIN"
12780
+ // },
12781
+ // ]
12782
+ // }
12783
+ //
12784
+ }
12785
+ else {
12786
+ request['orderId'] = id;
12787
+ response = await this.sapiGetConvertOrderStatus(this.extend(request, params));
12788
+ //
12789
+ // {
12790
+ // "orderId":933256278426274426,
12791
+ // "orderStatus":"SUCCESS",
12792
+ // "fromAsset":"BTC",
12793
+ // "fromAmount":"0.00054414",
12794
+ // "toAsset":"USDT",
12795
+ // "toAmount":"20",
12796
+ // "ratio":"36755",
12797
+ // "inverseRatio":"0.00002721",
12798
+ // "createTime":1623381330472
12799
+ // }
12800
+ //
12801
+ }
12802
+ let data = response;
12803
+ if (code === 'BUSD') {
12804
+ const rows = this.safeList(response, 'rows', []);
12805
+ data = this.safeDict(rows, 0, {});
12806
+ }
12807
+ const fromCurrencyId = this.safeString2(data, 'deductedAsset', 'fromAsset');
12808
+ const toCurrencyId = this.safeString2(data, 'targetAsset', 'toAsset');
12809
+ let fromCurrency = undefined;
12810
+ let toCurrency = undefined;
12811
+ if (fromCurrencyId !== undefined) {
12812
+ fromCurrency = this.currency(fromCurrencyId);
12813
+ }
12814
+ if (toCurrencyId !== undefined) {
12815
+ toCurrency = this.currency(toCurrencyId);
12816
+ }
12817
+ return this.parseConversion(data, fromCurrency, toCurrency);
12818
+ }
12819
+ async fetchConvertTradeHistory(code = undefined, since = undefined, limit = undefined, params = {}) {
12820
+ /**
12821
+ * @method
12822
+ * @name binance#fetchConvertTradeHistory
12823
+ * @description fetch the users history of conversion trades
12824
+ * @see https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data
12825
+ * @see https://binance-docs.github.io/apidocs/spot/en/#get-convert-trade-history-user_data
12826
+ * @param {string} [code] the unified currency code
12827
+ * @param {int} [since] the earliest time in ms to fetch conversions for
12828
+ * @param {int} [limit] the maximum number of conversion structures to retrieve
12829
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12830
+ * @param {int} [params.until] timestamp in ms of the latest conversion to fetch
12831
+ * @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
12832
+ */
12833
+ await this.loadMarkets();
12834
+ const request = {};
12835
+ const msInThirtyDays = 2592000000;
12836
+ const now = this.milliseconds();
12837
+ if (since !== undefined) {
12838
+ request['startTime'] = since;
12839
+ }
12840
+ else {
12841
+ request['startTime'] = now - msInThirtyDays;
12842
+ }
12843
+ const endTime = this.safeString2(params, 'endTime', 'until');
12844
+ if (endTime !== undefined) {
12845
+ request['endTime'] = endTime;
12846
+ }
12847
+ else {
12848
+ request['endTime'] = now;
12849
+ }
12850
+ params = this.omit(params, 'until');
12851
+ let response = undefined;
12852
+ let responseQuery = undefined;
12853
+ let fromCurrencyKey = undefined;
12854
+ let toCurrencyKey = undefined;
12855
+ if (code === 'BUSD') {
12856
+ const currency = this.currency(code);
12857
+ request['asset'] = currency['id'];
12858
+ if (limit !== undefined) {
12859
+ request['size'] = limit;
12860
+ }
12861
+ fromCurrencyKey = 'deductedAsset';
12862
+ toCurrencyKey = 'targetAsset';
12863
+ responseQuery = 'rows';
12864
+ response = await this.sapiGetAssetConvertTransferQueryByPage(this.extend(request, params));
12865
+ //
12866
+ // {
12867
+ // "total": 3,
12868
+ // "rows": [
12869
+ // {
12870
+ // "tranId": 118263615991,
12871
+ // "type": 244,
12872
+ // "time": 1664442078000,
12873
+ // "deductedAsset": "BUSD",
12874
+ // "deductedAmount": "1",
12875
+ // "targetAsset": "USDC",
12876
+ // "targetAmount": "1",
12877
+ // "status": "S",
12878
+ // "accountType": "MAIN"
12879
+ // },
12880
+ // ]
12881
+ // }
12882
+ //
12883
+ }
12884
+ else {
12885
+ if (limit !== undefined) {
12886
+ request['limit'] = limit;
12887
+ }
12888
+ fromCurrencyKey = 'fromAsset';
12889
+ toCurrencyKey = 'toAsset';
12890
+ responseQuery = 'list';
12891
+ response = await this.sapiGetConvertTradeFlow(this.extend(request, params));
12892
+ //
12893
+ // {
12894
+ // "list": [
12895
+ // {
12896
+ // "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
12897
+ // "orderId": 940708407462087195,
12898
+ // "orderStatus": "SUCCESS",
12899
+ // "fromAsset": "USDT",
12900
+ // "fromAmount": "20",
12901
+ // "toAsset": "BNB",
12902
+ // "toAmount": "0.06154036",
12903
+ // "ratio": "0.00307702",
12904
+ // "inverseRatio": "324.99",
12905
+ // "createTime": 1624248872184
12906
+ // }
12907
+ // ],
12908
+ // "startTime": 1623824139000,
12909
+ // "endTime": 1626416139000,
12910
+ // "limit": 100,
12911
+ // "moreData": false
12912
+ // }
12913
+ //
12914
+ }
12915
+ const rows = this.safeList(response, responseQuery, []);
12916
+ return this.parseConversions(rows, fromCurrencyKey, toCurrencyKey, since, limit);
12917
+ }
12684
12918
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
12919
+ //
12920
+ // fetchConvertQuote
12921
+ //
12922
+ // {
12923
+ // "quoteId":"12415572564",
12924
+ // "ratio":"38163.7",
12925
+ // "inverseRatio":"0.0000262",
12926
+ // "validTimestamp":1623319461670,
12927
+ // "toAmount":"3816.37",
12928
+ // "fromAmount":"0.1"
12929
+ // }
12685
12930
  //
12686
12931
  // createConvertTrade
12687
12932
  //
12688
12933
  // {
12934
+ // "orderId":"933256278426274426",
12935
+ // "createTime":1623381330472,
12936
+ // "orderStatus":"PROCESS"
12937
+ // }
12938
+ //
12939
+ // createConvertTrade BUSD
12940
+ //
12941
+ // {
12689
12942
  // "tranId": 118263407119,
12690
12943
  // "status": "S"
12691
12944
  // }
12692
12945
  //
12693
- const fromCode = this.safeCurrencyCode(undefined, fromCurrency);
12694
- const toCode = this.safeCurrencyCode(undefined, toCurrency);
12946
+ // fetchConvertTrade, fetchConvertTradeHistory BUSD
12947
+ //
12948
+ // {
12949
+ // "tranId": 118263615991,
12950
+ // "type": 244,
12951
+ // "time": 1664442078000,
12952
+ // "deductedAsset": "BUSD",
12953
+ // "deductedAmount": "1",
12954
+ // "targetAsset": "USDC",
12955
+ // "targetAmount": "1",
12956
+ // "status": "S",
12957
+ // "accountType": "MAIN"
12958
+ // }
12959
+ //
12960
+ // fetchConvertTrade
12961
+ //
12962
+ // {
12963
+ // "orderId":933256278426274426,
12964
+ // "orderStatus":"SUCCESS",
12965
+ // "fromAsset":"BTC",
12966
+ // "fromAmount":"0.00054414",
12967
+ // "toAsset":"USDT",
12968
+ // "toAmount":"20",
12969
+ // "ratio":"36755",
12970
+ // "inverseRatio":"0.00002721",
12971
+ // "createTime":1623381330472
12972
+ // }
12973
+ //
12974
+ // fetchConvertTradeHistory
12975
+ //
12976
+ // {
12977
+ // "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
12978
+ // "orderId": 940708407462087195,
12979
+ // "orderStatus": "SUCCESS",
12980
+ // "fromAsset": "USDT",
12981
+ // "fromAmount": "20",
12982
+ // "toAsset": "BNB",
12983
+ // "toAmount": "0.06154036",
12984
+ // "ratio": "0.00307702",
12985
+ // "inverseRatio": "324.99",
12986
+ // "createTime": 1624248872184
12987
+ // }
12988
+ //
12989
+ const timestamp = this.safeIntegerN(conversion, ['time', 'validTimestamp', 'createTime']);
12990
+ const fromCur = this.safeString2(conversion, 'deductedAsset', 'fromAsset');
12991
+ const fromCode = this.safeCurrencyCode(fromCur, fromCurrency);
12992
+ const to = this.safeString2(conversion, 'targetAsset', 'toAsset');
12993
+ const toCode = this.safeCurrencyCode(to, toCurrency);
12695
12994
  return {
12696
12995
  'info': conversion,
12697
- 'timestamp': undefined,
12698
- 'datetime': undefined,
12699
- 'id': this.safeString(conversion, 'tranId'),
12996
+ 'timestamp': timestamp,
12997
+ 'datetime': this.iso8601(timestamp),
12998
+ 'id': this.safeStringN(conversion, ['tranId', 'orderId', 'quoteId']),
12700
12999
  'fromCurrency': fromCode,
12701
- 'fromAmount': undefined,
13000
+ 'fromAmount': this.safeNumber2(conversion, 'deductedAmount', 'fromAmount'),
12702
13001
  'toCurrency': toCode,
12703
- 'toAmount': undefined,
13002
+ 'toAmount': this.safeNumber2(conversion, 'targetAmount', 'toAmount'),
12704
13003
  'price': undefined,
12705
13004
  'fee': undefined,
12706
13005
  };
package/js/src/bingx.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bingx.js';
9
- import { AuthenticationError, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired, NotSupported, ExchangeNotAvailable } from './base/errors.js';
9
+ import { AuthenticationError, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired, NotSupported, OperationFailed } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  import { DECIMAL_PLACES } from './base/functions/number.js';
@@ -387,7 +387,7 @@ export default class bingx extends Exchange {
387
387
  '100400': BadRequest,
388
388
  '100421': BadSymbol,
389
389
  '100440': ExchangeError,
390
- '100500': ExchangeNotAvailable,
390
+ '100500': OperationFailed,
391
391
  '100503': ExchangeError,
392
392
  '80001': BadRequest,
393
393
  '80012': InsufficientFunds,
@@ -397,7 +397,7 @@ export default class bingx extends Exchange {
397
397
  '100414': AccountSuspended,
398
398
  '100419': PermissionDenied,
399
399
  '100437': BadRequest,
400
- '101204': InsufficientFunds, // bingx {"code":101204,"msg":"","data":{}}
400
+ '101204': InsufficientFunds, // {"code":101204,"msg":"","data":{}}
401
401
  },
402
402
  'broad': {},
403
403
  },
@@ -284,6 +284,7 @@ export default class bitget extends Exchange {
284
284
  parseMarginMode(marginMode: any, market?: any): MarginMode;
285
285
  fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
286
286
  createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
287
+ fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
287
288
  parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
288
289
  fetchConvertCurrencies(params?: {}): Promise<Currencies>;
289
290
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
package/js/src/bitget.js CHANGED
@@ -69,6 +69,8 @@ export default class bitget extends Exchange {
69
69
  'fetchClosedOrders': true,
70
70
  'fetchConvertCurrencies': true,
71
71
  'fetchConvertQuote': true,
72
+ 'fetchConvertTrade': false,
73
+ 'fetchConvertTradeHistory': true,
72
74
  'fetchCrossBorrowRate': true,
73
75
  'fetchCrossBorrowRates': false,
74
76
  'fetchCurrencies': true,
@@ -8542,6 +8544,66 @@ export default class bitget extends Exchange {
8542
8544
  const toCurrency = this.currency(toCurrencyId);
8543
8545
  return this.parseConversion(data, undefined, toCurrency);
8544
8546
  }
8547
+ async fetchConvertTradeHistory(code = undefined, since = undefined, limit = undefined, params = {}) {
8548
+ /**
8549
+ * @method
8550
+ * @name bitget#fetchConvertTradeHistory
8551
+ * @description fetch the users history of conversion trades
8552
+ * @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Record
8553
+ * @param {string} [code] the unified currency code
8554
+ * @param {int} [since] the earliest time in ms to fetch conversions for
8555
+ * @param {int} [limit] the maximum number of conversion structures to retrieve
8556
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8557
+ * @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
8558
+ */
8559
+ await this.loadMarkets();
8560
+ const request = {};
8561
+ const msInDay = 86400000;
8562
+ const now = this.milliseconds();
8563
+ if (since !== undefined) {
8564
+ request['startTime'] = since;
8565
+ }
8566
+ else {
8567
+ request['startTime'] = now - msInDay;
8568
+ }
8569
+ const endTime = this.safeString2(params, 'endTime', 'until');
8570
+ if (endTime !== undefined) {
8571
+ request['endTime'] = endTime;
8572
+ }
8573
+ else {
8574
+ request['endTime'] = now;
8575
+ }
8576
+ if (limit !== undefined) {
8577
+ request['limit'] = limit;
8578
+ }
8579
+ params = this.omit(params, 'until');
8580
+ const response = await this.privateConvertGetV2ConvertConvertRecord(this.extend(request, params));
8581
+ //
8582
+ // {
8583
+ // "code": "00000",
8584
+ // "msg": "success",
8585
+ // "requestTime": 1712124371799,
8586
+ // "data": {
8587
+ // "dataList": [
8588
+ // {
8589
+ // "id": "1159296505255219205",
8590
+ // "fromCoin": "USDT",
8591
+ // "fromCoinSize": "5",
8592
+ // "cnvtPrice": "0.99940076",
8593
+ // "toCoin": "USDC",
8594
+ // "toCoinSize": "4.99700379",
8595
+ // "ts": "1712123746217",
8596
+ // "fee": "0"
8597
+ // }
8598
+ // ],
8599
+ // "endId": "1159296505255219205"
8600
+ // }
8601
+ // }
8602
+ //
8603
+ const data = this.safeDict(response, 'data', {});
8604
+ const dataList = this.safeList(data, 'dataList', []);
8605
+ return this.parseConversions(dataList, 'fromCoin', 'toCoin', since, limit);
8606
+ }
8545
8607
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
8546
8608
  //
8547
8609
  // fetchConvertQuote
@@ -8565,6 +8627,19 @@ export default class bitget extends Exchange {
8565
8627
  // "ts": "1712123746217"
8566
8628
  // }
8567
8629
  //
8630
+ // fetchConvertTradeHistory
8631
+ //
8632
+ // {
8633
+ // "id": "1159296505255219205",
8634
+ // "fromCoin": "USDT",
8635
+ // "fromCoinSize": "5",
8636
+ // "cnvtPrice": "0.99940076",
8637
+ // "toCoin": "USDC",
8638
+ // "toCoinSize": "4.99700379",
8639
+ // "ts": "1712123746217",
8640
+ // "fee": "0"
8641
+ // }
8642
+ //
8568
8643
  const timestamp = this.safeInteger(conversion, 'ts');
8569
8644
  const fromCoin = this.safeString(conversion, 'fromCoin');
8570
8645
  const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
@@ -8574,7 +8649,7 @@ export default class bitget extends Exchange {
8574
8649
  'info': conversion,
8575
8650
  'timestamp': timestamp,
8576
8651
  'datetime': this.iso8601(timestamp),
8577
- 'id': this.safeString(conversion, 'traceId'),
8652
+ 'id': this.safeString2(conversion, 'id', 'traceId'),
8578
8653
  'fromCurrency': fromCode,
8579
8654
  'fromAmount': this.safeNumber(conversion, 'fromCoinSize'),
8580
8655
  'toCurrency': toCode,
@@ -2592,7 +2592,7 @@ export default class coinbase extends Exchange {
2592
2592
  * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
2593
2593
  * @param {float} [params.takeProfitPrice] price to trigger take-profit orders
2594
2594
  * @param {bool} [params.postOnly] true or false
2595
- * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO'
2595
+ * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO', 'FOK'
2596
2596
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2597
2597
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2598
2598
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
@@ -2697,6 +2697,14 @@ export default class coinbase extends Exchange {
2697
2697
  },
2698
2698
  };
2699
2699
  }
2700
+ else if (timeInForce === 'FOK') {
2701
+ request['order_configuration'] = {
2702
+ 'limit_limit_fok': {
2703
+ 'base_size': this.amountToPrecision(symbol, amount),
2704
+ 'limit_price': this.priceToPrecision(symbol, price),
2705
+ },
2706
+ };
2707
+ }
2700
2708
  else {
2701
2709
  request['order_configuration'] = {
2702
2710
  'limit_limit_gtc': {
@@ -62,7 +62,7 @@ export default class coinbasepro extends Exchange {
62
62
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
63
63
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
64
64
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
65
- parseTransactionStatus(transaction: any): "ok" | "failed" | "canceled" | "pending";
65
+ parseTransactionStatus(transaction: any): "ok" | "canceled" | "failed" | "pending";
66
66
  parseTransaction(transaction: any, currency?: Currency): Transaction;
67
67
  createDepositAddress(code: string, params?: {}): Promise<{
68
68
  currency: string;
@@ -79,6 +79,7 @@ export default class hyperliquid extends Exchange {
79
79
  withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<any>;
80
80
  formatVaultAddress(address?: Str): string;
81
81
  handlePublicAddress(methodName: string, params: Dict): any[];
82
+ coinToMarketId(coin: Str): string;
82
83
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
83
84
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
84
85
  url: string;