ccxt 4.1.10 → 4.1.11

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 (56) hide show
  1. package/CONTRIBUTING.md +2 -0
  2. package/README.md +3 -3
  3. package/build.sh +3 -1
  4. package/dist/ccxt.browser.js +215 -78
  5. package/dist/ccxt.browser.min.js +3 -3
  6. package/dist/cjs/ccxt.js +1 -1
  7. package/dist/cjs/src/base/Exchange.js +30 -2
  8. package/dist/cjs/src/binance.js +21 -10
  9. package/dist/cjs/src/bingx.js +15 -9
  10. package/dist/cjs/src/bitget.js +2 -2
  11. package/dist/cjs/src/bitmart.js +2 -2
  12. package/dist/cjs/src/bybit.js +2 -2
  13. package/dist/cjs/src/coinex.js +3 -3
  14. package/dist/cjs/src/coinspot.js +103 -8
  15. package/dist/cjs/src/delta.js +2 -2
  16. package/dist/cjs/src/deribit.js +1 -1
  17. package/dist/cjs/src/huobi.js +5 -6
  18. package/dist/cjs/src/okx.js +3 -3
  19. package/dist/cjs/src/pro/binance.js +3 -9
  20. package/dist/cjs/src/pro/phemex.js +2 -2
  21. package/dist/cjs/src/whitebit.js +14 -11
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/binance.d.ts +3 -0
  25. package/js/src/abstract/binancecoinm.d.ts +3 -0
  26. package/js/src/abstract/binanceus.d.ts +3 -0
  27. package/js/src/abstract/binanceusdm.d.ts +3 -0
  28. package/js/src/abstract/bingx.d.ts +1 -0
  29. package/js/src/base/Exchange.d.ts +7 -6
  30. package/js/src/base/Exchange.js +30 -2
  31. package/js/src/base/types.d.ts +10 -0
  32. package/js/src/binance.d.ts +5 -13
  33. package/js/src/binance.js +21 -10
  34. package/js/src/bingx.d.ts +2 -16
  35. package/js/src/bingx.js +15 -9
  36. package/js/src/bitget.d.ts +2 -16
  37. package/js/src/bitget.js +2 -2
  38. package/js/src/bitmart.d.ts +2 -16
  39. package/js/src/bitmart.js +2 -2
  40. package/js/src/bybit.d.ts +5 -19
  41. package/js/src/bybit.js +2 -2
  42. package/js/src/coinex.js +3 -3
  43. package/js/src/coinspot.d.ts +1 -0
  44. package/js/src/coinspot.js +103 -8
  45. package/js/src/delta.d.ts +2 -20
  46. package/js/src/delta.js +2 -2
  47. package/js/src/deribit.js +1 -1
  48. package/js/src/gate.d.ts +2 -2
  49. package/js/src/huobi.d.ts +3 -12
  50. package/js/src/huobi.js +5 -6
  51. package/js/src/okx.d.ts +3 -21
  52. package/js/src/okx.js +3 -3
  53. package/js/src/pro/binance.js +3 -9
  54. package/js/src/pro/phemex.js +2 -2
  55. package/js/src/whitebit.js +14 -11
  56. package/package.json +2 -2
