ccxt 4.4.13 → 4.4.14

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 (66) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +48 -2
  5. package/dist/cjs/src/binance.js +76 -11
  6. package/dist/cjs/src/bitget.js +112 -3
  7. package/dist/cjs/src/bitrue.js +1 -9
  8. package/dist/cjs/src/bitvavo.js +1 -3
  9. package/dist/cjs/src/coinex.js +15 -1
  10. package/dist/cjs/src/cryptocom.js +1 -0
  11. package/dist/cjs/src/digifinex.js +15 -1
  12. package/dist/cjs/src/huobijp.js +1 -3
  13. package/dist/cjs/src/kucoin.js +40 -1
  14. package/dist/cjs/src/kucoinfutures.js +59 -4
  15. package/dist/cjs/src/mexc.js +64 -8
  16. package/dist/cjs/src/okx.js +14 -0
  17. package/dist/cjs/src/poloniexfutures.js +37 -11
  18. package/dist/cjs/src/pro/okx.js +43 -0
  19. package/dist/cjs/src/woo.js +14 -0
  20. package/dist/cjs/src/woofipro.js +14 -0
  21. package/dist/cjs/src/xt.js +14 -0
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/binance.d.ts +1 -0
  25. package/js/src/abstract/binancecoinm.d.ts +1 -0
  26. package/js/src/abstract/binanceus.d.ts +1 -0
  27. package/js/src/abstract/binanceusdm.d.ts +1 -0
  28. package/js/src/abstract/cryptocom.d.ts +1 -0
  29. package/js/src/base/Exchange.d.ts +6 -0
  30. package/js/src/base/Exchange.js +48 -2
  31. package/js/src/binance.d.ts +1 -0
  32. package/js/src/binance.js +76 -11
  33. package/js/src/bitget.d.ts +2 -0
  34. package/js/src/bitget.js +112 -3
  35. package/js/src/bitrue.d.ts +0 -1
  36. package/js/src/bitrue.js +1 -9
  37. package/js/src/bitvavo.d.ts +0 -1
  38. package/js/src/bitvavo.js +1 -3
  39. package/js/src/coinex.d.ts +1 -0
  40. package/js/src/coinex.js +15 -1
  41. package/js/src/cryptocom.js +1 -0
  42. package/js/src/digifinex.d.ts +1 -0
  43. package/js/src/digifinex.js +15 -1
  44. package/js/src/huobijp.d.ts +0 -1
  45. package/js/src/huobijp.js +1 -3
  46. package/js/src/kucoin.d.ts +2 -0
  47. package/js/src/kucoin.js +40 -1
  48. package/js/src/kucoinfutures.d.ts +3 -0
  49. package/js/src/kucoinfutures.js +59 -4
  50. package/js/src/mexc.d.ts +1 -0
  51. package/js/src/mexc.js +64 -8
  52. package/js/src/okx.d.ts +1 -0
  53. package/js/src/okx.js +14 -0
  54. package/js/src/poloniexfutures.d.ts +2 -0
  55. package/js/src/poloniexfutures.js +37 -11
  56. package/js/src/pro/okx.d.ts +2 -0
  57. package/js/src/pro/okx.js +43 -0
  58. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  59. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  60. package/js/src/woo.d.ts +1 -0
  61. package/js/src/woo.js +14 -0
  62. package/js/src/woofipro.d.ts +1 -0
  63. package/js/src/woofipro.js +14 -0
  64. package/js/src/xt.d.ts +1 -0
  65. package/js/src/xt.js +14 -0
  66. package/package.json +1 -1
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  /* eslint-disable */
9
9
  import * as functions from './functions.js';
10
- const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
10
+ const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, roundTimeframe, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
11
11
  import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
12
12
  // import exceptions from "./errors.js"
