ccxt 4.4.40 → 4.4.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +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 +20 -3
  5. package/dist/cjs/src/binance.js +24 -24
  6. package/dist/cjs/src/bingx.js +3 -1
  7. package/dist/cjs/src/bitfinex.js +1 -1
  8. package/dist/cjs/src/bitget.js +1 -0
  9. package/dist/cjs/src/bitmart.js +254 -1
  10. package/dist/cjs/src/bybit.js +8 -8
  11. package/dist/cjs/src/exmo.js +62 -4
  12. package/dist/cjs/src/gate.js +1 -1
  13. package/dist/cjs/src/htx.js +1 -1
  14. package/dist/cjs/src/hyperliquid.js +65 -1
  15. package/dist/cjs/src/kraken.js +129 -26
  16. package/dist/cjs/src/kucoin.js +6 -1
  17. package/dist/cjs/src/mexc.js +3 -3
  18. package/dist/cjs/src/okx.js +6 -1
  19. package/dist/cjs/src/xt.js +5 -2
  20. package/js/ccxt.d.ts +3 -3
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/bitmart.d.ts +2 -0
  23. package/js/src/abstract/okx.d.ts +5 -0
  24. package/js/src/base/Exchange.d.ts +6 -3
  25. package/js/src/base/Exchange.js +20 -3
  26. package/js/src/base/types.d.ts +2 -0
  27. package/js/src/binance.js +24 -24
  28. package/js/src/bingx.js +3 -1
  29. package/js/src/bitfinex.js +1 -1
  30. package/js/src/bitget.js +1 -0
  31. package/js/src/bitmart.d.ts +52 -1
  32. package/js/src/bitmart.js +254 -1
  33. package/js/src/bybit.js +8 -8
  34. package/js/src/exmo.d.ts +35 -0
  35. package/js/src/exmo.js +62 -4
  36. package/js/src/gate.js +1 -1
  37. package/js/src/htx.js +1 -1
  38. package/js/src/hyperliquid.d.ts +20 -1
  39. package/js/src/hyperliquid.js +65 -1
  40. package/js/src/kraken.d.ts +13 -7
  41. package/js/src/kraken.js +129 -26
  42. package/js/src/kucoin.js +6 -1
  43. package/js/src/mexc.js +3 -3
  44. package/js/src/okx.js +6 -1
  45. package/js/src/xt.js +5 -2
  46. package/package.json +2 -2
