ccxt 4.1.28 → 4.1.30

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 (43) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +586 -62
  3. package/dist/ccxt.browser.min.js +9 -9
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/ws/Future.js +6 -2
  6. package/dist/cjs/src/bitget.js +286 -17
  7. package/dist/cjs/src/bitopro.js +5 -4
  8. package/dist/cjs/src/bitrue.js +33 -18
  9. package/dist/cjs/src/bybit.js +4 -0
  10. package/dist/cjs/src/cryptocom.js +32 -0
  11. package/dist/cjs/src/gate.js +58 -10
  12. package/dist/cjs/src/huobi.js +0 -1
  13. package/dist/cjs/src/huobijp.js +0 -1
  14. package/dist/cjs/src/krakenfutures.js +58 -4
  15. package/dist/cjs/src/mexc.js +95 -4
  16. package/dist/cjs/src/okx.js +1 -0
  17. package/dist/cjs/src/phemex.js +3 -0
  18. package/dist/cjs/src/pro/huobi.js +4 -0
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/bybit.d.ts +1 -0
  22. package/js/src/abstract/okex.d.ts +1 -0
  23. package/js/src/abstract/okex5.d.ts +1 -0
  24. package/js/src/abstract/okx.d.ts +1 -0
  25. package/js/src/base/ws/Future.js +6 -2
  26. package/js/src/bitget.d.ts +12 -0
  27. package/js/src/bitget.js +286 -17
  28. package/js/src/bitopro.js +5 -4
  29. package/js/src/bitrue.js +33 -18
  30. package/js/src/bybit.js +4 -0
  31. package/js/src/cryptocom.d.ts +1 -0
  32. package/js/src/cryptocom.js +32 -0
  33. package/js/src/gate.js +58 -10
  34. package/js/src/huobi.js +0 -1
  35. package/js/src/huobijp.js +0 -1
  36. package/js/src/krakenfutures.d.ts +1 -1
  37. package/js/src/krakenfutures.js +58 -4
  38. package/js/src/mexc.d.ts +3 -1
  39. package/js/src/mexc.js +95 -4
  40. package/js/src/okx.js +1 -0
  41. package/js/src/phemex.js +3 -0
  42. package/js/src/pro/huobi.js +4 -0
  43. package/package.json +1 -1