13
13
  import { // eslint-disable-line object-curly-newline
@@ -134,6 +134,7 @@ export default class Exchange {
134
134
  this.flatten = flatten;
135
135
  this.unique = unique;
136
136
  this.indexBy = indexBy;
137
+ this.roundTimeframe = roundTimeframe;
137
138
  this.sortBy = sortBy;
138
139
  this.sortBy2 = sortBy2;
139
140
  this.groupBy = groupBy;
@@ -1383,6 +1384,8 @@ export default class Exchange {
1383
1384
  'fetchFundingHistory': undefined,
1384
1385
  'fetchFundingRate': undefined,
1385
1386
  'fetchFundingRateHistory': undefined,
1387
+ 'fetchFundingInterval': undefined,
1388
+ 'fetchFundingIntervals': undefined,
1386
1389
  'fetchFundingRates': undefined,
1387
1390
  'fetchGreeks': undefined,
1388
1391
  'fetchIndexOHLCV': undefined,
@@ -2131,6 +2134,9 @@ export default class Exchange {
2131
2134
  async fetchFundingRates(symbols = undefined, params = {}) {
2132
2135
  throw new NotSupported(this.id + ' fetchFundingRates() is not supported yet');
2133
2136
  }
2137
+ async fetchFundingIntervals(symbols = undefined, params = {}) {
2138
+ throw new NotSupported(this.id + ' fetchFundingIntervals() is not supported yet');
2139
+ }
2134
2140
  async watchFundingRate(symbol, params = {}) {
2135
2141
  throw new NotSupported(this.id + ' watchFundingRate() is not supported yet');
2136
2142
  }
@@ -4400,6 +4406,24 @@ export default class Exchange {
4400
4406
  throw new NotSupported(this.id + ' fetchTicker() is not supported yet');
4401
4407
  }
4402
4408
  }
4409
+ async fetchMarkPrice(symbol, params = {}) {
4410
+ if (this.has['fetchMarkPrices']) {
4411
+ await this.loadMarkets();
4412
+ const market = this.market(symbol);
4413
+ symbol = market['symbol'];
4414
+ const tickers = await this.fetchMarkPrices([symbol], params);
4415
+ const ticker = this.safeDict(tickers, symbol);
4416
+ if (ticker === undefined) {
4417
+ throw new NullResponse(this.id + ' fetchMarkPrices() could not find a ticker for ' + symbol);
4418
+ }
4419
+ else {
4420
+ return ticker;
4421
+ }
4422
+ }
4423
+ else {
4424
+ throw new NotSupported(this.id + ' fetchMarkPrices() is not supported yet');
4425
+ }
4426
+ }
4403
4427
  async fetchTickerWs(symbol, params = {}) {
4404
4428
  if (this.has['fetchTickersWs']) {
4405
4429
  await this.loadMarkets();
@@ -5184,7 +5208,8 @@ export default class Exchange {
5184
5208
  return this.forceString(fee);
5185
5209
  }
5186
5210
  else {
5187
- return this.decimalToPrecision(fee, ROUND, precision, this.precisionMode, this.paddingMode);
5211
+ const roundingMode = this.safeInteger(this.options, 'currencyToPrecisionRoundingMode', ROUND);
5212
+ return this.decimalToPrecision(fee, roundingMode, precision, this.precisionMode, this.paddingMode);
5188
5213
  }
5189
5214
  }
5190
5215
  forceString(value) {
@@ -5632,6 +5657,27 @@ export default class Exchange {
5632
5657
  throw new NotSupported(this.id + ' fetchFundingRate () is not supported yet');
5633
5658
  }
5634
5659
  }
5660
+ async fetchFundingInterval(symbol, params = {}) {
5661
+ if (this.has['fetchFundingIntervals']) {
5662
+ await this.loadMarkets();
5663
+ const market = this.market(symbol);
5664
+ symbol = market['symbol'];
5665
+ if (!market['contract']) {
5666
+ throw new BadSymbol(this.id + ' fetchFundingInterval() supports contract markets only');
5667
+ }
5668
+ const rates = await this.fetchFundingIntervals([symbol], params);
5669
+ const rate = this.safeValue(rates, symbol);
5670
+ if (rate === undefined) {
5671
+ throw new NullResponse(this.id + ' fetchFundingInterval() returned no data for ' + symbol);
5672
+ }
5673
+ else {
5674
+ return rate;
5675
+ }
5676
+ }
5677
+ else {
5678
+ throw new NotSupported(this.id + ' fetchFundingInterval() is not supported yet');
5679
+ }
5680
+ }
5635
5681
  async fetchMarkOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
5636
5682
  /**
5637
5683
  * @method
@@ -333,4 +333,5 @@ export default class binance extends Exchange {
333
333
  fetchConvertTrade(id: string, code?: Str, params?: {}): Promise<Conversion>;
334
334
  fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
335
335
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
336
+ fetchFundingIntervals(symbols?: Strings, params?: {}): Promise<FundingRates>;
336
337
  }
package/js/src/binance.js CHANGED
@@ -91,6 +91,8 @@ export default class binance extends Exchange {
91
91
  'fetchDepositWithdrawFee': 'emulated',
92
92
  'fetchDepositWithdrawFees': true,
93
93
  'fetchFundingHistory': true,
94
+ 'fetchFundingInterval': 'emulated',
95
+ 'fetchFundingIntervals': true,
94
96
  'fetchFundingRate': true,
95
97
  'fetchFundingRateHistory': true,
96
98
  'fetchFundingRates': true,
@@ -714,6 +716,7 @@ export default class binance extends Exchange {
714
716
  'ticker/bookTicker': { 'cost': 2, 'noSymbol': 5 },
715
717
  'constituents': 2,
716
718
  'openInterest': 1,
719
+ 'fundingInfo': 1,
717
720
  },
718
721
  },
719
722
  'dapiData': {
@@ -9504,16 +9507,28 @@ export default class binance extends Exchange {
9504
9507
  parseFundingRate(contract, market = undefined) {
9505
9508
  // ensure it matches with https://www.binance.com/en/futures/funding-history/0
9506
9509
  //
9507
- // {
9508
- // "symbol": "BTCUSDT",
9509
- // "markPrice": "45802.81129892",
9510
- // "indexPrice": "45745.47701915",
9511
- // "estimatedSettlePrice": "45133.91753671",
9512
- // "lastFundingRate": "0.00063521",
9513
- // "interestRate": "0.00010000",
9514
- // "nextFundingTime": "1621267200000",
9515
- // "time": "1621252344001"
9516
- // }
9510
+ // fetchFundingRate, fetchFundingRates
9511
+ //
9512
+ // {
9513
+ // "symbol": "BTCUSDT",
9514
+ // "markPrice": "45802.81129892",
9515
+ // "indexPrice": "45745.47701915",
9516
+ // "estimatedSettlePrice": "45133.91753671",
9517
+ // "lastFundingRate": "0.00063521",
9518
+ // "interestRate": "0.00010000",
9519
+ // "nextFundingTime": "1621267200000",
9520
+ // "time": "1621252344001"
9521
+ // }
9522
+ //
9523
+ // fetchFundingInterval, fetchFundingIntervals
9524
+ //
9525
+ // {
9526
+ // "symbol": "BLZUSDT",
9527
+ // "adjustedFundingRateCap": "0.03000000",
9528
+ // "adjustedFundingRateFloor": "-0.03000000",
9529
+ // "fundingIntervalHours": 4,
9530
+ // "disclaimer": false
9531
+ // }
9517
9532
  //
9518
9533
  const timestamp = this.safeInteger(contract, 'time');
9519
9534
  const marketId = this.safeString(contract, 'symbol');
@@ -9524,6 +9539,11 @@ export default class binance extends Exchange {
9524
9539
  const estimatedSettlePrice = this.safeNumber(contract, 'estimatedSettlePrice');
9525
9540
  const fundingRate = this.safeNumber(contract, 'lastFundingRate');
9526
9541
  const fundingTime = this.safeInteger(contract, 'nextFundingTime');
9542
+ const interval = this.safeString(contract, 'fundingIntervalHours');
9543
+ let intervalString = undefined;
9544
+ if (interval !== undefined) {
9545
+ intervalString = interval + 'h';
9546
+ }
9527
9547
  return {
9528
9548
  'info': contract,
9529
9549
  'symbol': symbol,
@@ -9542,7 +9562,7 @@ export default class binance extends Exchange {
9542
9562
  'previousFundingRate': undefined,
9543
9563
  'previousFundingTimestamp': undefined,
9544
9564
  'previousFundingDatetime': undefined,
9545
- 'interval': undefined,
9565
+ 'interval': intervalString,
9546
9566
  };
9547
9567
  }
9548
9568
  parseAccountPositions(account, filterClosed = false) {
@@ -13683,4 +13703,49 @@ export default class binance extends Exchange {
13683
13703
  'fee': undefined,
13684
13704
  };
13685
13705
  }
13706
+ async fetchFundingIntervals(symbols = undefined, params = {}) {
13707
+ /**
13708
+ * @method
13709
+ * @name binance#fetchFundingIntervals
13710
+ * @description fetch the funding rate interval for multiple markets
13711
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Info
13712
+ * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Get-Funding-Info
13713
+ * @param {string[]} [symbols] list of unified market symbols
13714
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
13715
+ * @param {string} [params.subType] "linear" or "inverse"
13716
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
13717
+ */
13718
+ await this.loadMarkets();
13719
+ let market = undefined;
13720
+ if (symbols !== undefined) {
13721
+ symbols = this.marketSymbols(symbols);
13722
+ market = this.market(symbols[0]);
13723
+ }
13724
+ const type = 'swap';
13725
+ let subType = undefined;
13726
+ [subType, params] = this.handleSubTypeAndParams('fetchFundingIntervals', market, params, 'linear');
13727
+ let response = undefined;
13728
+ if (this.isLinear(type, subType)) {
13729
+ response = await this.fapiPublicGetFundingInfo(params);
13730
+ }
13731
+ else if (this.isInverse(type, subType)) {
13732
+ response = await this.dapiPublicGetFundingInfo(params);
13733
+ }
13734
+ else {
13735
+ throw new NotSupported(this.id + ' fetchFundingIntervals() supports linear and inverse swap contracts only');
13736
+ }
13737
+ //
13738
+ // [
13739
+ // {
13740
+ // "symbol": "BLZUSDT",
13741
+ // "adjustedFundingRateCap": "0.03000000",
13742
+ // "adjustedFundingRateFloor": "-0.03000000",
13743
+ // "fundingIntervalHours": 4,
13744
+ // "disclaimer": false
13745
+ // },
13746
+ // ]
13747
+ //
13748
+ const result = this.parseFundingRates(response, market);
13749
+ return this.filterByArray(result, 'symbol', symbols);
13750
+ }
13686
13751
  }
@@ -37,6 +37,7 @@ export default class bitget extends Exchange {
37
37
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
38
38
  parseTicker(ticker: Dict, market?: Market): Ticker;
39
39
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
40
+ fetchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
40
41
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
41
42
  parseTrade(trade: Dict, market?: Market): Trade;
42
43
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -187,6 +188,7 @@ export default class bitget extends Exchange {
187
188
  fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
188
189
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
189
190
  fetchConvertCurrencies(params?: {}): Promise<Currencies>;
191
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
190
192
  handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
191
193
  nonce(): number;
192
194
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/bitget.js CHANGED
@@ -82,6 +82,8 @@ export default class bitget extends Exchange {
82
82
  'fetchDepositWithdrawFee': 'emulated',
83
83
  'fetchDepositWithdrawFees': true,
84
84
  'fetchFundingHistory': true,
85
+ 'fetchFundingInterval': true,
86
+ 'fetchFundingIntervals': false,
85
87
  'fetchFundingRate': true,
86
88
  'fetchFundingRateHistory': true,
87
89
  'fetchFundingRates': false,
@@ -97,6 +99,7 @@ export default class bitget extends Exchange {
97
99
  'fetchMarketLeverageTiers': true,
98
100
  'fetchMarkets': true,
99
101
  'fetchMarkOHLCV': true,
102
+ 'fetchMarkPrice': true,
100
103
  'fetchMyLiquidations': true,
101
104
  'fetchMyTrades': true,
102
105
  'fetchOHLCV': true,
@@ -2537,6 +2540,14 @@ export default class bitget extends Exchange {
2537
2540
  return this.parseOrderBook(data, market['symbol'], timestamp);
2538
2541
  }
2539
2542
  parseTicker(ticker, market = undefined) {
2543
+ //
2544
+ // {
2545
+ // "symbol": "BTCUSDT",
2546
+ // "price": "26242",
2547
+ // "indexPrice": "34867",
2548
+ // "markPrice": "25555",
2549
+ // "ts": "1695793390482"
2550
+ // }
2540
2551
  //
2541
2552
  // spot: fetchTicker, fetchTickers
2542
2553
  //
@@ -2644,6 +2655,7 @@ export default class bitget extends Exchange {
2644
2655
  'baseVolume': this.safeString(ticker, 'baseVolume'),
2645
2656
  'quoteVolume': this.safeString(ticker, 'quoteVolume'),
2646
2657
  'indexPrice': this.safeString(ticker, 'indexPrice'),
2658
+ 'markPrice': this.safeString(ticker, 'markPrice'),
2647
2659
  'info': ticker,
2648
2660
  }, market);
2649
2661
  }
@@ -2747,6 +2759,42 @@ export default class bitget extends Exchange {
2747
2759
  const data = this.safeList(response, 'data', []);
2748
2760
  return this.parseTicker(data[0], market);
2749
2761
  }
2762
+ async fetchMarkPrice(symbol, params = {}) {
2763
+ /**
2764
+ * @method
2765
+ * @name bitget#fetchMarkPrice
2766
+ * @description fetches the mark price for a specific market
2767
+ * @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Price
2768
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
2769
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2770
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
2771
+ */
2772
+ await this.loadMarkets();
2773
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2774
+ let market = undefined;
2775
+ if (sandboxMode) {
2776
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2777
+ market = this.market(sandboxSymbol);
2778
+ }
2779
+ else {
2780
+ market = this.market(symbol);
2781
+ }
2782
+ const request = {
2783
+ 'symbol': market['id'],
2784
+ };
2785
+ let response = undefined;
2786
+ if (market['spot']) {
2787
+ throw new NotSupported(this.id + ' fetchMarkPrice() is not supported for spot markets');
2788
+ }
2789
+ else {
2790
+ let productType = undefined;
2791
+ [productType, params] = this.handleProductTypeAndParams(market, params);
2792
+ request['productType'] = productType;
2793
+ response = await this.publicMixGetV2MixMarketSymbolPrice(this.extend(request, params));
2794
+ }
2795
+ const data = this.safeList(response, 'data', []);
2796
+ return this.parseTicker(data[0], market);
2797
+ }
2750
2798
  async fetchTickers(symbols = undefined, params = {}) {
2751
2799
  /**
2752
2800
  * @method
@@ -6796,14 +6844,30 @@ export default class bitget extends Exchange {
6796
6844
  return this.parseFundingRate(data[0], market);
6797
6845
  }
6798
6846
  parseFundingRate(contract, market = undefined) {
6847
+ //
6848
+ // fetchFundingRate
6799
6849
  //
6800
6850
  // {
6801
6851
  // "symbol": "BTCUSDT",
6802
6852
  // "fundingRate": "-0.000182"
6803
6853
  // }
6804
6854
  //
6855
+ // fetchFundingInterval
6856
+ //
6857
+ // {
6858
+ // "symbol": "BTCUSDT",
6859
+ // "nextFundingTime": "1727942400000",
6860
+ // "ratePeriod": "8"
6861
+ // }
6862
+ //
6805
6863
  const marketId = this.safeString(contract, 'symbol');
6806
6864
  const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
6865
+ const fundingTimestamp = this.safeInteger(contract, 'nextFundingTime');
6866
+ const interval = this.safeString(contract, 'ratePeriod');
6867
+ let intervalString = undefined;
6868
+ if (interval !== undefined) {
6869
+ intervalString = interval + 'h';
6870
+ }
6807
6871
  return {
6808
6872
  'info': contract,
6809
6873
  'symbol': symbol,
@@ -6814,15 +6878,15 @@ export default class bitget extends Exchange {
6814
6878
  'timestamp': undefined,
6815
6879
  'datetime': undefined,
6816
6880
  'fundingRate': this.safeNumber(contract, 'fundingRate'),
6817
- 'fundingTimestamp': undefined,
6818
- 'fundingDatetime': undefined,
6881
+ 'fundingTimestamp': fundingTimestamp,
6882
+ 'fundingDatetime': this.iso8601(fundingTimestamp),
6819
6883
  'nextFundingRate': undefined,
6820
6884
  'nextFundingTimestamp': undefined,
6821
6885
  'nextFundingDatetime': undefined,
6822
6886
  'previousFundingRate': undefined,
6823
6887
  'previousFundingTimestamp': undefined,
6824
6888
  'previousFundingDatetime': undefined,
6825
- 'interval': undefined,
6889
+ 'interval': intervalString,
6826
6890
  };
6827
6891
  }
6828
6892
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -8793,6 +8857,51 @@ export default class bitget extends Exchange {
8793
8857
  }
8794
8858
  return result;
8795
8859
  }
8860
+ async fetchFundingInterval(symbol, params = {}) {
8861
+ /**
8862
+ * @method
8863
+ * @name bitget#fetchFundingInterval
8864
+ * @description fetch the current funding rate interval
8865
+ * @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
8866
+ * @param {string} symbol unified market symbol
8867
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8868
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
8869
+ */
8870
+ await this.loadMarkets();
8871
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
8872
+ let market = undefined;
8873
+ if (sandboxMode) {
8874
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
8875
+ market = this.market(sandboxSymbol);
8876
+ }
8877
+ else {
8878
+ market = this.market(symbol);
8879
+ }
8880
+ let productType = undefined;
8881
+ [productType, params] = this.handleProductTypeAndParams(market, params);
8882
+ const request = {
8883
+ 'symbol': market['id'],
8884
+ 'productType': productType,
8885
+ };
8886
+ const response = await this.publicMixGetV2MixMarketFundingTime(this.extend(request, params));
8887
+ //
8888
+ // {
8889
+ // "code": "00000",
8890
+ // "msg": "success",
8891
+ // "requestTime": 1727930153888,
8892
+ // "data": [
8893
+ // {
8894
+ // "symbol": "BTCUSDT",
8895
+ // "nextFundingTime": "1727942400000",
8896
+ // "ratePeriod": "8"
8897
+ // }
8898
+ // ]
8899
+ // }
8900
+ //
8901
+ const data = this.safeList(response, 'data', []);
8902
+ const first = this.safeDict(data, 0, {});
8903
+ return this.parseFundingRate(first, market);
8904
+ }
8796
8905
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
8797
8906
  if (!response) {
8798
8907
  return undefined; // fallback to default error handler
@@ -6,7 +6,6 @@ import type { Balances, Currencies, Currency, Dict, Int, MarginModification, Mar
6
6
  */
7
7
  export default class bitrue extends Exchange {
8
8
  describe(): any;
9
- currencyToPrecision(code: any, fee: any, networkCode?: any): string;
10
9
  nonce(): number;
11
10
  fetchStatus(params?: {}): Promise<{
12
11
  status: string;
package/js/src/bitrue.js CHANGED
@@ -327,6 +327,7 @@ export default class bitrue extends Exchange {
327
327
  // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades
328
328
  'fetchMyTradesMethod': 'v2PrivateGetMyTrades',
329
329
  'hasAlreadyAuthenticatedSuccessfully': false,
330
+ 'currencyToPrecisionRoundingMode': TRUNCATE,
330
331
  'recvWindow': 5 * 1000,
331
332
  'timeDifference': 0,
332
333
  'adjustForTimeDifference': false,
@@ -516,15 +517,6 @@ export default class bitrue extends Exchange {
516
517
  },
517
518
  });
518
519
  }
519
- currencyToPrecision(code, fee, networkCode = undefined) {
520
- // info is available in currencies only if the user has configured his api keys
521
- if (this.safeValue(this.currencies[code], 'precision') !== undefined) {
522
- return this.decimalToPrecision(fee, TRUNCATE, this.currencies[code]['precision'], this.precisionMode, this.paddingMode);
523
- }
524
- else {
525
- return this.numberToString(fee);
526
- }
527
- }
528
520
  nonce() {
529
521
  return this.milliseconds() - this.options['timeDifference'];
530
522
  }
@@ -6,7 +6,6 @@ import type { Balances, Currencies, Currency, Dict, Int, Market, Num, OHLCV, Ord
6
6
  */
7
7
  export default class bitvavo extends Exchange {
8
8
  describe(): any;
9
- currencyToPrecision(code: any, fee: any, networkCode?: any): string;
10
9
  amountToPrecision(symbol: any, amount: any): string;
11
10
  priceToPrecision(symbol: any, price: any): string;
12
11
  fetchTime(params?: {}): Promise<number>;
package/js/src/bitvavo.js CHANGED
@@ -269,6 +269,7 @@ export default class bitvavo extends Exchange {
269
269
  },
270
270
  },
271
271
  'options': {
272
+ 'currencyToPrecisionRoundingMode': TRUNCATE,
272
273
  'BITVAVO-ACCESS-WINDOW': 10000,
273
274
  'networks': {
274
275
  'ERC20': 'ETH',
@@ -281,9 +282,6 @@ export default class bitvavo extends Exchange {
281
282
  },
282
283
  });
283
284
  }
284
- currencyToPrecision(code, fee, networkCode = undefined) {
285
- return this.decimalToPrecision(fee, 0, this.currencies[code]['precision'], DECIMAL_PLACES);
286
- }
287
285
  amountToPrecision(symbol, amount) {
288
286
  // https://docs.bitfinex.com/docs/introduction#amount-precision
289
287
  // The amount field allows up to 8 decimals.
@@ -76,6 +76,7 @@ export default class coinex extends Exchange {
76
76
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
77
77
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
78
78
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
79
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
79
80
  parseFundingRate(contract: any, market?: Market): FundingRate;
80
81
  parseFundingInterval(interval: any): string;
81
82
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<FundingRates>;
package/js/src/coinex.js CHANGED
@@ -74,6 +74,8 @@ export default class coinex extends Exchange {
74
74
  'fetchDepositWithdrawFee': true,
75
75
  'fetchDepositWithdrawFees': false,
76
76
  'fetchFundingHistory': true,
77
+ 'fetchFundingInterval': true,
78
+ 'fetchFundingIntervals': false,
77
79
  'fetchFundingRate': true,
78
80
  'fetchFundingRateHistory': true,
79
81
  'fetchFundingRates': true,
@@ -4558,9 +4560,21 @@ export default class coinex extends Exchange {
4558
4560
  const first = this.safeDict(data, 0, {});
4559
4561
  return this.parseFundingRate(first, market);
4560
4562
  }
4563
+ async fetchFundingInterval(symbol, params = {}) {
4564
+ /**
4565
+ * @method
4566
+ * @name coinex#fetchFundingInterval
4567
+ * @description fetch the current funding rate interval
4568
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4569
+ * @param {string} symbol unified market symbol
4570
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4571
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
4572
+ */
4573
+ return await this.fetchFundingRate(symbol, params);
4574
+ }
4561
4575
  parseFundingRate(contract, market = undefined) {
4562
4576
  //
4563
- // fetchFundingRate, fetchFundingRates
4577
+ // fetchFundingRate, fetchFundingRates, fetchFundingInterval
4564
4578
  //
4565
4579
  // {
4566
4580
  // "latest_funding_rate": "0",
@@ -163,6 +163,7 @@ export default class cryptocom extends Exchange {
163
163
  'public/get-valuations': 1,
164
164
  'public/get-expired-settlement-price': 10 / 3,
165
165
  'public/get-insurance': 1,
166
+ 'public/get-risk-parameters': 1,
166
167
  },
167
168
  'post': {
168
169
  'public/staking/get-conversion-rate': 2,
@@ -85,6 +85,7 @@ export default class digifinex extends Exchange {
85
85
  };
86
86
  parseBorrowRates(info: any, codeKey: any): any;
87
87
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
88
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
88
89
  parseFundingRate(contract: any, market?: Market): FundingRate;
89
90
  parseFundingInterval(interval: any): string;
90
91
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
@@ -55,6 +55,8 @@ export default class digifinex extends Exchange {
55
55
  'fetchDepositWithdrawFee': 'emulated',
56
56
  'fetchDepositWithdrawFees': true,
57
57
  'fetchFundingHistory': true,
58
+ 'fetchFundingInterval': true,
59
+ 'fetchFundingIntervals': false,
58
60
  'fetchFundingRate': true,
59
61
  'fetchFundingRateHistory': true,
60
62
  'fetchFundingRates': false,
@@ -3252,9 +3254,21 @@ export default class digifinex extends Exchange {
3252
3254
  // }
3253
3255
  // }
3254
3256
  //
3255
- const data = this.safeValue(response, 'data', {});
3257
+ const data = this.safeDict(response, 'data', {});
3256
3258
  return this.parseFundingRate(data, market);
3257
3259
  }
3260
+ async fetchFundingInterval(symbol, params = {}) {
3261
+ /**
3262
+ * @method
3263
+ * @name digifinex#fetchFundingInterval
3264
+ * @description fetch the current funding rate interval
3265
+ * @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3266
+ * @param {string} symbol unified market symbol
3267
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3268
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3269
+ */
3270
+ return await this.fetchFundingRate(symbol, params);
3271
+ }
3258
3272
  parseFundingRate(contract, market = undefined) {
3259
3273
  //
3260
3274
  // {
@@ -57,7 +57,6 @@ export default class huobijp extends Exchange {
57
57
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<any[]>;
58
58
  parseCancelOrders(orders: any): any[];
59
59
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
60
- currencyToPrecision(code: any, fee: any, networkCode?: any): string;
61
60
  parseDepositAddress(depositAddress: any, currency?: Currency): {
62
61
  currency: string;
63
62
  address: string;
package/js/src/huobijp.js CHANGED
@@ -310,6 +310,7 @@ export default class huobijp extends Exchange {
310
310
  'fetchMarketsMethod': 'publicGetCommonSymbols',
311
311
  'fetchBalanceMethod': 'privateGetAccountAccountsIdBalance',
312
312
  'createOrderMethod': 'privatePostOrderOrdersPlace',
313
+ 'currencyToPrecisionRoundingMode': TRUNCATE,
313
314
  'language': 'en-US',
314
315
  'broker': {
315
316
  'id': 'AA03022abc',
@@ -1648,9 +1649,6 @@ export default class huobijp extends Exchange {
1648
1649
  }),
1649
1650
  ];
1650
1651
  }
1651
- currencyToPrecision(code, fee, networkCode = undefined) {
1652
- return this.decimalToPrecision(fee, 0, this.currencies[code]['precision'], this.precisionMode);
1653
- }
1654
1652
  parseDepositAddress(depositAddress, currency = undefined) {
1655
1653
  //
1656
1654
  // {
@@ -30,7 +30,9 @@ export default class kucoin extends Exchange {
30
30
  isFuturesMethod(methodName: any, params: any): boolean;
31
31
  parseTicker(ticker: Dict, market?: Market): Ticker;
32
32
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
33
+ fetchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
33
34
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
35
+ fetchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
34
36
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
35
37
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
36
38
  createDepositAddress(code: string, params?: {}): Promise<{