@@ -282,13 +282,14 @@ class whitebit extends whitebit$1 {
282
282
  // "stockPrec": "3", // Stock currency precision
283
283
  // "moneyPrec": "2", // Precision of money currency
284
284
  // "feePrec": "4", // Fee precision
285
- // "makerFee": "0.001", // Default maker fee ratio
286
- // "takerFee": "0.001", // Default taker fee ratio
285
+ // "makerFee": "0.1", // Default maker fee ratio
286
+ // "takerFee": "0.1", // Default taker fee ratio
287
287
  // "minAmount": "0.001", // Minimal amount of stock to trade
288
288
  // "minTotal": "0.001", // Minimal amount of money to trade
289
289
  // "tradesEnabled": true, // Is trading enabled
290
290
  // "isCollateral": true, // Is margin trading enabled
291
- // "type": "spot" // Market type. Possible values: "spot", "futures"
291
+ // "type": "spot", // Market type. Possible values: "spot", "futures"
292
+ // "maxTotal": "1000000000" // Maximum total(amount * price) of money to trade
292
293
  // },
293
294
  // {
294
295
  // ...
@@ -330,6 +331,10 @@ class whitebit extends whitebit$1 {
330
331
  else {
331
332
  type = 'spot';
332
333
  }
334
+ const takerFeeRate = this.safeString(market, 'takerFee');
335
+ const taker = Precise["default"].stringDiv(takerFeeRate, '100');
336
+ const makerFeeRate = this.safeString(market, 'makerFee');
337
+ const maker = Precise["default"].stringDiv(makerFeeRate, '100');
333
338
  const entry = {
334
339
  'id': id,
335
340
  'symbol': symbol,
@@ -349,8 +354,8 @@ class whitebit extends whitebit$1 {
349
354
  'contract': contract,
350
355
  'linear': linear,
351
356
  'inverse': inverse,
352
- 'taker': this.safeNumber(market, 'makerFee'),
353
- 'maker': this.safeNumber(market, 'takerFee'),
357
+ 'taker': this.parseNumber(taker),
358
+ 'maker': this.parseNumber(maker),
354
359
  'contractSize': contractSize,
355
360
  'expiry': undefined,
356
361
  'expiryDatetime': undefined,
@@ -375,7 +380,7 @@ class whitebit extends whitebit$1 {
375
380
  },
376
381
  'cost': {
377
382
  'min': this.safeNumber(market, 'minTotal'),
378
- 'max': undefined,
383
+ 'max': this.safeNumber(market, 'maxTotal'),
379
384
  },
380
385
  },
381
386
  'info': market,
@@ -819,6 +824,7 @@ class whitebit extends whitebit$1 {
819
824
  /**
820
825
  * @method
821
826
  * @name whitebit#fetchOrderBook
827
+ * @see https://whitebit-exchange.github.io/api-docs/public/http-v4/#orderbook
822
828
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
823
829
  * @param {string} symbol unified symbol of the market to fetch the order book for
824
830
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -831,7 +837,7 @@ class whitebit extends whitebit$1 {
831
837
  'market': market['id'],
832
838
  };
833
839
  if (limit !== undefined) {
834
- request['depth'] = limit; // default = 50, maximum = 100
840
+ request['limit'] = limit; // default = 100, maximum = 100
835
841
  }
836
842
  const response = await this.v4PublicGetOrderbookMarket(this.extend(request, params));
837
843
  //
@@ -853,7 +859,7 @@ class whitebit extends whitebit$1 {
853
859
  // ]
854
860
  // }
855
861
  //
856
- const timestamp = this.parseToInt(Precise["default"].stringMul(this.safeString(response, 'timestamp'), '1000'));
862
+ const timestamp = this.safeIntegerProduct(response, 'timestamp', 1000);
857
863
  return this.parseOrderBook(response, symbol, timestamp);
858
864
  }
859
865
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -1065,10 +1071,7 @@ class whitebit extends whitebit$1 {
1065
1071
  }
1066
1072
  limit = Math.min(limit, maxLimit);
1067
1073
  const start = this.parseToInt(since / 1000);
1068
- const duration = this.parseTimeframe(timeframe);
1069
- const end = this.sum(start, duration * limit);
1070
1074
  request['start'] = start;
1071
- request['end'] = end;
1072
1075
  }
1073
1076
  if (limit !== undefined) {
1074
1077
  request['limit'] = Math.min(limit, 1440);
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.9";
7
+ declare const version = "4.1.10";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.10';
41
+ const version = '4.1.11';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -54,6 +54,7 @@ interface Exchange {
54
54
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
55
55
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;
56
56
  sapiGetLoanVipRequestData(params?: {}): Promise<implicitReturnType>;
57
+ sapiGetLoanVipRequestInterestRate(params?: {}): Promise<implicitReturnType>;
57
58
  sapiGetLoanIncome(params?: {}): Promise<implicitReturnType>;
58
59
  sapiGetLoanOngoingOrders(params?: {}): Promise<implicitReturnType>;
59
60
  sapiGetLoanLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
@@ -479,6 +480,8 @@ interface Exchange {
479
480
  fapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
480
481
  fapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
481
482
  fapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
483
+ fapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
484
+ fapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
482
485
  fapiPrivateGetOrderAsyn(params?: {}): Promise<implicitReturnType>;
483
486
  fapiPrivateGetOrderAsynId(params?: {}): Promise<implicitReturnType>;
484
487
  fapiPrivateGetTradeAsyn(params?: {}): Promise<implicitReturnType>;
@@ -54,6 +54,7 @@ interface binance {
54
54
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
55
55
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;
56
56
  sapiGetLoanVipRequestData(params?: {}): Promise<implicitReturnType>;
57
+ sapiGetLoanVipRequestInterestRate(params?: {}): Promise<implicitReturnType>;
57
58
  sapiGetLoanIncome(params?: {}): Promise<implicitReturnType>;
58
59
  sapiGetLoanOngoingOrders(params?: {}): Promise<implicitReturnType>;
59
60
  sapiGetLoanLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
@@ -479,6 +480,8 @@ interface binance {
479
480
  fapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
480
481
  fapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
481
482
  fapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
483
+ fapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
484
+ fapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
482
485
  fapiPrivateGetOrderAsyn(params?: {}): Promise<implicitReturnType>;
483
486
  fapiPrivateGetOrderAsynId(params?: {}): Promise<implicitReturnType>;
484
487
  fapiPrivateGetTradeAsyn(params?: {}): Promise<implicitReturnType>;
@@ -54,6 +54,7 @@ interface binance {
54
54
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
55
55
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;
56
56
  sapiGetLoanVipRequestData(params?: {}): Promise<implicitReturnType>;
57
+ sapiGetLoanVipRequestInterestRate(params?: {}): Promise<implicitReturnType>;
57
58
  sapiGetLoanIncome(params?: {}): Promise<implicitReturnType>;
58
59
  sapiGetLoanOngoingOrders(params?: {}): Promise<implicitReturnType>;
59
60
  sapiGetLoanLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
@@ -479,6 +480,8 @@ interface binance {
479
480
  fapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
480
481
  fapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
481
482
  fapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
483
+ fapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
484
+ fapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
482
485
  fapiPrivateGetOrderAsyn(params?: {}): Promise<implicitReturnType>;
483
486
  fapiPrivateGetOrderAsynId(params?: {}): Promise<implicitReturnType>;
484
487
  fapiPrivateGetTradeAsyn(params?: {}): Promise<implicitReturnType>;
@@ -54,6 +54,7 @@ interface binance {
54
54
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
55
55
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;
56
56
  sapiGetLoanVipRequestData(params?: {}): Promise<implicitReturnType>;
57
+ sapiGetLoanVipRequestInterestRate(params?: {}): Promise<implicitReturnType>;
57
58
  sapiGetLoanIncome(params?: {}): Promise<implicitReturnType>;
58
59
  sapiGetLoanOngoingOrders(params?: {}): Promise<implicitReturnType>;
59
60
  sapiGetLoanLtvAdjustmentHistory(params?: {}): Promise<implicitReturnType>;
@@ -479,6 +480,8 @@ interface binance {
479
480
  fapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
480
481
  fapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
481
482
  fapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
483
+ fapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
484
+ fapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
482
485
  fapiPrivateGetOrderAsyn(params?: {}): Promise<implicitReturnType>;
483
486
  fapiPrivateGetOrderAsynId(params?: {}): Promise<implicitReturnType>;
484
487
  fapiPrivateGetTradeAsyn(params?: {}): Promise<implicitReturnType>;
@@ -53,6 +53,7 @@ interface Exchange {
53
53
  swapV2PrivateDeleteTradeOrder(params?: {}): Promise<implicitReturnType>;
54
54
  swapV2PrivateDeleteTradeBatchOrders(params?: {}): Promise<implicitReturnType>;
55
55
  swapV2PrivateDeleteTradeAllOpenOrders(params?: {}): Promise<implicitReturnType>;
56
+ swapV3PublicGetQuoteKlines(params?: {}): Promise<implicitReturnType>;
56
57
  contractV1PrivateGetAllPosition(params?: {}): Promise<implicitReturnType>;
57
58
  contractV1PrivateGetAllOrders(params?: {}): Promise<implicitReturnType>;
58
59
  contractV1PrivateGetBalance(params?: {}): Promise<implicitReturnType>;
@@ -4,7 +4,7 @@ ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotA
4
4
  import WsClient from './ws/WsClient.js';
5
5
  import { Future } from './ws/Future.js';
6
6
  import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
7
- import { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory } from './types.js';
7
+ import { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory, OpenInterest } from './types.js';
8
8
  export { Market, Trade, Fee, Position, Ticker } from './types.js';
9
9
  /**
10
10
  * @class Exchange
@@ -622,7 +622,7 @@ export default class Exchange {
622
622
  convertOHLCVToTradingView(ohlcvs: any, timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): {};
623
623
  fetchWebEndpoint(method: any, endpointMethod: any, returnAsJson: any, startRegex?: any, endRegex?: any): Promise<any>;
624
624
  marketIds(symbols: any): any;
625
- marketSymbols(symbols: any, type?: string, allowEmpty?: boolean): any;
625
+ marketSymbols(symbols: any, type?: string, allowEmpty?: boolean, sameTypeOnly?: boolean, sameSubTypeOnly?: boolean): any;
626
626
  marketCodes(codes: any): any;
627
627
  parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType): any[];
628
628
  fetchL2OrderBook(symbol: string, limit?: Int, params?: {}): Promise<any>;
@@ -636,7 +636,7 @@ export default class Exchange {
636
636
  selectNetworkIdFromRawNetworks(currencyCode: any, networkCode: any, indexedNetworkEntries: any): any;
637
637
  selectNetworkKeyFromNetworks(currencyCode: any, networkCode: any, indexedNetworkEntries: any, isIndexedByUnifiedNetworkCode?: boolean): any;
638
638
  safeNumber2(dictionary: any, key1: any, key2: any, d?: any): number;
639
- parseOrderBook(orderbook: object, symbol: string, timestamp?: number, bidsKey?: string, asksKey?: string, priceKey?: IndexType, amountKey?: IndexType): OrderBook;
639
+ parseOrderBook(orderbook: object, symbol: string, timestamp?: Int, bidsKey?: string, asksKey?: string, priceKey?: IndexType, amountKey?: IndexType): OrderBook;
640
640
  parseOHLCVs(ohlcvs: object[], market?: any, timeframe?: string, since?: Int, limit?: Int): OHLCV[];
641
641
  parseLeverageTiers(response: any, symbols?: string[], marketIdKey?: any): {};
642
642
  loadTradingLimits(symbols?: string[], reload?: boolean, params?: {}): Promise<Dictionary<any>>;
@@ -730,7 +730,7 @@ export default class Exchange {
730
730
  fetchDepositsWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
731
731
  fetchDeposits(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
732
732
  fetchWithdrawals(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
733
- fetchOpenInterest(symbol: string, params?: {}): Promise<any>;
733
+ fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
734
734
  fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
735
735
  parseLastPrice(price: any, market?: any): any;
736
736
  fetchDepositAddress(code: string, params?: {}): Promise<any>;
@@ -782,8 +782,8 @@ export default class Exchange {
782
782
  fetchLastPrices(symbols?: string[], params?: {}): Promise<void>;
783
783
  fetchTradingFees(params?: {}): Promise<any>;
784
784
  fetchTradingFee(symbol: string, params?: {}): Promise<any>;
785
- parseOpenInterest(interest: any, market?: any): any;
786
- parseOpenInterests(response: any, market?: any, since?: Int, limit?: Int): any;
785
+ parseOpenInterest(interest: any, market?: any): OpenInterest;
786
+ parseOpenInterests(response: any, market?: any, since?: Int, limit?: Int): OpenInterest[];
787
787
  fetchFundingRate(symbol: string, params?: {}): Promise<any>;
788
788
  fetchMarkOHLCV(symbol: any, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
789
789
  fetchIndexOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
@@ -815,5 +815,6 @@ export default class Exchange {
815
815
  sortCursorPaginatedResult(result: any): any;
816
816
  removeRepeatedElementsFromArray(input: any): any;
817
817
  handleUntilOption(key: any, request: any, params: any, multiplier?: number): any[];
818
+ safeOpenInterest(interest: any, market?: any): OpenInterest;
818
819
  }
819
820
  export { Exchange, };
@@ -2319,7 +2319,7 @@ export default class Exchange {
2319
2319
  }
2320
2320
  return result;
2321
2321
  }
2322
- marketSymbols(symbols, type = undefined, allowEmpty = true) {
2322
+ marketSymbols(symbols, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
2323
2323
  if (symbols === undefined) {
2324
2324
  if (!allowEmpty) {
2325
2325
  throw new ArgumentsRequired(this.id + ' empty list of symbols is not supported');
@@ -2334,10 +2334,26 @@ export default class Exchange {
2334
2334
  return symbols;
2335
2335
  }
2336
2336
  const result = [];
2337
+ let marketType = undefined;
2338
+ let isLinearSubType = undefined;
2337
2339
  for (let i = 0; i < symbols.length; i++) {
2338
2340
  const market = this.market(symbols[i]);
2341
+ if (sameTypeOnly && (marketType !== undefined)) {
2342
+ if (market['type'] !== marketType) {
2343
+ throw new BadRequest(this.id + ' symbols must be of the same type, either ' + marketType + ' or ' + market['type'] + '.');
2344
+ }
2345
+ }
2346
+ if (sameSubTypeOnly && (isLinearSubType !== undefined)) {
2347
+ if (market['linear'] !== isLinearSubType) {
2348
+ throw new BadRequest(this.id + ' symbols must be of the same subType, either linear or inverse.');
2349
+ }
2350
+ }
2339
2351
  if (type !== undefined && market['type'] !== type) {
2340
- throw new BadRequest(this.id + ' symbols must be of same type ' + type + '. If the type is incorrect you can change it in options or the params of the request');
2352
+ throw new BadRequest(this.id + ' symbols must be of the same type ' + type + '. If the type is incorrect you can change it in options or the params of the request');
2353
+ }
2354
+ marketType = market['type'];
2355
+ if (!market['spot']) {
2356
+ isLinearSubType = market['linear'];
2341
2357
  }
2342
2358
  const symbol = this.safeString(market, 'symbol', symbols[i]);
2343
2359
  result.push(symbol);
@@ -4366,5 +4382,17 @@ export default class Exchange {
4366
4382
  }
4367
4383
  return [request, params];
4368
4384
  }
4385
+ safeOpenInterest(interest, market = undefined) {
4386
+ return this.extend(interest, {
4387
+ 'symbol': this.safeString(market, 'symbol'),
4388
+ 'baseVolume': this.safeNumber(interest, 'baseVolume'),
4389
+ 'quoteVolume': this.safeNumber(interest, 'quoteVolume'),
4390
+ 'openInterestAmount': this.safeNumber(interest, 'openInterestAmount'),
4391
+ 'openInterestValue': this.safeNumber(interest, 'openInterestValue'),
4392
+ 'timestamp': this.safeInteger(interest, 'timestamp'),
4393
+ 'datetime': this.safeString(interest, 'datetime'),
4394
+ 'info': this.safeValue(interest, 'info'),
4395
+ });
4396
+ }
4369
4397
  }
4370
4398
  export { Exchange, };
@@ -208,6 +208,16 @@ export interface FundingRateHistory {
208
208
  timestamp?: number;
209
209
  datetime?: string;
210
210
  }
211
+ export interface OpenInterest {
212
+ symbol: string;
213
+ openInterestAmount?: number;
214
+ openInterestValue?: number;
215
+ baseVolume?: number;
216
+ quoteVolume?: number;
217
+ timestamp?: number;
218
+ datetime?: string;
219
+ info: any;
220
+ }
211
221
  /** [ timestamp, open, high, low, close, volume ] */
212
222
  export declare type OHLCV = [number, number, number, number, number, number];
213
223
  /** [ timestamp, open, high, low, close, volume, count ] */
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory } from './base/types.js';
2
+ import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @extends Exchange
@@ -71,6 +71,7 @@ export default class binance extends Exchange {
71
71
  };
72
72
  };
73
73
  info: any;
74
+ created: number;
74
75
  };
75
76
  parseBalanceHelper(entry: any): import("./base/types.js").Balance;
76
77
  parseBalance(response: any, type?: any, marginMode?: any): Balances;
@@ -493,16 +494,7 @@ export default class binance extends Exchange {
493
494
  datetime: any;
494
495
  info: any;
495
496
  };
496
- fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
497
- fetchOpenInterest(symbol: string, params?: {}): Promise<any>;
498
- parseOpenInterest(interest: any, market?: any): {
499
- symbol: any;
500
- baseVolume: number;
501
- quoteVolume: number;
502
- openInterestAmount: number;
503
- openInterestValue: number;
504
- timestamp: number;
505
- datetime: string;
506
- info: any;
507
- };
497
+ fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
498
+ fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
499
+ parseOpenInterest(interest: any, market?: any): OpenInterest;
508
500
  }