package/js/src/gate.js CHANGED
@@ -1567,6 +1567,7 @@ export default class gate extends Exchange {
1567
1567
  * @method
1568
1568
  * @name gate#fetchCurrencies
1569
1569
  * @description fetches all available currencies on an exchange
1570
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-currencies-details
1570
1571
  * @param {object} [params] extra parameters specific to the gate api endpoint
1571
1572
  * @returns {object} an associative dictionary of currencies
1572
1573
  */
@@ -1677,6 +1678,7 @@ export default class gate extends Exchange {
1677
1678
  * @method
1678
1679
  * @name gate#fetchFundingRate
1679
1680
  * @description fetch the current funding rate
1681
+ * @see https://www.gate.io/docs/developers/apiv4/en/#get-a-single-contract
1680
1682
  * @param {string} symbol unified market symbol
1681
1683
  * @param {object} [params] extra parameters specific to the gate api endpoint
1682
1684
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
@@ -1739,6 +1741,7 @@ export default class gate extends Exchange {
1739
1741
  * @method
1740
1742
  * @name gate#fetchFundingRates
1741
1743
  * @description fetch the funding rate for multiple markets
1744
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
1742
1745
  * @param {string[]|undefined} symbols list of unified market symbols
1743
1746
  * @param {object} [params] extra parameters specific to the gate api endpoint
1744
1747
  * @returns {object} a dictionary of [funding rates structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rates-structure}, indexe by market symbols
@@ -2205,6 +2208,8 @@ export default class gate extends Exchange {
2205
2208
  * @method
2206
2209
  * @name gate#fetchFundingHistory
2207
2210
  * @description fetch the history of funding payments paid and received on this account
2211
+ * @see https://www.gate.io/docs/developers/apiv4/en/#query-account-book-2
2212
+ * @see https://www.gate.io/docs/developers/apiv4/en/#query-account-book-3
2208
2213
  * @param {string} symbol unified market symbol
2209
2214
  * @param {int} [since] the earliest time in ms to fetch funding history for
2210
2215
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -2905,6 +2910,7 @@ export default class gate extends Exchange {
2905
2910
  * @method
2906
2911
  * @name gate#fetchFundingRateHistory
2907
2912
  * @description fetches historical funding rate prices
2913
+ * @see https://www.gate.io/docs/developers/apiv4/en/#funding-rate-history
2908
2914
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
2909
2915
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
2910
2916
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
@@ -2998,6 +3004,10 @@ export default class gate extends Exchange {
2998
3004
  * @method
2999
3005
  * @name gate#fetchTrades
3000
3006
  * @description get the list of most recent trades for a particular symbol
3007
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-market-trades
3008
+ * @see https://www.gate.io/docs/developers/apiv4/en/#futures-trading-history
3009
+ * @see https://www.gate.io/docs/developers/apiv4/en/#futures-trading-history-2
3010
+ * @see https://www.gate.io/docs/developers/apiv4/en/#options-trade-history
3001
3011
  * @param {string} symbol unified symbol of the market to fetch trades for
3002
3012
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
3003
3013
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -3101,6 +3111,10 @@ export default class gate extends Exchange {
3101
3111
  * @method
3102
3112
  * @name gate#fetchOrderTrades
3103
3113
  * @description fetch all the trades made from a single order
3114
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history
3115
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history-2
3116
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history-3
3117
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-personal-trading-history-4
3104
3118
  * @param {string} id order id
3105
3119
  * @param {string} symbol unified market symbol
3106
3120
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3418,6 +3432,7 @@ export default class gate extends Exchange {
3418
3432
  * @method
3419
3433
  * @name gate#fetchDeposits
3420
3434
  * @description fetch all deposits made to an account
3435
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-deposit-records
3421
3436
  * @param {string} code unified currency code
3422
3437
  * @param {int} [since] the earliest time in ms to fetch deposits for
3423
3438
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -3455,6 +3470,7 @@ export default class gate extends Exchange {
3455
3470
  * @method
3456
3471
  * @name gate#fetchWithdrawals
3457
3472
  * @description fetch all withdrawals made from an account
3473
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-withdrawal-records
3458
3474
  * @param {string} code unified currency code
3459
3475
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
3460
3476
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -3492,6 +3508,7 @@ export default class gate extends Exchange {
3492
3508
  * @method
3493
3509
  * @name gate#withdraw
3494
3510
  * @description make a withdrawal
3511
+ * @see https://www.gate.io/docs/developers/apiv4/en/#withdraw
3495
3512
  * @param {string} code unified currency code
3496
3513
  * @param {float} amount the amount to withdraw
3497
3514
  * @param {string} address the address to withdraw to
@@ -3638,6 +3655,13 @@ export default class gate extends Exchange {
3638
3655
  * @method
3639
3656
  * @name gate#createOrder
3640
3657
  * @description Create an order on the exchange
3658
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-an-order
3659
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-price-triggered-order
3660
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order
3661
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-price-triggered-order-2
3662
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order-2
3663
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-price-triggered-order-3
3664
+ * @see https://www.gate.io/docs/developers/apiv4/en/#create-an-options-order
3641
3665
  * @param {string} symbol Unified CCXT market symbol
3642
3666
  * @param {string} type 'limit' or 'market' *"market" is contract only*
3643
3667
  * @param {string} side 'buy' or 'sell'
@@ -4450,6 +4474,7 @@ export default class gate extends Exchange {
4450
4474
  * @method
4451
4475
  * @name gate#fetchOpenOrders
4452
4476
  * @description fetch all unfilled currently open orders
4477
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-open-orders
4453
4478
  * @param {string} symbol unified market symbol
4454
4479
  * @param {int} [since] the earliest time in ms to fetch open orders for
4455
4480
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -4466,6 +4491,13 @@ export default class gate extends Exchange {
4466
4491
  * @method
4467
4492
  * @name gate#fetchClosedOrders
4468
4493
  * @description fetches information on multiple closed orders made by the user
4494
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-orders
4495
+ * @see https://www.gate.io/docs/developers/apiv4/en/#retrieve-running-auto-order-list
4496
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders
4497
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders
4498
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
4499
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
4500
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
4469
4501
  * @param {string} symbol unified market symbol of the market orders were made in
4470
4502
  * @param {int} [since] the earliest time in ms to fetch orders for
4471
4503
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -4674,6 +4706,10 @@ export default class gate extends Exchange {
4674
4706
  * @method
4675
4707
  * @name gate#cancelOrder
4676
4708
  * @description Cancels an open order
4709
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order
4710
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-2
4711
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-3
4712
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-4
4677
4713
  * @param {string} id Order id
4678
4714
  * @param {string} symbol Unified market symbol
4679
4715
  * @param {object} [params] Parameters specified by the exchange api
@@ -4784,6 +4820,10 @@ export default class gate extends Exchange {
4784
4820
  * @method
4785
4821
  * @name gate#cancelAllOrders
4786
4822
  * @description cancel all open orders
4823
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-in-specified-currency-pair
4824
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched
4825
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched-2
4826
+ * @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched-3
4787
4827
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
4788
4828
  * @param {object} [params] extra parameters specific to the gate api endpoint
4789
4829
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -4915,6 +4955,8 @@ export default class gate extends Exchange {
4915
4955
  * @method
4916
4956
  * @name gate#setLeverage
4917
4957
  * @description set the level of leverage for a market
4958
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-leverage
4959
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-leverage-2
4918
4960
  * @param {float} leverage the rate of leverage
4919
4961
  * @param {string} symbol unified market symbol
4920
4962
  * @param {object} [params] extra parameters specific to the gate api endpoint
@@ -5279,6 +5321,8 @@ export default class gate extends Exchange {
5279
5321
  * @method
5280
5322
  * @name gate#fetchLeverageTiers
5281
5323
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
5324
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
5325
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts-2
5282
5326
  * @param {string[]|undefined} symbols list of unified market symbols
5283
5327
  * @param {object} [params] extra parameters specific to the gate api endpoint
5284
5328
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#leverage-tiers-structure}, indexed by market symbols
@@ -5534,12 +5578,12 @@ export default class gate extends Exchange {
5534
5578
  'currency': currency['id'],
5535
5579
  'amount': this.currencyToPrecision(code, amount),
5536
5580
  };
5537
- let method = undefined;
5581
+ let response = undefined;
5582
+ params = this.omit(params, ['marginMode']);
5538
5583
  if (symbol === undefined) {
5539
- method = 'privateMarginPostCrossRepayments';
5584
+ response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
5540
5585
  }
5541
5586
  else {
5542
- method = 'privateMarginPostLoansLoanIdRepayment';
5543
5587
  const market = this.market(symbol);
5544
5588
  request['currency_pair'] = market['id'];
5545
5589
  request['mode'] = 'partial';
@@ -5548,9 +5592,9 @@ export default class gate extends Exchange {
5548
5592
  throw new ArgumentsRequired(this.id + ' repayMargin() requires loan_id param for isolated margin');
5549
5593
  }
5550
5594
  request['loan_id'] = loanId;
5595
+ params = this.omit(params, ['loan_id', 'id']);
5596
+ response = await this.privateMarginPostLoansLoanIdRepayment(this.extend(request, params));
5551
5597
  }
5552
- params = this.omit(params, ['marginMode', 'loan_id', 'id']);
5553
- let response = await this[method](this.extend(request, params));
5554
5598
  //
5555
5599
  // Cross
5556
5600
  //
@@ -5617,9 +5661,9 @@ export default class gate extends Exchange {
5617
5661
  'currency': currency['id'],
5618
5662
  'amount': this.currencyToPrecision(code, amount),
5619
5663
  };
5620
- let method = undefined;
5664
+ let response = undefined;
5621
5665
  if (symbol === undefined) {
5622
- method = 'privateMarginPostCrossLoans';
5666
+ response = await this.privateMarginPostCrossLoans(this.extend(request, params));
5623
5667
  }
5624
5668
  else {
5625
5669
  const market = this.market(symbol);
@@ -5629,10 +5673,9 @@ export default class gate extends Exchange {
5629
5673
  // as it is the smallest tick size currently offered by gateio
5630
5674
  request['rate'] = this.safeString(params, 'rate', '0.0001');
5631
5675
  request['auto_renew'] = true;
5632
- method = 'privateMarginPostLoans';
5676
+ params = this.omit(params, ['rate']);
5677
+ response = await this.privateMarginPostLoans(this.extend(request, params));
5633
5678
  }
5634
- params = this.omit(params, ['marginMode', 'rate']);
5635
- const response = await this[method](this.extend(request, params));
5636
5679
  //
5637
5680
  // Cross
5638
5681
  //
@@ -5856,6 +5899,8 @@ export default class gate extends Exchange {
5856
5899
  * @method
5857
5900
  * @name gate#reduceMargin
5858
5901
  * @description remove margin from a position
5902
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin
5903
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin-2
5859
5904
  * @param {string} symbol unified market symbol
5860
5905
  * @param {float} amount the amount of margin to remove
5861
5906
  * @param {object} [params] extra parameters specific to the exmo api endpoint
@@ -5868,6 +5913,8 @@ export default class gate extends Exchange {
5868
5913
  * @method
5869
5914
  * @name gate#addMargin
5870
5915
  * @description add margin
5916
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin
5917
+ * @see https://www.gate.io/docs/developers/apiv4/en/#update-position-margin-2
5871
5918
  * @param {string} symbol unified market symbol
5872
5919
  * @param {float} amount amount of margin to add
5873
5920
  * @param {object} [params] extra parameters specific to the exmo api endpoint
@@ -6405,6 +6452,7 @@ export default class gate extends Exchange {
6405
6452
  * @method
6406
6453
  * @name gate#fetchUnderlyingAssets
6407
6454
  * @description fetches the market ids of underlying assets for a specific contract market type
6455
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-underlyings
6408
6456
  * @param {object} [params] exchange specific params
6409
6457
  * @param {string} [params.type] the contract market type, 'option', 'swap' or 'future', the default is 'option'
6410
6458
  * @returns {object[]} a list of [underlying assets]{@link https://github.com/ccxt/ccxt/wiki/Manual#underlying-assets-structure}
package/js/src/huobi.js CHANGED
@@ -1051,7 +1051,6 @@ export default class huobi extends Exchange {
1051
1051
  'GET': 'Themis',
1052
1052
  'GTC': 'Game.com',
1053
1053
  'HIT': 'HitChain',
1054
- 'HOT': 'Hydro Protocol',
1055
1054
  // https://github.com/ccxt/ccxt/issues/7399
1056
1055
  // https://coinmarketcap.com/currencies/pnetwork/
1057
1056
  // https://coinmarketcap.com/currencies/penta/markets/
package/js/src/huobijp.js CHANGED
@@ -319,7 +319,6 @@ export default class huobijp extends Exchange {
319
319
  'GET': 'Themis',
320
320
  'GTC': 'Game.com',
321
321
  'HIT': 'HitChain',
322
- 'HOT': 'Hydro Protocol',
323
322
  // https://github.com/ccxt/ccxt/issues/7399
324
323
  // https://coinmarketcap.com/currencies/pnetwork/
325
324
  // https://coinmarketcap.com/currencies/penta/markets/
@@ -64,7 +64,7 @@ export default class krakenfutures extends Exchange {
64
64
  entryPrice: number;
65
65
  notional: any;
66
66
  leverage: number;
67
- unrealizedPnl: number;
67
+ unrealizedPnl: any;
68
68
  contracts: number;
69
69
  contractSize: number;
70
70
  marginRatio: any;
@@ -411,6 +411,7 @@ export default class krakenfutures extends Exchange {
411
411
  /**
412
412
  * @method
413
413
  * @name krakenfutures#fetchOrderBook
414
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-orderbook
414
415
  * @description Fetches a list of open orders in a market
415
416
  * @param {string} symbol Unified market symbol
416
417
  * @param {int} [limit] Not used by krakenfutures
@@ -457,6 +458,15 @@ export default class krakenfutures extends Exchange {
457
458
  return this.parseOrderBook(response['orderBook'], symbol, timestamp);
458
459
  }
459
460
  async fetchTickers(symbols = undefined, params = {}) {
461
+ /**
462
+ * @method
463
+ * @name krakenfutures#fetchTickers
464
+ * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
465
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-tickers
466
+ * @param {string[]} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
467
+ * @param {object} [params] extra parameters specific to the krakenfutures api endpoint
468
+ * @returns {object} an array of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
469
+ */
460
470
  await this.loadMarkets();
461
471
  const response = await this.publicGetTickers(params);
462
472
  //
@@ -656,6 +666,7 @@ export default class krakenfutures extends Exchange {
656
666
  /**
657
667
  * @method
658
668
  * @name krakenfutures#fetchTrades
669
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history
659
670
  * @descriptions Fetch a history of filled trades that this account has made
660
671
  * @param {string} symbol Unified CCXT market symbol
661
672
  * @param {int} [since] Timestamp in ms of earliest trade. Not used by krakenfutures except in combination with params.until
@@ -977,6 +988,7 @@ export default class krakenfutures extends Exchange {
977
988
  /**
978
989
  * @method
979
990
  * @name krakenfutures#editOrder
991
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-edit-order
980
992
  * @description Edit an open order on the exchange
981
993
  * @param {string} id order id
982
994
  * @param {string} symbol Not used by Krakenfutures
@@ -1006,6 +1018,10 @@ export default class krakenfutures extends Exchange {
1006
1018
  }
1007
1019
  async cancelOrder(id, symbol = undefined, params = {}) {
1008
1020
  /**
1021
+ * @method
1022
+ * @name krakenfutures#cancelOrder
1023
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-cancel-order
1024
+ * @description Cancel an open order on the exchange
1009
1025
  * @param {string} id Order id
1010
1026
  * @param {string} symbol Not used by Krakenfutures
1011
1027
  * @param {object} [params] Exchange specific params
@@ -1089,6 +1105,7 @@ export default class krakenfutures extends Exchange {
1089
1105
  /**
1090
1106
  * @method
1091
1107
  * @name krakenfutures#cancelAllOrders
1108
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-cancel-all-orders
1092
1109
  * @description Cancels all orders on the exchange, including trigger orders
1093
1110
  * @param {str} symbol Unified market symbol
1094
1111
  * @param {dict} [params] Exchange specific params
@@ -1105,6 +1122,7 @@ export default class krakenfutures extends Exchange {
1105
1122
  /**
1106
1123
  * @method
1107
1124
  * @name krakenfutures#fetchOpenOrders
1125
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-get-open-orders
1108
1126
  * @description Gets all open orders, including trigger orders, for an account from the exchange api
1109
1127
  * @param {string} symbol Unified market symbol
1110
1128
  * @param {int} [since] Timestamp (ms) of earliest order. (Not used by kraken api but filtered internally by CCXT)
@@ -1512,6 +1530,18 @@ export default class krakenfutures extends Exchange {
1512
1530
  });
1513
1531
  }
1514
1532
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1533
+ /**
1534
+ * @method
1535
+ * @name krakenfutures#fetchMyTrades
1536
+ * @description fetch all trades made by the user
1537
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-historical-data-get-your-fills
1538
+ * @param {string} symbol unified market symbol
1539
+ * @param {int} [since] *not used by the api* the earliest time in ms to fetch trades for
1540
+ * @param {int} [limit] the maximum number of trades structures to retrieve
1541
+ * @param {object} [params] extra parameters specific to the bybit api endpoint
1542
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1543
+ * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1544
+ */
1515
1545
  await this.loadMarkets();
1516
1546
  let market = undefined;
1517
1547
  if (symbol !== undefined) {
@@ -1544,9 +1574,10 @@ export default class krakenfutures extends Exchange {
1544
1574
  /**
1545
1575
  * @method
1546
1576
  * @name krakenfutures#fetchBalance
1577
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-wallets
1547
1578
  * @description Fetch the balance for a sub-account, all sub-account balances are inside 'info' in the response
1548
1579
  * @param {object} [params] Exchange specific parameters
1549
- * @param {string} [params.type] The sub-account type to query the balance of, possible values include 'flex', 'cash'/'main'/'funding', or a market symbol * defaults to 'cash' *
1580
+ * @param {string} [params.type] The sub-account type to query the balance of, possible values include 'flex', 'cash'/'main'/'funding', or a market symbol * defaults to 'flex' *
1550
1581
  * @param {string} [params.symbol] A unified market symbol, when assigned the balance for a trading market that matches the symbol is returned
1551
1582
  * @returns A [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
1552
1583
  */
@@ -1650,7 +1681,7 @@ export default class krakenfutures extends Exchange {
1650
1681
  type = symbol;
1651
1682
  }
1652
1683
  if (type === undefined) {
1653
- type = (symbol === undefined) ? 'cash' : symbol;
1684
+ type = (symbol === undefined) ? 'flex' : symbol;
1654
1685
  }
1655
1686
  const accountName = this.parseAccount(type);
1656
1687
  const accounts = this.safeValue(response, 'accounts');
@@ -1848,6 +1879,17 @@ export default class krakenfutures extends Exchange {
1848
1879
  };
1849
1880
  }
1850
1881
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1882
+ /**
1883
+ * @method
1884
+ * @name krakenfutures#fetchFundingRateHistory
1885
+ * @description fetches historical funding rate prices
1886
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-historical-funding-rates-historical-funding-rates
1887
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
1888
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1889
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
1890
+ * @param {object} [params] extra parameters specific to the api endpoint
1891
+ * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
1892
+ */
1851
1893
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
1852
1894
  await this.loadMarkets();
1853
1895
  const market = this.market(symbol);
@@ -1878,7 +1920,7 @@ export default class krakenfutures extends Exchange {
1878
1920
  result.push({
1879
1921
  'info': item,
1880
1922
  'symbol': symbol,
1881
- 'fundingRate': this.safeNumber(item, 'fundingRate'),
1923
+ 'fundingRate': this.safeNumber(item, 'relativeFundingRate'),
1882
1924
  'timestamp': this.parse8601(datetime),
1883
1925
  'datetime': datetime,
1884
1926
  });
@@ -1890,6 +1932,7 @@ export default class krakenfutures extends Exchange {
1890
1932
  /**
1891
1933
  * @method
1892
1934
  * @name krakenfutures#fetchPositions
1935
+ * @see https://docs.futures.kraken.com/#websocket-api-private-feeds-open-positions
1893
1936
  * @description Fetches current contract trading positions
1894
1937
  * @param {string[]} symbols List of unified symbols
1895
1938
  * @param {object} [params] Not used by krakenfutures
@@ -1969,7 +2012,7 @@ export default class krakenfutures extends Exchange {
1969
2012
  'entryPrice': this.safeNumber(position, 'price'),
1970
2013
  'notional': undefined,
1971
2014
  'leverage': leverage,
1972
- 'unrealizedPnl': this.safeNumber(position, 'unrealizedFunding'),
2015
+ 'unrealizedPnl': undefined,
1973
2016
  'contracts': this.safeNumber(position, 'size'),
1974
2017
  'contractSize': this.safeNumber(market, 'contractSize'),
1975
2018
  'marginRatio': undefined,
@@ -1982,6 +2025,15 @@ export default class krakenfutures extends Exchange {
1982
2025
  };
1983
2026
  }
1984
2027
  async fetchLeverageTiers(symbols = undefined, params = {}) {
2028
+ /**
2029
+ * @method
2030
+ * @name krakenfutures#fetchLeverageTiers
2031
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-instrument-details-get-instruments
2032
+ * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
2033
+ * @param {string[]|undefined} symbols list of unified market symbols
2034
+ * @param {object} [params] extra parameters specific to the krakenfutures api endpoint
2035
+ * @returns {object} a dictionary of [leverage tiers structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#leverage-tiers-structure}, indexed by market symbols
2036
+ */
1985
2037
  await this.loadMarkets();
1986
2038
  const response = await this.publicGetInstruments(params);
1987
2039
  //
@@ -2161,6 +2213,8 @@ export default class krakenfutures extends Exchange {
2161
2213
  /**
2162
2214
  * @method
2163
2215
  * @name krakenfutures#transfer
2216
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-wallet-transfer
2217
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-withdrawal-to-spot-wallet
2164
2218
  * @description transfers currencies between sub-accounts
2165
2219
  * @param {string} code Unified currency code
2166
2220
  * @param {float} amount Size of the transfer
package/js/src/mexc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/mexc.js';
2
- import { IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook } from './base/types.js';
2
+ import { IndexType, Int, OrderSide, Balances, OrderType, OHLCV, FundingRateHistory, Position, OrderBook, OrderRequest } from './base/types.js';
3
3
  /**
4
4
  * @class mexc
5
5
  * @extends Exchange
@@ -31,8 +31,10 @@ export default class mexc extends Exchange {
31
31
  parseTicker(ticker: any, market?: any): import("./base/types.js").Ticker;
32
32
  fetchBidsAsks(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
33
33
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
34
+ createSpotOrderRequest(market: any, type: any, side: any, amount: any, price?: any, marginMode?: any, params?: {}): any;
34
35
  createSpotOrder(market: any, type: any, side: any, amount: any, price?: any, marginMode?: any, params?: {}): Promise<import("./base/types.js").Order>;
35
36
  createSwapOrder(market: any, type: any, side: any, amount: any, price?: any, marginMode?: any, params?: {}): Promise<import("./base/types.js").Order>;
37
+ createOrders(orders: OrderRequest[], params?: {}): Promise<import("./base/types.js").Order[]>;
36
38
  fetchOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
37
39
  fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
38
40
  fetchOrdersByIds(ids: any, symbol?: string, params?: {}): Promise<import("./base/types.js").Order[]>;
package/js/src/mexc.js CHANGED
@@ -39,6 +39,7 @@ export default class mexc extends Exchange {
39
39
  'cancelOrders': undefined,
40
40
  'createDepositAddress': true,
41
41
  'createOrder': true,
42
+ 'createOrders': true,
42
43
  'createReduceOnlyOrder': true,
43
44
  'deposit': undefined,
44
45
  'editOrder': undefined,
@@ -2083,7 +2084,7 @@ export default class mexc extends Exchange {
2083
2084
  return await this.createSwapOrder(market, type, side, amount, price, marginMode, query);
2084
2085
  }
2085
2086
  }
2086
- async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2087
+ createSpotOrderRequest(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2087
2088
  const symbol = market['symbol'];
2088
2089
  const orderSide = (side === 'buy') ? 'BUY' : 'SELL';
2089
2090
  const request = {
@@ -2120,19 +2121,28 @@ export default class mexc extends Exchange {
2120
2121
  request['newClientOrderId'] = clientOrderId;
2121
2122
  params = this.omit(params, ['type', 'clientOrderId']);
2122
2123
  }
2123
- let method = 'spotPrivatePostOrder';
2124
2124
  if (marginMode !== undefined) {
2125
2125
  if (marginMode !== 'isolated') {
2126
2126
  throw new BadRequest(this.id + ' createOrder() does not support marginMode ' + marginMode + ' for spot-margin trading');
2127
2127
  }
2128
- method = 'spotPrivatePostMarginOrder';
2129
2128
  }
2130
2129
  let postOnly = undefined;
2131
2130
  [postOnly, params] = this.handlePostOnly(type === 'market', type === 'LIMIT_MAKER', params);
2132
2131
  if (postOnly) {
2133
2132
  request['type'] = 'LIMIT_MAKER';
2134
2133
  }
2135
- const response = await this[method](this.extend(request, params));
2134
+ return this.extend(request, params);
2135
+ }
2136
+ async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2137
+ await this.loadMarkets();
2138
+ const request = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, params);
2139
+ let response = undefined;
2140
+ if (marginMode !== undefined) {
2141
+ response = await this.spotPrivatePostMarginOrder(this.extend(request, params));
2142
+ }
2143
+ else {
2144
+ response = await this.spotPrivatePostOrder(this.extend(request, params));
2145
+ }
2136
2146
  //
2137
2147
  // spot
2138
2148
  //
@@ -2265,6 +2275,70 @@ export default class mexc extends Exchange {
2265
2275
  const data = this.safeString(response, 'data');
2266
2276
  return this.parseOrder(data, market);
2267
2277
  }
2278
+ async createOrders(orders, params = {}) {
2279
+ /**
2280
+ * @method
2281
+ * @name mexc#createOrders
2282
+ * @description *spot only* *all orders must have the same symbol* create a list of trade orders
2283
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#batch-orders
2284
+ * @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2285
+ * @param {object} [params] extra parameters specific to api endpoint
2286
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2287
+ */
2288
+ await this.loadMarkets();
2289
+ const ordersRequests = [];
2290
+ let symbol = undefined;
2291
+ for (let i = 0; i < orders.length; i++) {
2292
+ const rawOrder = orders[i];
2293
+ const marketId = this.safeString(rawOrder, 'symbol');
2294
+ const market = this.market(marketId);
2295
+ if (!market['spot']) {
2296
+ throw new NotSupported(this.id + ' createOrders() is only supported for spot markets');
2297
+ }
2298
+ if (symbol === undefined) {
2299
+ symbol = marketId;
2300
+ }
2301
+ else {
2302
+ if (symbol !== marketId) {
2303
+ throw new BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
2304
+ }
2305
+ }
2306
+ const type = this.safeString(rawOrder, 'type');
2307
+ const side = this.safeString(rawOrder, 'side');
2308
+ const amount = this.safeValue(rawOrder, 'amount');
2309
+ const price = this.safeValue(rawOrder, 'price');
2310
+ const orderParams = this.safeValue(rawOrder, 'params', {});
2311
+ let marginMode = undefined;
2312
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
2313
+ const orderRequest = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, orderParams);
2314
+ ordersRequests.push(orderRequest);
2315
+ }
2316
+ const request = {
2317
+ 'batchOrders': ordersRequests,
2318
+ };
2319
+ const response = await this.spotPrivatePostBatchOrders(request);
2320
+ //
2321
+ // [
2322
+ // {
2323
+ // "symbol": "BTCUSDT",
2324
+ // "orderId": "1196315350023612316",
2325
+ // "newClientOrderId": "hio8279hbdsds",
2326
+ // "orderListId": -1
2327
+ // },
2328
+ // {
2329
+ // "newClientOrderId": "123456",
2330
+ // "msg": "The minimum transaction volume cannot be less than:0.5USDT",
2331
+ // "code": 30002
2332
+ // },
2333
+ // {
2334
+ // "symbol": "BTCUSDT",
2335
+ // "orderId": "1196315350023612318",
2336
+ // "orderListId": -1
2337
+ // }
2338
+ // ]
2339
+ //
2340
+ return this.parseOrders(response);
2341
+ }
2268
2342
  async fetchOrder(id, symbol = undefined, params = {}) {
2269
2343
  /**
2270
2344
  * @method
@@ -3125,6 +3199,23 @@ export default class mexc extends Exchange {
3125
3199
  // "updateTime": "1648984276000",
3126
3200
  // }
3127
3201
  //
3202
+ // createOrders error
3203
+ //
3204
+ // {
3205
+ // "newClientOrderId": "123456",
3206
+ // "msg": "The minimum transaction volume cannot be less than:0.5USDT",
3207
+ // "code": 30002
3208
+ // }
3209
+ //
3210
+ const code = this.safeInteger(order, 'code');
3211
+ if (code !== undefined) {
3212
+ // error upon placing multiple orders
3213
+ return this.safeOrder({
3214
+ 'info': order,
3215
+ 'status': 'rejected',
3216
+ 'clientOrderId': this.safeString(order, 'newClientOrderId'),
3217
+ });
3218
+ }
3128
3219
  let id = undefined;
3129
3220
  if (typeof order === 'string') {
3130
3221
  id = order;
package/js/src/okx.js CHANGED
@@ -375,6 +375,7 @@ export default class okx extends Exchange {
375
375
  'sprd/order': 1,
376
376
  'sprd/cancel-order': 1,
377
377
  'sprd/mass-cancel': 1,
378
+ 'sprd/amend-order': 1,
378
379
  // trade
379
380
  'trade/order': 1 / 3,
380
381
  'trade/batch-orders': 1 / 15,
package/js/src/phemex.js CHANGED
@@ -1817,6 +1817,9 @@ export default class phemex extends Exchange {
1817
1817
  [type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1818
1818
  let method = 'privateGetSpotWallets';
1819
1819
  const request = {};
1820
+ if ((type !== 'spot') && (type !== 'swap')) {
1821
+ throw new BadRequest(this.id + ' does not support ' + type + ' markets, only spot and swap');
1822
+ }
1820
1823
  if (type === 'swap') {
1821
1824
  const code = this.safeString(params, 'code');
1822
1825
  let settle = undefined;
@@ -355,6 +355,7 @@ export default class huobi extends huobiRest {
355
355
  // id: 1583473663565,
356
356
  // rep: 'market.btcusdt.mbp.150',
357
357
  // status: 'ok',
358
+ // ts: 1698359289261,
358
359
  // data: {
359
360
  // seqNum: 104999417756,
360
361
  // bids: [
@@ -383,6 +384,9 @@ export default class huobi extends huobiRest {
383
384
  const sequence = this.safeInteger(tick, 'seqNum');
384
385
  const nonce = this.safeInteger(data, 'seqNum');
385
386
  snapshot['nonce'] = nonce;
387
+ const timestamp = this.safeInteger(message, 'ts');
388
+ snapshot['timestamp'] = timestamp;
389
+ snapshot['datetime'] = this.iso8601(timestamp);
386
390
  const snapshotLimit = this.safeInteger(subscription, 'limit');
387
391
  const snapshotOrderBook = this.orderBook(snapshot, snapshotLimit);
388
392
  client.resolve(snapshotOrderBook, id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.28",
3
+ "version": "4.1.30",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",