package/js/src/bitmart.js CHANGED
@@ -65,12 +65,13 @@ export default class bitmart extends Exchange {
65
65
  'fetchDeposits': true,
66
66
  'fetchDepositWithdrawFee': true,
67
67
  'fetchDepositWithdrawFees': false,
68
- 'fetchFundingHistory': undefined,
68
+ 'fetchFundingHistory': true,
69
69
  'fetchFundingRate': true,
70
70
  'fetchFundingRateHistory': false,
71
71
  'fetchFundingRates': false,
72
72
  'fetchIsolatedBorrowRate': true,
73
73
  'fetchIsolatedBorrowRates': true,
74
+ 'fetchLedger': true,
74
75
  'fetchLiquidations': false,
75
76
  'fetchMarginMode': false,
76
77
  'fetchMarkets': true,
@@ -157,6 +158,7 @@ export default class bitmart extends Exchange {
157
158
  'contract/public/depth': 5,
158
159
  'contract/public/open-interest': 30,
159
160
  'contract/public/funding-rate': 30,
161
+ 'contract/public/funding-rate-history': 30,
160
162
  'contract/public/kline': 6,
161
163
  'account/v1/currencies': 30,
162
164
  },
@@ -207,6 +209,7 @@ export default class bitmart extends Exchange {
207
209
  'contract/private/position-risk': 10,
208
210
  'contract/private/affilate/rebate-list': 10,
209
211
  'contract/private/affilate/trade-list': 10,
212
+ 'contract/private/transaction-history': 10,
210
213
  },
211
214
  'post': {
212
215
  // sub-account endpoints
@@ -4618,6 +4621,65 @@ export default class bitmart extends Exchange {
4618
4621
  const data = this.safeDict(response, 'data', {});
4619
4622
  return this.parseFundingRate(data, market);
4620
4623
  }
4624
+ /**
4625
+ * @method
4626
+ * @name bitmart#fetchFundingRateHistory
4627
+ * @description fetches historical funding rate prices
4628
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-funding-rate-history
4629
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
4630
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
4631
+ * @param {int} [limit] the maximum amount of funding rate structures to fetch
4632
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4633
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
4634
+ */
4635
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4636
+ if (symbol === undefined) {
4637
+ throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
4638
+ }
4639
+ await this.loadMarkets();
4640
+ const market = this.market(symbol);
4641
+ const request = {
4642
+ 'symbol': market['id'],
4643
+ };
4644
+ if (limit !== undefined) {
4645
+ request['limit'] = limit;
4646
+ }
4647
+ const response = await this.publicGetContractPublicFundingRateHistory(this.extend(request, params));
4648
+ //
4649
+ // {
4650
+ // "code": 1000,
4651
+ // "message": "Ok",
4652
+ // "data": {
4653
+ // "list": [
4654
+ // {
4655
+ // "symbol": "BTCUSDT",
4656
+ // "funding_rate": "0.000091412174",
4657
+ // "funding_time": "1734336000000"
4658
+ // },
4659
+ // ]
4660
+ // },
4661
+ // "trace": "fg73d949fgfdf6a40c8fc7f5ae6738.54.345345345345"
4662
+ // }
4663
+ //
4664
+ const data = this.safeDict(response, 'data', {});
4665
+ const result = this.safeList(data, 'list', []);
4666
+ const rates = [];
4667
+ for (let i = 0; i < result.length; i++) {
4668
+ const entry = result[i];
4669
+ const marketId = this.safeString(entry, 'symbol');
4670
+ const symbolInner = this.safeSymbol(marketId, market, '-', 'swap');
4671
+ const timestamp = this.safeInteger(entry, 'funding_time');
4672
+ rates.push({
4673
+ 'info': entry,
4674
+ 'symbol': symbolInner,
4675
+ 'fundingRate': this.safeNumber(entry, 'funding_rate'),
4676
+ 'timestamp': timestamp,
4677
+ 'datetime': this.iso8601(timestamp),
4678
+ });
4679
+ }
4680
+ const sorted = this.sortBy(rates, 'timestamp');
4681
+ return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
4682
+ }
4621
4683
  parseFundingRate(contract, market = undefined) {
4622
4684
  //
4623
4685
  // {
@@ -5052,6 +5114,197 @@ export default class bitmart extends Exchange {
5052
5114
  const data = this.safeDict(response, 'data', {});
5053
5115
  return this.parseOrder(data, market);
5054
5116
  }
5117
+ /**
5118
+ * @method
5119
+ * @name bitmart#fetchLedger
5120
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
5121
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
5122
+ * @param {string} [code] unified currency code
5123
+ * @param {int} [since] timestamp in ms of the earliest ledger entry
5124
+ * @param {int} [limit] max number of ledger entries to return
5125
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5126
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
5127
+ * @returns {object[]} a list of [ledger structures]{@link https://docs.ccxt.com/#/?id=ledger}
5128
+ */
5129
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
5130
+ await this.loadMarkets();
5131
+ let currency = undefined;
5132
+ if (code !== undefined) {
5133
+ currency = this.currency(code);
5134
+ }
5135
+ let request = {};
5136
+ [request, params] = this.handleUntilOption('end_time', request, params);
5137
+ const transactionsRequest = this.fetchTransactionsRequest(0, undefined, since, limit, params);
5138
+ const response = await this.privateGetContractPrivateTransactionHistory(transactionsRequest);
5139
+ //
5140
+ // {
5141
+ // "code": 1000,
5142
+ // "message": "Ok",
5143
+ // "data": [
5144
+ // {
5145
+ // "time": "1734422402121",
5146
+ // "type": "Funding Fee",
5147
+ // "amount": "-0.00008253",
5148
+ // "asset": "USDT",
5149
+ // "symbol": "LTCUSDT",
5150
+ // "tran_id": "1734422402121",
5151
+ // "flow_type": 3
5152
+ // },
5153
+ // ],
5154
+ // "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
5155
+ // }
5156
+ //
5157
+ const data = this.safeList(response, 'data', []);
5158
+ return this.parseLedger(data, currency, since, limit);
5159
+ }
5160
+ parseLedgerEntry(item, currency = undefined) {
5161
+ //
5162
+ // {
5163
+ // "time": "1734422402121",
5164
+ // "type": "Funding Fee",
5165
+ // "amount": "-0.00008253",
5166
+ // "asset": "USDT",
5167
+ // "symbol": "LTCUSDT",
5168
+ // "tran_id": "1734422402121",
5169
+ // "flow_type": 3
5170
+ // }
5171
+ //
5172
+ let amount = this.safeString(item, 'amount');
5173
+ let direction = undefined;
5174
+ if (Precise.stringLe(amount, '0')) {
5175
+ direction = 'out';
5176
+ amount = Precise.stringMul('-1', amount);
5177
+ }
5178
+ else {
5179
+ direction = 'in';
5180
+ }
5181
+ const currencyId = this.safeString(item, 'asset');
5182
+ const timestamp = this.safeInteger(item, 'time');
5183
+ const type = this.safeString(item, 'type');
5184
+ return this.safeLedgerEntry({
5185
+ 'info': item,
5186
+ 'id': this.safeString(item, 'tran_id'),
5187
+ 'direction': direction,
5188
+ 'account': undefined,
5189
+ 'referenceAccount': undefined,
5190
+ 'referenceId': this.safeString(item, 'tradeId'),
5191
+ 'type': this.parseLedgerEntryType(type),
5192
+ 'currency': this.safeCurrencyCode(currencyId, currency),
5193
+ 'amount': this.parseNumber(amount),
5194
+ 'timestamp': timestamp,
5195
+ 'datetime': this.iso8601(timestamp),
5196
+ 'before': undefined,
5197
+ 'after': undefined,
5198
+ 'status': undefined,
5199
+ 'fee': undefined,
5200
+ }, currency);
5201
+ }
5202
+ parseLedgerEntryType(type) {
5203
+ const ledgerType = {
5204
+ 'Commission Fee': 'fee',
5205
+ 'Funding Fee': 'fee',
5206
+ 'Realized PNL': 'trade',
5207
+ 'Transfer': 'transfer',
5208
+ 'Liquidation Clearance': 'settlement',
5209
+ };
5210
+ return this.safeString(ledgerType, type, type);
5211
+ }
5212
+ fetchTransactionsRequest(flowType = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
5213
+ let request = {};
5214
+ if (flowType !== undefined) {
5215
+ request['flow_type'] = flowType;
5216
+ }
5217
+ let market = undefined;
5218
+ if (symbol !== undefined) {
5219
+ market = this.market(symbol);
5220
+ request['symbol'] = market['id'];
5221
+ }
5222
+ if (since !== undefined) {
5223
+ request['start_time'] = since;
5224
+ }
5225
+ if (limit !== undefined) {
5226
+ request['page_size'] = limit;
5227
+ }
5228
+ [request, params] = this.handleUntilOption('end_time', request, params);
5229
+ return this.extend(request, params);
5230
+ }
5231
+ /**
5232
+ * @method
5233
+ * @name bitmart#fetchFundingHistory
5234
+ * @description fetch the history of funding payments paid and received on this account
5235
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
5236
+ * @param {string} [symbol] unified market symbol
5237
+ * @param {int} [since] the starting timestamp in milliseconds
5238
+ * @param {int} [limit] the number of entries to return
5239
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5240
+ * @param {int} [params.until] the latest time in ms to fetch funding history for
5241
+ * @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
5242
+ */
5243
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5244
+ await this.loadMarkets();
5245
+ let market = undefined;
5246
+ if (symbol !== undefined) {
5247
+ market = this.market(symbol);
5248
+ }
5249
+ let request = {};
5250
+ [request, params] = this.handleUntilOption('end_time', request, params);
5251
+ const transactionsRequest = this.fetchTransactionsRequest(3, symbol, since, limit, params);
5252
+ const response = await this.privateGetContractPrivateTransactionHistory(transactionsRequest);
5253
+ //
5254
+ // {
5255
+ // "code": 1000,
5256
+ // "message": "Ok",
5257
+ // "data": [
5258
+ // {
5259
+ // "time": "1734422402121",
5260
+ // "type": "Funding Fee",
5261
+ // "amount": "-0.00008253",
5262
+ // "asset": "USDT",
5263
+ // "symbol": "LTCUSDT",
5264
+ // "tran_id": "1734422402121",
5265
+ // "flow_type": 3
5266
+ // },
5267
+ // ],
5268
+ // "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
5269
+ // }
5270
+ //
5271
+ const data = this.safeList(response, 'data', []);
5272
+ return this.parseFundingHistories(data, market, since, limit);
5273
+ }
5274
+ parseFundingHistory(contract, market = undefined) {
5275
+ //
5276
+ // {
5277
+ // "time": "1734422402121",
5278
+ // "type": "Funding Fee",
5279
+ // "amount": "-0.00008253",
5280
+ // "asset": "USDT",
5281
+ // "symbol": "LTCUSDT",
5282
+ // "tran_id": "1734422402121",
5283
+ // "flow_type": 3
5284
+ // }
5285
+ //
5286
+ const marketId = this.safeString(contract, 'symbol');
5287
+ const currencyId = this.safeString(contract, 'asset');
5288
+ const timestamp = this.safeInteger(contract, 'time');
5289
+ return {
5290
+ 'info': contract,
5291
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
5292
+ 'code': this.safeCurrencyCode(currencyId),
5293
+ 'timestamp': timestamp,
5294
+ 'datetime': this.iso8601(timestamp),
5295
+ 'id': this.safeString(contract, 'tran_id'),
5296
+ 'amount': this.safeNumber(contract, 'amount'),
5297
+ };
5298
+ }
5299
+ parseFundingHistories(contracts, market = undefined, since = undefined, limit = undefined) {
5300
+ const result = [];
5301
+ for (let i = 0; i < contracts.length; i++) {
5302
+ const contract = contracts[i];
5303
+ result.push(this.parseFundingHistory(contract, market));
5304
+ }
5305
+ const sorted = this.sortBy(result, 'timestamp');
5306
+ return this.filterBySinceLimit(sorted, since, limit);
5307
+ }
5055
5308
  nonce() {
5056
5309
  return this.milliseconds();
5057
5310
  }