package/js/src/binance.js CHANGED
@@ -25,7 +25,7 @@ export default class binance extends Exchange {
25
25
  'rateLimit': 50,
26
26
  'certified': true,
27
27
  'pro': true,
28
- // new metainfo interface
28
+ // new metainfo2 interface
29
29
  'has': {
30
30
  'CORS': undefined,
31
31
  'spot': true,
@@ -252,6 +252,7 @@ export default class binance extends Exchange {
252
252
  'loan/vip/loanable/data': 40,
253
253
  'loan/vip/collateral/data': 40,
254
254
  'loan/vip/request/data': 2.6668,
255
+ 'loan/vip/request/interestRate': 2.6668,
255
256
  'loan/income': 40.002,
256
257
  'loan/ongoing/orders': 40,
257
258
  'loan/ltv/adjustment/history': 40,
@@ -766,10 +767,12 @@ export default class binance extends Exchange {
766
767
  'adlQuantile': 5,
767
768
  'pmAccountInfo': 5,
768
769
  'orderAmendment': 1,
769
- 'order/asyn': 5,
770
- 'order/asyn/id': 5,
771
- 'trade/asyn': 5,
772
- 'trade/asyn/id': 5,
770
+ 'income/asyn': 1000,
771
+ 'income/asyn/id': 10,
772
+ 'order/asyn': 1000,
773
+ 'order/asyn/id': 10,
774
+ 'trade/asyn': 1000,
775
+ 'trade/asyn/id': 10,
773
776
  },
774
777
  'post': {
775
778
  'batchOrders': 5,
@@ -2388,6 +2391,7 @@ export default class binance extends Exchange {
2388
2391
  },
2389
2392
  },
2390
2393
  'info': market,
2394
+ 'created': this.safeInteger(market, 'onboardDate'), // present in inverse & linear apis
2391
2395
  };
2392
2396
  if ('PRICE_FILTER' in filtersByType) {
2393
2397
  const filter = this.safeValue(filtersByType, 'PRICE_FILTER', {});
@@ -2715,7 +2719,7 @@ export default class binance extends Exchange {
2715
2719
  // "unrealizedProfit":"0.00000000",
2716
2720
  // "positionInitialMargin":"0",
2717
2721
  // "openOrderInitialMargin":"0",
2718
- // "leverage":"20",
2722
+ // "leverage":"21",
2719
2723
  // "isolated":false,
2720
2724
  // "entryPrice":"0.00000",
2721
2725
  // "maxNotional":"5000000",
@@ -3217,6 +3221,7 @@ export default class binance extends Exchange {
3217
3221
  await this.loadMarkets();
3218
3222
  let type = undefined;
3219
3223
  let market = undefined;
3224
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
3220
3225
  if (symbols !== undefined) {
3221
3226
  const first = this.safeString(symbols, 0);
3222
3227
  market = this.market(first);
@@ -8389,7 +8394,7 @@ export default class binance extends Exchange {
8389
8394
  throw new AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
8390
8395
  }
8391
8396
  }
8392
- else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2')) {
8397
+ else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
8393
8398
  this.checkRequiredCredentials();
8394
8399
  if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
8395
8400
  // inject in implicit API calls
@@ -9144,7 +9149,13 @@ export default class binance extends Exchange {
9144
9149
  // ]
9145
9150
  //
9146
9151
  if (market['option']) {
9147
- return this.parseOpenInterests(response, market);
9152
+ const result = this.parseOpenInterests(response, market);
9153
+ for (let i = 0; i < result.length; i++) {
9154
+ const item = result[i];
9155
+ if (item['symbol'] === symbol) {
9156
+ return item;
9157
+ }
9158
+ }
9148
9159
  }
9149
9160
  else {
9150
9161
  return this.parseOpenInterest(response, market);
@@ -9157,7 +9168,7 @@ export default class binance extends Exchange {
9157
9168
  const value = this.safeNumber2(interest, 'sumOpenInterestValue', 'sumOpenInterestUsd');
9158
9169
  // Inverse returns the number of contracts different from the base or quote volume in this case
9159
9170
  // compared with https://www.binance.com/en/futures/funding-history/quarterly/4
9160
- return {
9171
+ return this.safeOpenInterest({
9161
9172
  'symbol': this.safeSymbol(id, market, undefined, 'contract'),
9162
9173
  'baseVolume': market['inverse'] ? undefined : amount,
9163
9174
  'quoteVolume': value,
@@ -9166,6 +9177,6 @@ export default class binance extends Exchange {
9166
9177
  'timestamp': timestamp,
9167
9178
  'datetime': this.iso8601(timestamp),
9168
9179
  'info': interest,
9169
- };
9180
+ }, market);
9170
9181
  }
9171
9182
  }
package/js/src/bingx.d.ts CHANGED
@@ -103,22 +103,8 @@ export default class bingx extends Exchange {
103
103
  previousFundingDatetime: any;
104
104
  };
105
105
  fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
106
- fetchOpenInterest(symbol: string, params?: {}): Promise<{
107
- symbol: any;
108
- openInterestAmount: any;
109
- openInterestValue: number;
110
- timestamp: number;
111
- datetime: string;
112
- info: any;
113
- }>;
114
- parseOpenInterest(interest: any, market?: any): {
115
- symbol: any;
116
- openInterestAmount: any;
117
- openInterestValue: number;
118
- timestamp: number;
119
- datetime: string;
120
- info: any;
121
- };
106
+ fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
107
+ parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
122
108
  fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
123
109
  fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
124
110
  parseTicker(ticker: any, market?: any): import("./base/types.js").Ticker;
package/js/src/bingx.js CHANGED
@@ -176,6 +176,13 @@ export default class bingx extends Exchange {
176
176
  },
177
177
  },
178
178
  },
179
+ 'v3': {
180
+ 'public': {
181
+ 'get': {
182
+ 'quote/klines': 1,
183
+ },
184
+ },
185
+ },
179
186
  },
180
187
  'contract': {
181
188
  'v1': {
@@ -633,12 +640,12 @@ export default class bingx extends Exchange {
633
640
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
634
641
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
635
642
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
643
+ * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
636
644
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
637
645
  * @param {string} timeframe the length of time each candle represents
638
646
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
639
647
  * @param {int} [limit] the maximum amount of candles to fetch
640
648
  * @param {object} [params] extra parameters specific to the bingx api endpoint
641
- * @param {string} [params.price] "mark" or "index" for mark price and index price candles
642
649
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
643
650
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
644
651
  * @returns {[[int]]} A list of candles ordered as timestamp, open, high, low, close, volume
@@ -660,20 +667,17 @@ export default class bingx extends Exchange {
660
667
  if (limit !== undefined) {
661
668
  request['limit'] = limit;
662
669
  }
663
- else {
664
- request['limit'] = 50;
665
- }
666
- const until = this.safeInteger2(params, 'until', 'startTime');
670
+ const until = this.safeInteger2(params, 'until', 'endTime');
667
671
  if (until !== undefined) {
668
672
  params = this.omit(params, ['until']);
669
- request['startTime'] = until;
673
+ request['endTime'] = until;
670
674
  }
671
675
  let response = undefined;
672
676
  if (market['spot']) {
673
677
  response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
674
678
  }
675
679
  else {
676
- response = await this.swapV2PublicGetQuoteKlines(this.extend(request, params));
680
+ response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
677
681
  }
678
682
  //
679
683
  // {
@@ -1174,14 +1178,16 @@ export default class bingx extends Exchange {
1174
1178
  const id = this.safeString(interest, 'symbol');
1175
1179
  const symbol = this.safeSymbol(id, market, '-', 'swap');
1176
1180
  const openInterest = this.safeNumber(interest, 'openInterest');
1177
- return {
1181
+ return this.safeOpenInterest({
1178
1182
  'symbol': symbol,
1183
+ 'baseVolume': undefined,
1184
+ 'quoteVolume': undefined,
1179
1185
  'openInterestAmount': undefined,
1180
1186
  'openInterestValue': openInterest,
1181
1187
  'timestamp': timestamp,
1182
1188
  'datetime': this.iso8601(timestamp),
1183
1189
  'info': interest,
1184
- };
1190
+ }, market);
1185
1191
  }
1186
1192
  async fetchTicker(symbol, params = {}) {
1187
1193
  /**
@@ -247,14 +247,7 @@ export default class bitget extends Exchange {
247
247
  setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
248
248
  setMarginMode(marginMode: any, symbol?: string, params?: {}): Promise<any>;
249
249
  setPositionMode(hedged: any, symbol?: string, params?: {}): Promise<any>;
250
- fetchOpenInterest(symbol: string, params?: {}): Promise<{
251
- symbol: any;
252
- openInterestAmount: number;
253
- openInterestValue: any;
254
- timestamp: number;
255
- datetime: string;
256
- info: any;
257
- }>;
250
+ fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
258
251
  fetchTransfers(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
259
252
  transfer(code: string, amount: any, fromAccount: any, toAccount: any, params?: {}): Promise<{
260
253
  info: any;
@@ -292,14 +285,7 @@ export default class bitget extends Exchange {
292
285
  };
293
286
  fetchDepositWithdrawFees(codes?: string[], params?: {}): Promise<any>;
294
287
  parseTransferStatus(status: any): string;
295
- parseOpenInterest(interest: any, market?: any): {
296
- symbol: any;
297
- openInterestAmount: number;
298
- openInterestValue: any;
299
- timestamp: number;
300
- datetime: string;
301
- info: any;
302
- };
288
+ parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
303
289
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
304
290
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
305
291
  url: string;
package/js/src/bitget.js CHANGED
@@ -5176,14 +5176,14 @@ export default class bitget extends Exchange {
5176
5176
  const id = this.safeString(interest, 'symbol');
5177
5177
  const symbol = this.safeSymbol(id, market);
5178
5178
  const amount = this.safeNumber(interest, 'amount');
5179
- return {
5179
+ return this.safeOpenInterest({
5180
5180
  'symbol': symbol,
5181
5181
  'openInterestAmount': amount,
5182
5182
  'openInterestValue': undefined,
5183
5183
  'timestamp': timestamp,
5184
5184
  'datetime': this.iso8601(timestamp),
5185
5185
  'info': interest,
5186
- };
5186
+ }, market);
5187
5187
  }
5188
5188
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
5189
5189
  if (!response) {
@@ -212,22 +212,8 @@ export default class bitmart extends Exchange {
212
212
  datetime: string;
213
213
  info: any;
214
214
  };
215
- fetchOpenInterest(symbol: string, params?: {}): Promise<{
216
- symbol: any;
217
- openInterestAmount: number;
218
- openInterestValue: number;
219
- timestamp: number;
220
- datetime: string;
221
- info: any;
222
- }>;
223
- parseOpenInterest(interest: any, market?: any): {
224
- symbol: any;
225
- openInterestAmount: number;
226
- openInterestValue: number;
227
- timestamp: number;
228
- datetime: string;
229
- info: any;
230
- };
215
+ fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
216
+ parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
231
217
  setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
232
218
  fetchFundingRate(symbol: string, params?: {}): Promise<{
233
219
  info: any;
package/js/src/bitmart.js CHANGED
@@ -3660,14 +3660,14 @@ export default class bitmart extends Exchange {
3660
3660
  //
3661
3661
  const timestamp = this.safeInteger(interest, 'timestamp');
3662
3662
  const id = this.safeString(interest, 'symbol');
3663
- return {
3663
+ return this.safeOpenInterest({
3664
3664
  'symbol': this.safeSymbol(id, market),
3665
3665
  'openInterestAmount': this.safeNumber(interest, 'open_interest'),
3666
3666
  'openInterestValue': this.safeNumber(interest, 'open_interest_value'),
3667
3667
  'timestamp': timestamp,
3668
3668
  'datetime': this.iso8601(timestamp),
3669
3669
  'info': interest,
3670
- };
3670
+ }, market);
3671
3671
  }
3672
3672
  async setLeverage(leverage, symbol = undefined, params = {}) {
3673
3673
  /**