ccxt 4.4.13 → 4.4.15

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 (77) 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/htx.js +1 -1
  13. package/dist/cjs/src/huobijp.js +1 -3
  14. package/dist/cjs/src/kucoin.js +40 -1
  15. package/dist/cjs/src/kucoinfutures.js +59 -4
  16. package/dist/cjs/src/mexc.js +64 -8
  17. package/dist/cjs/src/okx.js +14 -0
  18. package/dist/cjs/src/onetrading.js +2 -2
  19. package/dist/cjs/src/poloniexfutures.js +37 -11
  20. package/dist/cjs/src/pro/binance.js +1 -1
  21. package/dist/cjs/src/pro/okx.js +43 -0
  22. package/dist/cjs/src/pro/upbit.js +46 -0
  23. package/dist/cjs/src/pro/vertex.js +11 -0
  24. package/dist/cjs/src/vertex.js +11 -0
  25. package/dist/cjs/src/woo.js +14 -0
  26. package/dist/cjs/src/woofipro.js +14 -0
  27. package/dist/cjs/src/xt.js +14 -0
  28. package/js/ccxt.d.ts +1 -1
  29. package/js/ccxt.js +1 -1
  30. package/js/src/abstract/binance.d.ts +1 -0
  31. package/js/src/abstract/binancecoinm.d.ts +1 -0
  32. package/js/src/abstract/binanceus.d.ts +1 -0
  33. package/js/src/abstract/binanceusdm.d.ts +1 -0
  34. package/js/src/abstract/cryptocom.d.ts +1 -0
  35. package/js/src/base/Exchange.d.ts +6 -0
  36. package/js/src/base/Exchange.js +48 -2
  37. package/js/src/binance.d.ts +1 -0
  38. package/js/src/binance.js +76 -11
  39. package/js/src/bitget.d.ts +2 -0
  40. package/js/src/bitget.js +112 -3
  41. package/js/src/bitrue.d.ts +0 -1
  42. package/js/src/bitrue.js +1 -9
  43. package/js/src/bitvavo.d.ts +0 -1
  44. package/js/src/bitvavo.js +1 -3
  45. package/js/src/coinex.d.ts +1 -0
  46. package/js/src/coinex.js +15 -1
  47. package/js/src/cryptocom.js +1 -0
  48. package/js/src/digifinex.d.ts +1 -0
  49. package/js/src/digifinex.js +15 -1
  50. package/js/src/htx.js +1 -1
  51. package/js/src/huobijp.d.ts +0 -1
  52. package/js/src/huobijp.js +1 -3
  53. package/js/src/kucoin.d.ts +2 -0
  54. package/js/src/kucoin.js +40 -1
  55. package/js/src/kucoinfutures.d.ts +3 -0
  56. package/js/src/kucoinfutures.js +59 -4
  57. package/js/src/mexc.d.ts +1 -0
  58. package/js/src/mexc.js +64 -8
  59. package/js/src/okx.d.ts +1 -0
  60. package/js/src/okx.js +14 -0
  61. package/js/src/onetrading.js +2 -2
  62. package/js/src/poloniexfutures.d.ts +2 -0
  63. package/js/src/poloniexfutures.js +37 -11
  64. package/js/src/pro/binance.js +1 -1
  65. package/js/src/pro/okx.d.ts +2 -0
  66. package/js/src/pro/okx.js +43 -0
  67. package/js/src/pro/upbit.d.ts +3 -1
  68. package/js/src/pro/upbit.js +46 -0
  69. package/js/src/pro/vertex.js +11 -0
  70. package/js/src/vertex.js +11 -0
  71. package/js/src/woo.d.ts +1 -0
  72. package/js/src/woo.js +14 -0
  73. package/js/src/woofipro.d.ts +1 -0
  74. package/js/src/woofipro.js +14 -0
  75. package/js/src/xt.d.ts +1 -0
  76. package/js/src/xt.js +14 -0
  77. package/package.json +1 -1
@@ -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
  // {