package/js/src/bybit.js CHANGED
@@ -3685,33 +3685,33 @@ export default class bybit extends Exchange {
3685
3685
  const avgPrice = this.omitZero(this.safeString(order, 'avgPrice'));
3686
3686
  const rawTimeInForce = this.safeString(order, 'timeInForce');
3687
3687
  const timeInForce = this.parseTimeInForce(rawTimeInForce);
3688
- const stopPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
3688
+ const triggerPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
3689
3689
  const reduceOnly = this.safeBool(order, 'reduceOnly');
3690
3690
  let takeProfitPrice = this.omitZero(this.safeString(order, 'takeProfit'));
3691
3691
  let stopLossPrice = this.omitZero(this.safeString(order, 'stopLoss'));
3692
3692
  const triggerDirection = this.safeString(order, 'triggerDirection');
3693
3693
  const isAscending = (triggerDirection === '1');
3694
- const isStopOrderType2 = (stopPrice !== undefined) && reduceOnly;
3694
+ const isStopOrderType2 = (triggerPrice !== undefined) && reduceOnly;
3695
3695
  if ((stopLossPrice === undefined) && isStopOrderType2) {
3696
3696
  // check if order is stop order type 2 - stopLossPrice
3697
3697
  if (isAscending && (side === 'buy')) {
3698
3698
  // stopLoss order against short position
3699
- stopLossPrice = stopPrice;
3699
+ stopLossPrice = triggerPrice;
3700
3700
  }
3701
3701
  if (!isAscending && (side === 'sell')) {
3702
3702
  // stopLoss order against a long position
3703
- stopLossPrice = stopPrice;
3703
+ stopLossPrice = triggerPrice;
3704
3704
  }
3705
3705
  }
3706
3706
  if ((takeProfitPrice === undefined) && isStopOrderType2) {
3707
3707
  // check if order is stop order type 2 - takeProfitPrice
3708
3708
  if (isAscending && (side === 'sell')) {
3709
3709
  // takeprofit order against a long position
3710
- takeProfitPrice = stopPrice;
3710
+ takeProfitPrice = triggerPrice;
3711
3711
  }
3712
3712
  if (!isAscending && (side === 'buy')) {
3713
3713
  // takeprofit order against a short position
3714
- takeProfitPrice = stopPrice;
3714
+ takeProfitPrice = triggerPrice;
3715
3715
  }
3716
3716
  }
3717
3717
  return this.safeOrder({
@@ -3729,7 +3729,7 @@ export default class bybit extends Exchange {
3729
3729
  'reduceOnly': this.safeBool(order, 'reduceOnly'),
3730
3730
  'side': side,
3731
3731
  'price': price,
3732
- 'triggerPrice': stopPrice,
3732
+ 'triggerPrice': triggerPrice,
3733
3733
  'takeProfitPrice': takeProfitPrice,
3734
3734
  'stopLossPrice': stopLossPrice,
3735
3735
  'amount': amount,
@@ -6757,7 +6757,7 @@ export default class bybit extends Exchange {
6757
6757
  const data = this.addPaginationCursorToResult(response);
6758
6758
  const id = this.safeString(result, 'symbol');
6759
6759
  market = this.safeMarket(id, market, undefined, 'contract');
6760
- return this.parseOpenInterests(data, market, since, limit);
6760
+ return this.parseOpenInterestsHistory(data, market, since, limit);
6761
6761
  }
6762
6762
  /**
6763
6763
  * @method
package/js/src/exmo.d.ts CHANGED
@@ -182,6 +182,40 @@ export default class exmo extends Exchange {
182
182
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
183
183
  */
184
184
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
185
+ /**
186
+ * @method
187
+ * @name exmo#createMarketOrderWithCost
188
+ * @description create a market order by providing the symbol, side and cost
189
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
190
+ * @param {string} symbol unified symbol of the market to create an order in
191
+ * @param {string} side 'buy' or 'sell'
192
+ * @param {float} cost how much you want to trade in units of the quote currency
193
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
194
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
195
+ */
196
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: number, params?: {}): Promise<Order>;
197
+ /**
198
+ * @method
199
+ * @name exmo#createMarketBuyOrderWithCost
200
+ * @description create a market buy order by providing the symbol and cost
201
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
202
+ * @param {string} symbol unified symbol of the market to create an order in
203
+ * @param {float} cost how much you want to trade in units of the quote currency
204
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
205
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
206
+ */
207
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
208
+ /**
209
+ * @method
210
+ * @name exmo#createMarketSellOrderWithCost
211
+ * @description create a market sell order by providing the symbol and cost
212
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
213
+ * @param {string} symbol unified symbol of the market to create an order in
214
+ * @param {float} cost how much you want to trade in units of the quote currency
215
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
216
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
217
+ */
218
+ createMarketSellOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
185
219
  /**
186
220
  * @method
187
221
  * @name exmo#createOrder
@@ -198,6 +232,7 @@ export default class exmo extends Exchange {
198
232
  * @param {float} [params.stopPrice] the price at which a trigger order is triggered at
199
233
  * @param {string} [params.timeInForce] *spot only* 'fok', 'ioc' or 'post_only'
200
234
  * @param {boolean} [params.postOnly] *spot only* true for post only orders
235
+ * @param {float} [params.cost] *spot only* *market orders only* the cost of the order in the quote currency for market orders
201
236
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
202
237
  */
203
238
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
package/js/src/exmo.js CHANGED
@@ -34,6 +34,9 @@ export default class exmo extends Exchange {
34
34
  'cancelOrder': true,
35
35
  'cancelOrders': false,
36
36
  'createDepositAddress': false,
37
+ 'createMarketBuyOrder': true,
38
+ 'createMarketBuyOrderWithCost': true,
39
+ 'createMarketOrderWithCost': true,
37
40
  'createOrder': true,
38
41
  'createStopLimitOrder': true,
39
42
  'createStopMarketOrder': true,
@@ -1409,6 +1412,52 @@ export default class exmo extends Exchange {
1409
1412
  }
1410
1413
  return this.filterBySinceLimit(result, since, limit);
1411
1414
  }
1415
+ /**
1416
+ * @method
1417
+ * @name exmo#createMarketOrderWithCost
1418
+ * @description create a market order by providing the symbol, side and cost
1419
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
1420
+ * @param {string} symbol unified symbol of the market to create an order in
1421
+ * @param {string} side 'buy' or 'sell'
1422
+ * @param {float} cost how much you want to trade in units of the quote currency
1423
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1424
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1425
+ */
1426
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1427
+ await this.loadMarkets();
1428
+ params = this.extend(params, { 'cost': cost });
1429
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
1430
+ }
1431
+ /**
1432
+ * @method
1433
+ * @name exmo#createMarketBuyOrderWithCost
1434
+ * @description create a market buy order by providing the symbol and cost
1435
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
1436
+ * @param {string} symbol unified symbol of the market to create an order in
1437
+ * @param {float} cost how much you want to trade in units of the quote currency
1438
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1439
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1440
+ */
1441
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1442
+ await this.loadMarkets();
1443
+ params = this.extend(params, { 'cost': cost });
1444
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1445
+ }
1446
+ /**
1447
+ * @method
1448
+ * @name exmo#createMarketSellOrderWithCost
1449
+ * @description create a market sell order by providing the symbol and cost
1450
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
1451
+ * @param {string} symbol unified symbol of the market to create an order in
1452
+ * @param {float} cost how much you want to trade in units of the quote currency
1453
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1454
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1455
+ */
1456
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
1457
+ await this.loadMarkets();
1458
+ params = this.extend(params, { 'cost': cost });
1459
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, params);
1460
+ }
1412
1461
  /**
1413
1462
  * @method
1414
1463
  * @name exmo#createOrder
@@ -1425,6 +1474,7 @@ export default class exmo extends Exchange {
1425
1474
  * @param {float} [params.stopPrice] the price at which a trigger order is triggered at
1426
1475
  * @param {string} [params.timeInForce] *spot only* 'fok', 'ioc' or 'post_only'
1427
1476
  * @param {boolean} [params.postOnly] *spot only* true for post only orders
1477
+ * @param {float} [params.cost] *spot only* *market orders only* the cost of the order in the quote currency for market orders
1428
1478
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1429
1479
  */
1430
1480
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1437,11 +1487,12 @@ export default class exmo extends Exchange {
1437
1487
  throw new BadRequest(this.id + ' only supports isolated margin');
1438
1488
  }
1439
1489
  const isSpot = (marginMode !== 'isolated');
1440
- const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
1490
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
1491
+ const cost = this.safeString(params, 'cost');
1441
1492
  const request = {
1442
1493
  'pair': market['id'],
1443
1494
  // 'leverage': 2,
1444
- 'quantity': this.amountToPrecision(market['symbol'], amount),
1495
+ // 'quantity': this.amountToPrecision (market['symbol'], amount),
1445
1496
  // spot - buy, sell, market_buy, market_sell, market_buy_total, market_sell_total
1446
1497
  // margin - limit_buy, limit_sell, market_buy, market_sell, stop_buy, stop_sell, stop_limit_buy, stop_limit_sell, trailing_stop_buy, trailing_stop_sell
1447
1498
  // 'stop_price': this.priceToPrecision (symbol, stopPrice),
@@ -1450,6 +1501,12 @@ export default class exmo extends Exchange {
1450
1501
  // 'client_id': 123, // optional, must be a positive integer
1451
1502
  // 'comment': '', // up to 50 latin symbols, whitespaces, underscores
1452
1503
  };
1504
+ if (cost === undefined) {
1505
+ request['quantity'] = this.amountToPrecision(market['symbol'], amount);
1506
+ }
1507
+ else {
1508
+ request['quantity'] = this.costToPrecision(market['symbol'], cost);
1509
+ }
1453
1510
  let clientOrderId = this.safeValue2(params, 'client_id', 'clientOrderId');
1454
1511
  if (clientOrderId !== undefined) {
1455
1512
  clientOrderId = this.safeInteger2(params, 'client_id', 'clientOrderId');
@@ -1464,7 +1521,7 @@ export default class exmo extends Exchange {
1464
1521
  if (!isSpot && (leverage === undefined)) {
1465
1522
  throw new ArgumentsRequired(this.id + ' createOrder requires an extra param params["leverage"] for margin orders');
1466
1523
  }
1467
- params = this.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId']);
1524
+ params = this.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId', 'cost']);
1468
1525
  if (price !== undefined) {
1469
1526
  request['price'] = this.priceToPrecision(market['symbol'], price);
1470
1527
  }
@@ -1490,7 +1547,8 @@ export default class exmo extends Exchange {
1490
1547
  request['type'] = side;
1491
1548
  }
1492
1549
  else if (type === 'market') {
1493
- request['type'] = 'market_' + side;
1550
+ const marketSuffix = (cost !== undefined) ? '_total' : '';
1551
+ request['type'] = 'market_' + side + marketSuffix;
1494
1552
  }
1495
1553
  if (isPostOnly) {
1496
1554
  request['exec_type'] = 'post_only';
package/js/src/gate.js CHANGED
@@ -6899,7 +6899,7 @@ export default class gate extends Exchange {
6899
6899
  // ...
6900
6900
  // ]
6901
6901
  //
6902
- return this.parseOpenInterests(response, market, since, limit);
6902
+ return this.parseOpenInterestsHistory(response, market, since, limit);
6903
6903
  }
6904
6904
  parseOpenInterest(interest, market = undefined) {
6905
6905
  //
package/js/src/htx.js CHANGED
@@ -8643,7 +8643,7 @@ export default class htx extends Exchange {
8643
8643
  //
8644
8644
  const data = this.safeValue(response, 'data');
8645
8645
  const tick = this.safeList(data, 'tick');
8646
- return this.parseOpenInterests(tick, market, since, limit);
8646
+ return this.parseOpenInterestsHistory(tick, market, since, limit);
8647
8647
  }
8648
8648
  /**
8649
8649
  * @method
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/hyperliquid.js';
2
- import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification, Currencies, CancellationRequest, int, Transaction, Currency, TradingFeeInterface, Ticker, Tickers, LedgerEntry, FundingRates, FundingRate } from './base/types.js';
2
+ import type { Market, TransferEntry, Balances, Int, OrderBook, OHLCV, Str, FundingRateHistory, Order, OrderType, OrderSide, Trade, Strings, Position, OrderRequest, Dict, Num, MarginModification, Currencies, CancellationRequest, int, Transaction, Currency, TradingFeeInterface, Ticker, Tickers, LedgerEntry, FundingRates, FundingRate, OpenInterests } from './base/types.js';
3
3
  /**
4
4
  * @class hyperliquid
5
5
  * @augments Exchange
@@ -530,6 +530,25 @@ export default class hyperliquid extends Exchange {
530
530
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
531
531
  */
532
532
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
533
+ /**
534
+ * @method
535
+ * @name hyperliquid#fetchOpenInterests
536
+ * @description Retrieves the open interest for a list of symbols
537
+ * @param {string[]} [symbols] Unified CCXT market symbol
538
+ * @param {object} [params] exchange specific parameters
539
+ * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
540
+ */
541
+ fetchOpenInterests(symbols?: Strings, params?: {}): Promise<OpenInterests>;
542
+ /**
543
+ * @method
544
+ * @name hyperliquid#fetchOpenInterest
545
+ * @description retrieves the open interest of a contract trading pair
546
+ * @param {string} symbol unified CCXT market symbol
547
+ * @param {object} [params] exchange specific parameters
548
+ * @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
549
+ */
550
+ fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
551
+ parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
533
552
  extractTypeFromDelta(data?: any[]): any[];
534
553
  formatVaultAddress(address?: Str): string;
535
554
  handlePublicAddress(methodName: string, params: Dict): any[];
@@ -88,8 +88,9 @@ export default class hyperliquid extends Exchange {
88
88
  'fetchMyLiquidations': false,
89
89
  'fetchMyTrades': true,
90
90
  'fetchOHLCV': true,
91
- 'fetchOpenInterest': false,
91
+ 'fetchOpenInterest': true,
92
92
  'fetchOpenInterestHistory': false,
93
+ 'fetchOpenInterests': true,
93
94
  'fetchOpenOrders': true,
94
95
  'fetchOrder': true,
95
96
  'fetchOrderBook': true,
@@ -3255,6 +3256,69 @@ export default class hyperliquid extends Exchange {
3255
3256
  const withdrawals = this.filterByArray(records, 'type', ['withdraw'], false);
3256
3257
  return this.parseTransactions(withdrawals, undefined, since, limit);
3257
3258
  }
3259
+ /**
3260
+ * @method
3261
+ * @name hyperliquid#fetchOpenInterests
3262
+ * @description Retrieves the open interest for a list of symbols
3263
+ * @param {string[]} [symbols] Unified CCXT market symbol
3264
+ * @param {object} [params] exchange specific parameters
3265
+ * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
3266
+ */
3267
+ async fetchOpenInterests(symbols = undefined, params = {}) {
3268
+ await this.loadMarkets();
3269
+ symbols = this.marketSymbols(symbols);
3270
+ const swapMarkets = await this.fetchSwapMarkets();
3271
+ const result = this.parseOpenInterests(swapMarkets);
3272
+ return this.filterByArray(result, 'symbol', symbols);
3273
+ }
3274
+ /**
3275
+ * @method
3276
+ * @name hyperliquid#fetchOpenInterest
3277
+ * @description retrieves the open interest of a contract trading pair
3278
+ * @param {string} symbol unified CCXT market symbol
3279
+ * @param {object} [params] exchange specific parameters
3280
+ * @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
3281
+ */
3282
+ async fetchOpenInterest(symbol, params = {}) {
3283
+ symbol = this.symbol(symbol);
3284
+ await this.loadMarkets();
3285
+ const ois = await this.fetchOpenInterests([symbol], params);
3286
+ return ois[symbol];
3287
+ }
3288
+ parseOpenInterest(interest, market = undefined) {
3289
+ //
3290
+ // {
3291
+ // szDecimals: '2',
3292
+ // name: 'HYPE',
3293
+ // maxLeverage: '3',
3294
+ // funding: '0.00014735',
3295
+ // openInterest: '14677900.74',
3296
+ // prevDayPx: '26.145',
3297
+ // dayNtlVlm: '299643445.12560016',
3298
+ // premium: '0.00081613',
3299
+ // oraclePx: '27.569',
3300
+ // markPx: '27.63',
3301
+ // midPx: '27.599',
3302
+ // impactPxs: [ '27.5915', '27.6319' ],
3303
+ // dayBaseVlm: '10790652.83',
3304
+ // baseId: 159
3305
+ // }
3306
+ //
3307
+ interest = this.safeDict(interest, 'info', {});
3308
+ const coin = this.safeString(interest, 'name');
3309
+ let marketId = undefined;
3310
+ if (coin !== undefined) {
3311
+ marketId = this.coinToMarketId(coin);
3312
+ }
3313
+ return this.safeOpenInterest({
3314
+ 'symbol': this.safeSymbol(marketId),
3315
+ 'openInterestAmount': this.safeNumber(interest, 'openInterest'),
3316
+ 'openInterestValue': undefined,
3317
+ 'timestamp': undefined,
3318
+ 'datetime': undefined,
3319
+ 'info': interest,
3320
+ }, market);
3321
+ }
3258
3322
  extractTypeFromDelta(data = []) {
3259
3323
  const records = [];
3260
3324
  for (let i = 0; i < data.length; i++) {