package/js/src/htx.js CHANGED
@@ -1233,7 +1233,7 @@ export default class htx extends Exchange {
1233
1233
  'SBTC': 'SUPERBITCOIN',
1234
1234
  'SOUL': 'SOULSAVER',
1235
1235
  'BIFI': 'BITCOINFILE',
1236
- 'FUD': 'FTX Users\' Debt',
1236
+ 'FUD': 'FTX Users Debt',
1237
1237
  },
1238
1238
  });
1239
1239
  }
@@ -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<{
package/js/src/kucoin.js CHANGED
@@ -81,6 +81,8 @@ export default class kucoin extends Exchange {
81
81
  'fetchMarketLeverageTiers': false,
82
82
  'fetchMarkets': true,
83
83
  'fetchMarkOHLCV': false,
84
+ 'fetchMarkPrice': true,
85
+ 'fetchMarkPrices': true,
84
86
  'fetchMyTrades': true,
85
87
  'fetchOHLCV': true,
86
88
  'fetchOpenInterest': false,
@@ -1663,7 +1665,7 @@ export default class kucoin extends Exchange {
1663
1665
  const symbol = market['symbol'];
1664
1666
  const baseVolume = this.safeString(ticker, 'vol');
1665
1667
  const quoteVolume = this.safeString(ticker, 'volValue');
1666
- const timestamp = this.safeInteger2(ticker, 'time', 'datetime');
1668
+ const timestamp = this.safeIntegerN(ticker, ['time', 'datetime', 'timePoint']);
1667
1669
  return this.safeTicker({
1668
1670
  'symbol': symbol,
1669
1671
  'timestamp': timestamp,
@@ -1684,6 +1686,7 @@ export default class kucoin extends Exchange {
1684
1686
  'average': this.safeString(ticker, 'averagePrice'),
1685
1687
  'baseVolume': baseVolume,
1686
1688
  'quoteVolume': quoteVolume,
1689
+ 'markPrice': this.safeString(ticker, 'value'),
1687
1690
  'info': ticker,
1688
1691
  }, market);
1689
1692
  }
@@ -1742,6 +1745,22 @@ export default class kucoin extends Exchange {
1742
1745
  }
1743
1746
  return this.filterByArrayTickers(result, 'symbol', symbols);
1744
1747
  }
1748
+ async fetchMarkPrices(symbols = undefined, params = {}) {
1749
+ /**
1750
+ * @method
1751
+ * @name kucoin#fetchMarkPrices
1752
+ * @description fetches the mark price for multiple markets
1753
+ * @see https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-margin-trading-pairs-mark-prices
1754
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1755
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1756
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1757
+ */
1758
+ await this.loadMarkets();
1759
+ symbols = this.marketSymbols(symbols);
1760
+ const response = await this.publicGetMarkPriceAllSymbols(params);
1761
+ const data = this.safeList(response, 'data', []);
1762
+ return this.parseTickers(data);
1763
+ }
1745
1764
  async fetchTicker(symbol, params = {}) {
1746
1765
  /**
1747
1766
  * @method
@@ -1784,6 +1803,26 @@ export default class kucoin extends Exchange {
1784
1803
  const data = this.safeDict(response, 'data', {});
1785
1804
  return this.parseTicker(data, market);
1786
1805
  }
1806
+ async fetchMarkPrice(symbol, params = {}) {
1807
+ /**
1808
+ * @method
1809
+ * @name kucoin#fetchMarkPrice
1810
+ * @description fetches the mark price for a specific market
1811
+ * @see https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-mark-price
1812
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1813
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1814
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1815
+ */
1816
+ await this.loadMarkets();
1817
+ const market = this.market(symbol);
1818
+ const request = {
1819
+ 'symbol': market['id'],
1820
+ };
1821
+ const response = await this.publicGetMarkPriceSymbolCurrent(this.extend(request, params));
1822
+ //
1823
+ const data = this.safeDict(response, 'data', {});
1824
+ return this.parseTicker(data, market);
1825
+ }
1787
1826
  parseOHLCV(ohlcv, market = undefined) {
1788
1827
  //
1789
1828
  // [
@@ -26,6 +26,7 @@ export default class kucoinfutures extends kucoin {
26
26
  }>;
27
27
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
28
28
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
29
+ fetchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
29
30
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
30
31
  parseTicker(ticker: Dict, market?: Market): Ticker;
31
32
  fetchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -47,6 +48,8 @@ export default class kucoinfutures extends kucoin {
47
48
  fetchOrder(id?: Str, symbol?: Str, params?: {}): Promise<Order>;
48
49
  parseOrder(order: Dict, market?: Market): Order;
49
50
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
51
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
52
+ parseFundingRate(data: any, market?: Market): FundingRate;
50
53
  parseFundingInterval(interval: any): string;
51
54
  parseBalance(response: any): Balances;
52
55
  fetchBalance(params?: {}): Promise<Balances>;
@@ -63,6 +63,8 @@ export default class kucoinfutures extends kucoin {
63
63
  'fetchDepositWithdrawFee': false,
64
64
  'fetchDepositWithdrawFees': false,
65
65
  'fetchFundingHistory': true,
66
+ 'fetchFundingInterval': true,
67
+ 'fetchFundingIntervals': false,
66
68
  'fetchFundingRate': true,
67
69
  'fetchFundingRateHistory': true,
68
70
  'fetchIndexOHLCV': false,
@@ -77,6 +79,7 @@ export default class kucoinfutures extends kucoin {
77
79
  'fetchMarketLeverageTiers': true,
78
80
  'fetchMarkets': true,
79
81
  'fetchMarkOHLCV': false,
82
+ 'fetchMarkPrice': true,
80
83
  'fetchMyTrades': true,
81
84
  'fetchOHLCV': true,
82
85
  'fetchOpenOrders': true,
@@ -778,6 +781,25 @@ export default class kucoinfutures extends kucoin {
778
781
  //
779
782
  return this.parseTicker(response['data'], market);
780
783
  }
784
+ async fetchMarkPrice(symbol, params = {}) {
785
+ /**
786
+ * @method
787
+ * @name kucoinfutures#fetchMarkPrice
788
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
789
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-mark-price
790
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
791
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
792
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
793
+ */
794
+ await this.loadMarkets();
795
+ const market = this.market(symbol);
796
+ const request = {
797
+ 'symbol': market['id'],
798
+ };
799
+ const response = await this.futuresPublicGetMarkPriceSymbolCurrent(this.extend(request, params));
800
+ //
801
+ return this.parseTicker(response['data'], market);
802
+ }
781
803
  async fetchTickers(symbols = undefined, params = {}) {
782
804
  /**
783
805
  * @method
@@ -867,6 +889,14 @@ export default class kucoinfutures extends kucoin {
867
889
  return this.filterByArrayTickers(tickers, 'symbol', symbols);
868
890
  }
869
891
  parseTicker(ticker, market = undefined) {
892
+ //
893
+ // {
894
+ // "symbol": "LTCUSDTM",
895
+ // "granularity": 1000,
896
+ // "timePoint": 1727967339000,
897
+ // "value": 62.37, mark price
898
+ // "indexPrice": 62.37
899
+ // }
870
900
  //
871
901
  // {
872
902
  // "code": "200000",
@@ -969,7 +999,7 @@ export default class kucoinfutures extends kucoin {
969
999
  'average': undefined,
970
1000
  'baseVolume': this.safeString(ticker, 'volumeOf24h'),
971
1001
  'quoteVolume': this.safeString(ticker, 'turnoverOf24h'),
972
- 'markPrice': this.safeString(ticker, 'markPrice'),
1002
+ 'markPrice': this.safeString2(ticker, 'markPrice', 'value'),
973
1003
  'indexPrice': this.safeString(ticker, 'indexPrice'),
974
1004
  'info': ticker,
975
1005
  }, market);
@@ -2185,12 +2215,37 @@ export default class kucoinfutures extends kucoin {
2185
2215
  // },
2186
2216
  // }
2187
2217
  //
2188
- const data = this.safeValue(response, 'data');
2189
- const fundingTimestamp = this.safeInteger(data, 'timePoint');
2218
+ const data = this.safeDict(response, 'data', {});
2190
2219
  // the website displayes the previous funding rate as "funding rate"
2220
+ return this.parseFundingRate(data, market);
2221
+ }
2222
+ async fetchFundingInterval(symbol, params = {}) {
2223
+ /**
2224
+ * @method
2225
+ * @name kucoinfutures#fetchFundingInterval
2226
+ * @description fetch the current funding rate interval
2227
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
2228
+ * @param {string} symbol unified market symbol
2229
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2230
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2231
+ */
2232
+ return await this.fetchFundingRate(symbol, params);
2233
+ }
2234
+ parseFundingRate(data, market = undefined) {
2235
+ //
2236
+ // {
2237
+ // "symbol": ".ETHUSDTMFPI8H",
2238
+ // "granularity": 28800000,
2239
+ // "timePoint": 1637380800000,
2240
+ // "value": 0.0001,
2241
+ // "predictedValue": 0.0001,
2242
+ // }
2243
+ //
2244
+ const fundingTimestamp = this.safeInteger(data, 'timePoint');
2245
+ const marketId = this.safeString(data, 'symbol');
2191
2246
  return {
2192
2247
  'info': data,
2193
- 'symbol': market['symbol'],
2248
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
2194
2249
  'markPrice': undefined,
2195
2250
  'indexPrice': undefined,
2196
2251
  'interestRate': undefined,
package/js/src/mexc.d.ts CHANGED
@@ -65,6 +65,7 @@ export default class mexc extends Exchange {
65
65
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
66
66
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
67
67
  parseFundingRate(contract: any, market?: Market): FundingRate;
68
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
68
69
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
69
70
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
70
71
  fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<LeverageTiers>;
package/js/src/mexc.js CHANGED
@@ -78,6 +78,8 @@ export default class mexc extends Exchange {
78
78
  'fetchDepositWithdrawFee': 'emulated',
79
79
  'fetchDepositWithdrawFees': true,
80
80
  'fetchFundingHistory': true,
81
+ 'fetchFundingInterval': true,
82
+ 'fetchFundingIntervals': false,
81
83
  'fetchFundingRate': true,
82
84
  'fetchFundingRateHistory': true,
83
85
  'fetchFundingRates': undefined,
@@ -2623,6 +2625,7 @@ export default class mexc extends Exchange {
2623
2625
  * @param {int} [since] the earliest time in ms to fetch orders for
2624
2626
  * @param {int} [limit] the maximum number of order structures to retrieve
2625
2627
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2628
+ * @param {int} [params.until] the latest time in ms to fetch orders for
2626
2629
  * @param {string} [params.marginMode] only 'isolated' is supported, for spot-margin trading
2627
2630
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2628
2631
  */
@@ -2633,6 +2636,8 @@ export default class mexc extends Exchange {
2633
2636
  market = this.market(symbol);
2634
2637
  request['symbol'] = market['id'];
2635
2638
  }
2639
+ const until = this.safeInteger(params, 'until');
2640
+ params = this.omit(params, 'until');
2636
2641
  const [marketType, query] = this.handleMarketTypeAndParams('fetchOrders', market, params);
2637
2642
  if (marketType === 'spot') {
2638
2643
  if (symbol === undefined) {
@@ -2642,6 +2647,9 @@ export default class mexc extends Exchange {
2642
2647
  if (since !== undefined) {
2643
2648
  request['startTime'] = since;
2644
2649
  }
2650
+ if (until !== undefined) {
2651
+ request['endTime'] = until;
2652
+ }
2645
2653
  if (limit !== undefined) {
2646
2654
  request['limit'] = limit;
2647
2655
  }
@@ -2708,10 +2716,22 @@ export default class mexc extends Exchange {
2708
2716
  else {
2709
2717
  if (since !== undefined) {
2710
2718
  request['start_time'] = since;
2711
- const end = this.safeInteger(params, 'end_time');
2719
+ const end = this.safeInteger(params, 'end_time', until);
2712
2720
  if (end === undefined) {
2713
2721
  request['end_time'] = this.sum(since, this.options['maxTimeTillEnd']);
2714
2722
  }
2723
+ else {
2724
+ if ((end - since) > this.options['maxTimeTillEnd']) {
2725
+ throw new BadRequest(this.id + ' end is invalid, i.e. exceeds allowed 90 days.');
2726
+ }
2727
+ else {
2728
+ request['end_time'] = until;
2729
+ }
2730
+ }
2731
+ }
2732
+ else if (until !== undefined) {
2733
+ request['start_time'] = this.sum(until, this.options['maxTimeTillEnd'] * -1);
2734
+ request['end_time'] = until;
2715
2735
  }
2716
2736
  if (limit !== undefined) {
2717
2737
  request['page_size'] = limit;
@@ -4218,9 +4238,13 @@ export default class mexc extends Exchange {
4218
4238
  const nextFundingRate = this.safeNumber(contract, 'fundingRate');
4219
4239
  const nextFundingTimestamp = this.safeInteger(contract, 'nextSettleTime');
4220
4240
  const marketId = this.safeString(contract, 'symbol');
4221
- const symbol = this.safeSymbol(marketId, market);
4241
+ const symbol = this.safeSymbol(marketId, market, undefined, 'contract');
4222
4242
  const timestamp = this.safeInteger(contract, 'timestamp');
4223
- const datetime = this.iso8601(timestamp);
4243
+ const interval = this.safeString(contract, 'collectCycle');
4244
+ let intervalString = undefined;
4245
+ if (interval !== undefined) {
4246
+ intervalString = interval + 'h';
4247
+ }
4224
4248
  return {
4225
4249
  'info': contract,
4226
4250
  'symbol': symbol,
@@ -4229,7 +4253,7 @@ export default class mexc extends Exchange {
4229
4253
  'interestRate': undefined,
4230
4254
  'estimatedSettlePrice': undefined,
4231
4255
  'timestamp': timestamp,
4232
- 'datetime': datetime,
4256
+ 'datetime': this.iso8601(timestamp),
4233
4257
  'fundingRate': nextFundingRate,
4234
4258
  'fundingTimestamp': nextFundingTimestamp,
4235
4259
  'fundingDatetime': this.iso8601(nextFundingTimestamp),
@@ -4239,9 +4263,21 @@ export default class mexc extends Exchange {
4239
4263
  'previousFundingRate': undefined,
4240
4264
  'previousFundingTimestamp': undefined,
4241
4265
  'previousFundingDatetime': undefined,
4242
- 'interval': undefined,
4266
+ 'interval': intervalString,
4243
4267
  };
4244
4268
  }
4269
+ async fetchFundingInterval(symbol, params = {}) {
4270
+ /**
4271
+ * @method
4272
+ * @name mexc#fetchFundingInterval
4273
+ * @description fetch the current funding rate interval
4274
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
4275
+ * @param {string} symbol unified market symbol
4276
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4277
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
4278
+ */
4279
+ return await this.fetchFundingRate(symbol, params);
4280
+ }
4245
4281
  async fetchFundingRate(symbol, params = {}) {
4246
4282
  /**
4247
4283
  * @method
@@ -4523,7 +4559,17 @@ export default class mexc extends Exchange {
4523
4559
  const networkCode = this.safeString(params, 'network');
4524
4560
  let networkId = undefined;
4525
4561
  if (networkCode !== undefined) {
4526
- networkId = this.networkCodeToId(networkCode, code);
4562
+ // createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
4563
+ const networkUnified = this.networkIdToCode(networkCode, code);
4564
+ const networks = this.safeDict(currency, 'networks', {});
4565
+ if (networkUnified in networks) {
4566
+ const network = this.safeDict(networks, networkUnified, {});
4567
+ const networkInfo = this.safeValue(network, 'info', {});
4568
+ networkId = this.safeString(networkInfo, 'network');
4569
+ }
4570
+ else {
4571
+ networkId = this.networkCodeToId(networkCode, code);
4572
+ }
4527
4573
  }
4528
4574
  if (networkId !== undefined) {
4529
4575
  request['network'] = networkId;
@@ -4564,7 +4610,18 @@ export default class mexc extends Exchange {
4564
4610
  if (networkCode === undefined) {
4565
4611
  throw new ArgumentsRequired(this.id + ' createDepositAddress requires a `network` parameter');
4566
4612
  }
4567
- const networkId = this.networkCodeToId(networkCode, code);
4613
+ // createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
4614
+ let networkId = undefined;
4615
+ const networkUnified = this.networkIdToCode(networkCode, code);
4616
+ const networks = this.safeDict(currency, 'networks', {});
4617
+ if (networkUnified in networks) {
4618
+ const network = this.safeDict(networks, networkUnified, {});
4619
+ const networkInfo = this.safeValue(network, 'info', {});
4620
+ networkId = this.safeString(networkInfo, 'network');
4621
+ }
4622
+ else {
4623
+ networkId = this.networkCodeToId(networkCode, code);
4624
+ }
4568
4625
  if (networkId !== undefined) {
4569
4626
  request['network'] = networkId;
4570
4627
  }
@@ -4590,7 +4647,6 @@ export default class mexc extends Exchange {
4590
4647
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
4591
4648
  */
4592
4649
  const network = this.safeString(params, 'network');
4593
- params = this.omit(params, ['network']);
4594
4650
  const addressStructures = await this.fetchDepositAddressesByNetwork(code, params);
4595
4651
  let result = undefined;
4596
4652
  if (network !== undefined) {
package/js/src/okx.d.ts CHANGED
@@ -91,6 +91,7 @@ export default class okx extends Exchange {
91
91
  };
92
92
  parseFundingRate(contract: any, market?: Market): FundingRate;
93
93
  parseFundingInterval(interval: any): string;
94
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
94
95
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
95
96
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
96
97
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
package/js/src/okx.js CHANGED
@@ -82,6 +82,8 @@ export default class okx 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,
@@ -6122,6 +6124,18 @@ export default class okx extends Exchange {
6122
6124
  };
6123
6125
  return this.safeString(intervals, interval, interval);
6124
6126
  }
6127
+ async fetchFundingInterval(symbol, params = {}) {
6128
+ /**
6129
+ * @method
6130
+ * @name okx#fetchFundingInterval
6131
+ * @description fetch the current funding rate interval
6132
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
6133
+ * @param {string} symbol unified market symbol
6134
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6135
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
6136
+ */
6137
+ return await this.fetchFundingRate(symbol, params);
6138
+ }
6125
6139
  async fetchFundingRate(symbol, params = {}) {
6126
6140
  /**
6127
6141
  * @method
@@ -119,8 +119,8 @@ export default class onetrading extends Exchange {
119
119
  'urls': {
120
120
  'logo': 'https://github.com/ccxt/ccxt/assets/43336371/bdbc26fd-02f2-4ca7-9f1e-17333690bb1c',
121
121
  'api': {
122
- 'public': 'https://api.onetrading.com/public',
123
- 'private': 'https://api.onetrading.com/public',
122
+ 'public': 'https://api.onetrading.com/fast',
123
+ 'private': 'https://api.onetrading.com/fast',
124
124
  },
125
125
  'www': 'https://onetrading.com/',
126
126
  'doc': [
@@ -56,6 +56,8 @@ export default class poloniexfutures extends Exchange {
56
56
  fetchOrder(id?: Str, symbol?: Str, params?: {}): Promise<Order>;
57
57
  parseOrder(order: Dict, market?: Market): Order;
58
58
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
59
+ fetchFundingInterval(symbol: string, params?: {}): Promise<FundingRate>;
60
+ parseFundingRate(data: any, market?: Market): FundingRate;
59
61
  parseFundingInterval(interval: any): string;
60
62
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
61
63
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
@@ -40,6 +40,8 @@ export default class poloniexfutures extends Exchange {
40
40
  'fetchDepositAddress': false,
41
41
  'fetchDepositAddresses': false,
42
42
  'fetchDepositAddressesByNetwork': false,
43
+ 'fetchFundingInterval': true,
44
+ 'fetchFundingIntervals': false,
43
45
  'fetchFundingRate': true,
44
46
  'fetchFundingRateHistory': false,
45
47
  'fetchL3OrderBook': true,
@@ -1637,28 +1639,52 @@ export default class poloniexfutures extends Exchange {
1637
1639
  // "predictedValue": 0.00375
1638
1640
  // }
1639
1641
  //
1640
- const data = this.safeValue(response, 'data');
1642
+ const data = this.safeDict(response, 'data', {});
1643
+ return this.parseFundingRate(data, market);
1644
+ }
1645
+ async fetchFundingInterval(symbol, params = {}) {
1646
+ /**
1647
+ * @method
1648
+ * @name poloniexfutures#fetchFundingInterval
1649
+ * @description fetch the current funding rate interval
1650
+ * @see https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index
1651
+ * @param {string} symbol unified market symbol
1652
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1653
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
1654
+ */
1655
+ return await this.fetchFundingRate(symbol, params);
1656
+ }
1657
+ parseFundingRate(data, market = undefined) {
1658
+ //
1659
+ // {
1660
+ // "symbol": ".ETHUSDTMFPI8H",
1661
+ // "granularity": 28800000,
1662
+ // "timePoint": 1637380800000,
1663
+ // "value": 0.0001,
1664
+ // "predictedValue": 0.0001,
1665
+ // }
1666
+ //
1641
1667
  const fundingTimestamp = this.safeInteger(data, 'timePoint');
1642
- // the website displayes the previous funding rate as "funding rate"
1668
+ const marketId = this.safeString(data, 'symbol');
1643
1669
  return {
1644
1670
  'info': data,
1645
- 'symbol': market['symbol'],
1671
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
1646
1672
  'markPrice': undefined,
1647
1673
  'indexPrice': undefined,
1648
1674
  'interestRate': undefined,
1649
1675
  'estimatedSettlePrice': undefined,
1650
1676
  'timestamp': undefined,
1651
1677
  'datetime': undefined,
1652
- 'fundingRate': this.safeNumber(data, 'predictedValue'),
1653
- 'fundingTimestamp': undefined,
1654
- 'fundingDatetime': undefined,
1655
- 'nextFundingRate': undefined,
1678
+ 'fundingRate': this.safeNumber(data, 'value'),
1679
+ 'fundingTimestamp': fundingTimestamp,
1680
+ 'fundingDatetime': this.iso8601(fundingTimestamp),
1681
+ 'nextFundingRate': this.safeNumber(data, 'predictedValue'),
1656
1682
  'nextFundingTimestamp': undefined,
1657
1683
  'nextFundingDatetime': undefined,
1658
- 'previousFundingRate': this.safeNumber(data, 'value'),
1659
- 'previousFundingTimestamp': fundingTimestamp,
1660
- 'previousFundingDatetime': this.iso8601(fundingTimestamp),
1661
- 'interval': this.parseFundingInterval(this.safeString(data, 'interval')),
1684
+ 'previousFundingRate': undefined,
1685
+ 'previousFundingTimestamp': undefined,
1686
+ 'previousFundingDatetime': undefined,
1687
+ 'interval': this.parseFundingInterval(this.safeString(data, 'granularity')),
1662
1688
  };
1663
1689
  }
1664
1690
  parseFundingInterval(interval) {
@@ -249,7 +249,7 @@ export default class binance extends binanceRest {
249
249
  let type = undefined;
250
250
  [type, params] = this.handleMarketTypeAndParams('watchLiquidationsForSymbols', firstMarket, params);
251
251
  if (type === 'spot') {
252
- throw new BadRequest(this.id + 'watchLiquidationsForSymbols is not supported for swap symbols');
252
+ throw new BadRequest(this.id + 'watchLiquidationsForSymbols is not supported for spot symbols');
253
253
  }
254
254
  let subType = undefined;
255
255
  [subType, params] = this.handleSubTypeAndParams('watchLiquidationsForSymbols', firstMarket, params);
@@ -17,6 +17,8 @@ export default class okx extends okxRest {
17
17
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
18
18
  unWatchTicker(symbol: string, params?: {}): Promise<any>;
19
19
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
20
+ watchMarkPrice(symbol: string, params?: {}): Promise<Ticker>;
21
+ watchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
20
22
  unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
21
23
  handleTicker(client: Client, message: any): void;
22
24
  watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;