ccxt 4.3.19 → 4.3.21

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/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +3 -0
  4. package/dist/cjs/src/base/functions/platform.js +3 -1
  5. package/dist/cjs/src/base/functions.js +1 -0
  6. package/dist/cjs/src/binance.js +10 -1
  7. package/dist/cjs/src/bitget.js +3 -0
  8. package/dist/cjs/src/bitmex.js +1 -0
  9. package/dist/cjs/src/bybit.js +38 -9
  10. package/dist/cjs/src/coinex.js +180 -201
  11. package/dist/cjs/src/hyperliquid.js +24 -2
  12. package/dist/cjs/src/okx.js +3 -0
  13. package/dist/cjs/src/phemex.js +17 -6
  14. package/dist/cjs/src/pro/htx.js +12 -7
  15. package/dist/cjs/src/pro/kucoinfutures.js +92 -0
  16. package/dist/cjs/src/pro/woo.js +52 -24
  17. package/js/ccxt.d.ts +1 -1
  18. package/js/ccxt.js +1 -1
  19. package/js/src/abstract/binance.d.ts +1 -0
  20. package/js/src/abstract/binancecoinm.d.ts +1 -0
  21. package/js/src/abstract/binanceus.d.ts +1 -0
  22. package/js/src/abstract/binanceusdm.d.ts +1 -0
  23. package/js/src/abstract/bitget.d.ts +3 -0
  24. package/js/src/abstract/okx.d.ts +3 -0
  25. package/js/src/ascendex.d.ts +1 -1
  26. package/js/src/base/Exchange.d.ts +1 -1
  27. package/js/src/base/Exchange.js +3 -0
  28. package/js/src/base/functions/platform.d.ts +2 -1
  29. package/js/src/base/functions/platform.js +3 -2
  30. package/js/src/binance.d.ts +1 -1
  31. package/js/src/binance.js +10 -1
  32. package/js/src/bingx.d.ts +1 -1
  33. package/js/src/bitget.d.ts +1 -1
  34. package/js/src/bitget.js +3 -0
  35. package/js/src/bitmex.js +1 -0
  36. package/js/src/bybit.d.ts +1 -0
  37. package/js/src/bybit.js +38 -9
  38. package/js/src/coinex.d.ts +2 -2
  39. package/js/src/coinex.js +180 -201
  40. package/js/src/delta.d.ts +1 -1
  41. package/js/src/digifinex.d.ts +1 -1
  42. package/js/src/exmo.d.ts +1 -1
  43. package/js/src/gate.d.ts +1 -1
  44. package/js/src/hitbtc.d.ts +1 -1
  45. package/js/src/hyperliquid.d.ts +1 -1
  46. package/js/src/hyperliquid.js +24 -2
  47. package/js/src/okx.d.ts +1 -1
  48. package/js/src/okx.js +3 -0
  49. package/js/src/phemex.d.ts +1 -1
  50. package/js/src/phemex.js +17 -6
  51. package/js/src/pro/htx.js +12 -7
  52. package/js/src/pro/kucoinfutures.d.ts +3 -1
  53. package/js/src/pro/kucoinfutures.js +93 -1
  54. package/js/src/pro/woo.d.ts +2 -1
  55. package/js/src/pro/woo.js +52 -24
  56. package/package.json +1 -1
@@ -2432,12 +2432,14 @@ class phemex extends phemex$1 {
2432
2432
  * @name phemex#createOrder
2433
2433
  * @description create a trade order
2434
2434
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#place-order
2435
+ * @see https://phemex-docs.github.io/#place-order-http-put-prefered-3
2435
2436
  * @param {string} symbol unified symbol of the market to create an order in
2436
2437
  * @param {string} type 'market' or 'limit'
2437
2438
  * @param {string} side 'buy' or 'sell'
2438
2439
  * @param {float} amount how much of currency you want to trade in units of base currency
2439
2440
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2440
2441
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2442
+ * @param {float} [params.trigger] trigger price for conditional orders
2441
2443
  * @param {object} [params.takeProfit] *swap only* *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
2442
2444
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
2443
2445
  * @param {object} [params.stopLoss] *swap only* *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
@@ -2448,7 +2450,7 @@ class phemex extends phemex$1 {
2448
2450
  const market = this.market(symbol);
2449
2451
  const requestSide = this.capitalize(side);
2450
2452
  type = this.capitalize(type);
2451
- const reduceOnly = this.safeValue(params, 'reduceOnly');
2453
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
2452
2454
  const request = {
2453
2455
  // common
2454
2456
  'symbol': market['id'],
@@ -2492,13 +2494,13 @@ class phemex extends phemex$1 {
2492
2494
  request['clOrdID'] = clientOrderId;
2493
2495
  params = this.omit(params, ['clOrdID', 'clientOrderId']);
2494
2496
  }
2495
- const stopPrice = this.safeStringN(params, ['stopPx', 'stopPrice', 'triggerPrice']);
2496
- if (stopPrice !== undefined) {
2497
+ const triggerPrice = this.safeStringN(params, ['stopPx', 'stopPrice', 'triggerPrice']);
2498
+ if (triggerPrice !== undefined) {
2497
2499
  if (market['settle'] === 'USDT') {
2498
- request['stopPxRp'] = this.priceToPrecision(symbol, stopPrice);
2500
+ request['stopPxRp'] = this.priceToPrecision(symbol, triggerPrice);
2499
2501
  }
2500
2502
  else {
2501
- request['stopPxEp'] = this.toEp(stopPrice, market);
2503
+ request['stopPxEp'] = this.toEp(triggerPrice, market);
2502
2504
  }
2503
2505
  }
2504
2506
  params = this.omit(params, ['stopPx', 'stopPrice', 'stopLoss', 'takeProfit', 'triggerPrice']);
@@ -2509,6 +2511,15 @@ class phemex extends phemex$1 {
2509
2511
  qtyType = 'ByQuote';
2510
2512
  }
2511
2513
  }
2514
+ if (triggerPrice !== undefined) {
2515
+ if (type === 'Limit') {
2516
+ request['ordType'] = 'StopLimit';
2517
+ }
2518
+ else if (type === 'Market') {
2519
+ request['ordType'] = 'Stop';
2520
+ }
2521
+ request['trigger'] = 'ByLastPrice';
2522
+ }
2512
2523
  request['qtyType'] = qtyType;
2513
2524
  if (qtyType === 'ByQuote') {
2514
2525
  let cost = this.safeNumber(params, 'cost');
@@ -2549,7 +2560,7 @@ class phemex extends phemex$1 {
2549
2560
  else {
2550
2561
  request['orderQty'] = this.parseToInt(amount);
2551
2562
  }
2552
- if (stopPrice !== undefined) {
2563
+ if (triggerPrice !== undefined) {
2553
2564
  const triggerType = this.safeString(params, 'triggerType', 'ByMarkPrice');
2554
2565
  request['triggerType'] = triggerType;
2555
2566
  }
@@ -1897,7 +1897,7 @@ class htx extends htx$1 {
1897
1897
  // "data": { "user-id": "35930539" }
1898
1898
  // }
1899
1899
  //
1900
- const promise = client.futures['authenticated'];
1900
+ const promise = client.futures['auth'];
1901
1901
  promise.resolve(message);
1902
1902
  }
1903
1903
  handleErrorMessage(client, message) {
@@ -1925,6 +1925,12 @@ class htx extends htx$1 {
1925
1925
  // 'err-msg': "Non - single account user is not available, please check through the cross and isolated account asset interface",
1926
1926
  // "ts": 1698419490189
1927
1927
  // }
1928
+ // {
1929
+ // "action":"req",
1930
+ // "code":2002,
1931
+ // "ch":"auth",
1932
+ // "message":"auth.fail"
1933
+ // }
1928
1934
  //
1929
1935
  const status = this.safeString(message, 'status');
1930
1936
  if (status === 'error') {
@@ -1935,6 +1941,7 @@ class htx extends htx$1 {
1935
1941
  const errorCode = this.safeString(message, 'err-code');
1936
1942
  try {
1937
1943
  this.throwExactlyMatchedException(this.exceptions['ws']['exact'], errorCode, this.json(message));
1944
+ throw new errors.ExchangeError(this.json(message));
1938
1945
  }
1939
1946
  catch (e) {
1940
1947
  const messageHash = this.safeString(subscription, 'messageHash');
@@ -1947,11 +1954,12 @@ class htx extends htx$1 {
1947
1954
  }
1948
1955
  return false;
1949
1956
  }
1950
- const code = this.safeInteger2(message, 'code', 'err-code');
1951
- if (code !== undefined && ((code !== 200) && (code !== 0))) {
1957
+ const code = this.safeString2(message, 'code', 'err-code');
1958
+ if (code !== undefined && ((code !== '200') && (code !== '0'))) {
1952
1959
  const feedback = this.id + ' ' + this.json(message);
1953
1960
  try {
1954
1961
  this.throwExactlyMatchedException(this.exceptions['ws']['exact'], code, feedback);
1962
+ throw new errors.ExchangeError(feedback);
1955
1963
  }
1956
1964
  catch (e) {
1957
1965
  if (e instanceof errors.AuthenticationError) {
@@ -2305,9 +2313,6 @@ class htx extends htx$1 {
2305
2313
  'url': url,
2306
2314
  'hostname': hostname,
2307
2315
  };
2308
- if (type === 'spot') {
2309
- this.options['ws']['gunzip'] = false;
2310
- }
2311
2316
  await this.authenticate(authParams);
2312
2317
  return await this.watch(url, messageHash, this.extend(request, params), channel, extendedSubsription);
2313
2318
  }
@@ -2319,7 +2324,7 @@ class htx extends htx$1 {
2319
2324
  throw new errors.ArgumentsRequired(this.id + ' authenticate requires a url, hostname and type argument');
2320
2325
  }
2321
2326
  this.checkRequiredCredentials();
2322
- const messageHash = 'authenticated';
2327
+ const messageHash = 'auth';
2323
2328
  const relativePath = url.replace('wss://' + hostname, '');
2324
2329
  const client = this.client(url);
2325
2330
  const future = client.future(messageHash);
@@ -15,6 +15,7 @@ class kucoinfutures extends kucoinfutures$1 {
15
15
  'watchTickers': true,
16
16
  'watchBidsAsks': true,
17
17
  'watchTrades': true,
18
+ 'watchOHLCV': true,
18
19
  'watchOrderBook': true,
19
20
  'watchOrders': true,
20
21
  'watchBalance': true,
@@ -25,6 +26,21 @@ class kucoinfutures extends kucoinfutures$1 {
25
26
  'watchOrderBookForSymbols': true,
26
27
  },
27
28
  'options': {
29
+ 'timeframes': {
30
+ '1m': '1min',
31
+ '3m': '1min',
32
+ '5m': '5min',
33
+ '15m': '15min',
34
+ '30m': '30min',
35
+ '1h': '1hour',
36
+ '2h': '2hour',
37
+ '4h': '4hour',
38
+ '8h': '8hour',
39
+ '12h': '12hour',
40
+ '1d': '1day',
41
+ '1w': '1week',
42
+ '1M': '1month',
43
+ },
28
44
  'accountsByType': {
29
45
  'swap': 'future',
30
46
  'cross': 'margin',
@@ -567,6 +583,81 @@ class kucoinfutures extends kucoinfutures$1 {
567
583
  client.resolve(trades, messageHash);
568
584
  return message;
569
585
  }
586
+ async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
587
+ /**
588
+ * @method
589
+ * @name kucoinfutures#watchOHLCV
590
+ * @see https://www.kucoin.com/docs/websocket/futures-trading/public-channels/klines
591
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
592
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
593
+ * @param {string} timeframe the length of time each candle represents
594
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
595
+ * @param {int} [limit] the maximum amount of candles to fetch
596
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
597
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
598
+ */
599
+ await this.loadMarkets();
600
+ symbol = this.symbol(symbol);
601
+ const url = await this.negotiate(false);
602
+ const marketId = this.marketId(symbol);
603
+ const timeframes = this.safeDict(this.options, 'timeframes');
604
+ const timeframeId = this.safeString(timeframes, timeframe, timeframe);
605
+ const topic = '/contractMarket/limitCandle:' + marketId + '_' + timeframeId;
606
+ const messageHash = 'ohlcv::' + symbol + '_' + timeframe;
607
+ const ohlcv = await this.subscribe(url, messageHash, topic, undefined, params);
608
+ if (this.newUpdates) {
609
+ limit = ohlcv.getLimit(symbol, limit);
610
+ }
611
+ return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
612
+ }
613
+ handleOHLCV(client, message) {
614
+ //
615
+ // {
616
+ // "topic":"/contractMarket/limitCandle:LTCUSDTM_1min",
617
+ // "type":"message",
618
+ // "data":{
619
+ // "symbol":"LTCUSDTM",
620
+ // "candles":[
621
+ // "1715470980",
622
+ // "81.38",
623
+ // "81.38",
624
+ // "81.38",
625
+ // "81.38",
626
+ // "61.0",
627
+ // "61"
628
+ // ],
629
+ // "time":1715470994801
630
+ // },
631
+ // "subject":"candle.stick"
632
+ // }
633
+ //
634
+ const topic = this.safeString(message, 'topic');
635
+ const parts = topic.split('_');
636
+ const timeframeId = this.safeString(parts, 1);
637
+ const data = this.safeDict(message, 'data');
638
+ const timeframes = this.safeDict(this.options, 'timeframes');
639
+ const timeframe = this.findTimeframe(timeframeId, timeframes);
640
+ const marketId = this.safeString(data, 'symbol');
641
+ const symbol = this.safeSymbol(marketId);
642
+ const messageHash = 'ohlcv::' + symbol + '_' + timeframe;
643
+ const ohlcv = this.safeList(data, 'candles');
644
+ const parsed = [
645
+ this.safeInteger(ohlcv, 0),
646
+ this.safeNumber(ohlcv, 1),
647
+ this.safeNumber(ohlcv, 2),
648
+ this.safeNumber(ohlcv, 3),
649
+ this.safeNumber(ohlcv, 4),
650
+ this.safeNumber(ohlcv, 6), // Note value 5 is incorrect and will be fixed in subsequent versions of kucoin
651
+ ];
652
+ this.ohlcvs[symbol] = this.safeDict(this.ohlcvs, symbol, {});
653
+ if (!(timeframe in this.ohlcvs[symbol])) {
654
+ const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
655
+ this.ohlcvs[symbol][timeframe] = new Cache.ArrayCacheByTimestamp(limit);
656
+ }
657
+ const stored = this.ohlcvs[symbol][timeframe];
658
+ stored.append(parsed);
659
+ client.resolve(stored, messageHash);
660
+ }
570
661
  async watchOrderBook(symbol, limit = undefined, params = {}) {
571
662
  /**
572
663
  * @method
@@ -983,6 +1074,7 @@ class kucoinfutures extends kucoinfutures$1 {
983
1074
  const methods = {
984
1075
  'level2': this.handleOrderBook,
985
1076
  'ticker': this.handleTicker,
1077
+ 'candle.stick': this.handleOHLCV,
986
1078
  'tickerV2': this.handleBidAsk,
987
1079
  'availableBalance.change': this.handleBalance,
988
1080
  'match': this.handleTrade,
@@ -547,6 +547,16 @@ class woo extends woo$1 {
547
547
  const request = this.extend(subscribe, message);
548
548
  return await this.watch(url, messageHash, request, messageHash, subscribe);
549
549
  }
550
+ async watchPrivateMultiple(messageHashes, message, params = {}) {
551
+ await this.authenticate(params);
552
+ const url = this.urls['api']['ws']['private'] + '/' + this.uid;
553
+ const requestId = this.requestId(url);
554
+ const subscribe = {
555
+ 'id': requestId,
556
+ };
557
+ const request = this.extend(subscribe, message);
558
+ return await this.watchMultiple(url, messageHashes, request, messageHashes, subscribe);
559
+ }
550
560
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
551
561
  /**
552
562
  * @method
@@ -558,10 +568,13 @@ class woo extends woo$1 {
558
568
  * @param {int} [since] the earliest time in ms to fetch orders for
559
569
  * @param {int} [limit] the maximum number of order structures to retrieve
560
570
  * @param {object} [params] extra parameters specific to the exchange API endpoint
571
+ * @param {bool} [params.trigger] true if trigger order
561
572
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
562
573
  */
563
574
  await this.loadMarkets();
564
- const topic = 'executionreport';
575
+ const trigger = this.safeBool2(params, 'stop', 'trigger', false);
576
+ const topic = (trigger) ? 'algoexecutionreportv2' : 'executionreport';
577
+ params = this.omit(params, ['stop', 'trigger']);
565
578
  let messageHash = topic;
566
579
  if (symbol !== undefined) {
567
580
  const market = this.market(symbol);
@@ -584,15 +597,19 @@ class woo extends woo$1 {
584
597
  * @method
585
598
  * @name woo#watchOrders
586
599
  * @see https://docs.woo.org/#executionreport
600
+ * @see https://docs.woo.org/#algoexecutionreportv2
587
601
  * @description watches information on multiple trades made by the user
588
602
  * @param {string} symbol unified market symbol of the market orders were made in
589
603
  * @param {int} [since] the earliest time in ms to fetch orders for
590
604
  * @param {int} [limit] the maximum number of order structures to retrieve
591
605
  * @param {object} [params] extra parameters specific to the exchange API endpoint
606
+ * @param {bool} [params.trigger] true if trigger order
592
607
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
593
608
  */
594
609
  await this.loadMarkets();
595
- const topic = 'executionreport';
610
+ const trigger = this.safeBool2(params, 'stop', 'trigger', false);
611
+ const topic = (trigger) ? 'algoexecutionreportv2' : 'executionreport';
612
+ params = this.omit(params, ['stop', 'trigger']);
596
613
  let messageHash = 'myTrades';
597
614
  if (symbol !== undefined) {
598
615
  const market = this.market(symbol);
@@ -718,15 +735,29 @@ class woo extends woo$1 {
718
735
  // }
719
736
  // }
720
737
  //
721
- const order = this.safeDict(message, 'data');
722
- const tradeId = this.safeString(order, 'tradeId');
723
- if ((tradeId !== undefined) && (tradeId !== '0')) {
724
- this.handleMyTrade(client, order);
738
+ const topic = this.safeString(message, 'topic');
739
+ const data = this.safeValue(message, 'data');
740
+ if (Array.isArray(data)) {
741
+ // algoexecutionreportv2
742
+ for (let i = 0; i < data.length; i++) {
743
+ const order = data[i];
744
+ const tradeId = this.omitZero(this.safeString(data, 'tradeId'));
745
+ if (tradeId !== undefined) {
746
+ this.handleMyTrade(client, order);
747
+ }
748
+ this.handleOrder(client, order, topic);
749
+ }
750
+ }
751
+ else {
752
+ // executionreport
753
+ const tradeId = this.omitZero(this.safeString(data, 'tradeId'));
754
+ if (tradeId !== undefined) {
755
+ this.handleMyTrade(client, data);
756
+ }
757
+ this.handleOrder(client, data, topic);
725
758
  }
726
- this.handleOrder(client, order);
727
759
  }
728
- handleOrder(client, message) {
729
- const topic = 'executionreport';
760
+ handleOrder(client, message, topic) {
730
761
  const parsed = this.parseWsOrder(message);
731
762
  const symbol = this.safeString(parsed, 'symbol');
732
763
  const orderId = this.safeString(parsed, 'id');
@@ -811,12 +842,17 @@ class woo extends woo$1 {
811
842
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
812
843
  */
813
844
  await this.loadMarkets();
814
- let messageHash = '';
845
+ const messageHashes = [];
815
846
  symbols = this.marketSymbols(symbols);
816
847
  if (!this.isEmpty(symbols)) {
817
- messageHash = '::' + symbols.join(',');
848
+ for (let i = 0; i < symbols.length; i++) {
849
+ const symbol = symbols[i];
850
+ messageHashes.push('positions::' + symbol);
851
+ }
852
+ }
853
+ else {
854
+ messageHashes.push('positions');
818
855
  }
819
- messageHash = 'positions' + messageHash;
820
856
  const url = this.urls['api']['ws']['private'] + '/' + this.uid;
821
857
  const client = this.client(url);
822
858
  this.setPositionsCache(client, symbols);
@@ -830,7 +866,7 @@ class woo extends woo$1 {
830
866
  'event': 'subscribe',
831
867
  'topic': 'position',
832
868
  };
833
- const newPositions = await this.watchPrivate(messageHash, request, params);
869
+ const newPositions = await this.watchPrivateMultiple(messageHashes, request, params);
834
870
  if (this.newUpdates) {
835
871
  return newPositions;
836
872
  }
@@ -906,17 +942,8 @@ class woo extends woo$1 {
906
942
  const position = this.parsePosition(rawPosition, market);
907
943
  newPositions.push(position);
908
944
  cache.append(position);
909
- }
910
- const messageHashes = this.findMessageHashes(client, 'positions::');
911
- for (let i = 0; i < messageHashes.length; i++) {
912
- const messageHash = messageHashes[i];
913
- const parts = messageHash.split('::');
914
- const symbolsString = parts[1];
915
- const symbols = symbolsString.split(',');
916
- const positions = this.filterByArray(newPositions, 'symbol', symbols, false);
917
- if (!this.isEmpty(positions)) {
918
- client.resolve(positions, messageHash);
919
- }
945
+ const messageHash = 'positions::' + market['symbol'];
946
+ client.resolve(position, messageHash);
920
947
  }
921
948
  client.resolve(newPositions, 'positions');
922
949
  }
@@ -1037,6 +1064,7 @@ class woo extends woo$1 {
1037
1064
  'kline': this.handleOHLCV,
1038
1065
  'auth': this.handleAuth,
1039
1066
  'executionreport': this.handleOrderUpdate,
1067
+ 'algoexecutionreportv2': this.handleOrderUpdate,
1040
1068
  'trade': this.handleTrade,
1041
1069
  'balance': this.handleBalance,
1042
1070
  'position': this.handlePositions,
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 type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.18";
7
+ declare const version = "4.3.20";
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, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.19';
41
+ const version = '4.3.21';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -464,6 +464,7 @@ interface Exchange {
464
464
  fapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
465
465
  fapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
466
466
  fapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
467
+ fapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
467
468
  fapiPublicGetFundingRate(params?: {}): Promise<implicitReturnType>;
468
469
  fapiPublicGetFundingInfo(params?: {}): Promise<implicitReturnType>;
469
470
  fapiPublicGetPremiumIndex(params?: {}): Promise<implicitReturnType>;
@@ -464,6 +464,7 @@ interface binance {
464
464
  fapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
465
465
  fapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
466
466
  fapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
467
+ fapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
467
468
  fapiPublicGetFundingRate(params?: {}): Promise<implicitReturnType>;
468
469
  fapiPublicGetFundingInfo(params?: {}): Promise<implicitReturnType>;
469
470
  fapiPublicGetPremiumIndex(params?: {}): Promise<implicitReturnType>;
@@ -516,6 +516,7 @@ interface binance {
516
516
  fapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
517
517
  fapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
518
518
  fapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
519
+ fapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
519
520
  fapiPublicGetFundingRate(params?: {}): Promise<implicitReturnType>;
520
521
  fapiPublicGetFundingInfo(params?: {}): Promise<implicitReturnType>;
521
522
  fapiPublicGetPremiumIndex(params?: {}): Promise<implicitReturnType>;
@@ -464,6 +464,7 @@ interface binance {
464
464
  fapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
465
465
  fapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
466
466
  fapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
467
+ fapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
467
468
  fapiPublicGetFundingRate(params?: {}): Promise<implicitReturnType>;
468
469
  fapiPublicGetFundingInfo(params?: {}): Promise<implicitReturnType>;
469
470
  fapiPublicGetPremiumIndex(params?: {}): Promise<implicitReturnType>;
@@ -100,6 +100,9 @@ interface Exchange {
100
100
  privateSpotGetV2SpotAccountSubaccountAssets(params?: {}): Promise<implicitReturnType>;
101
101
  privateSpotGetV2SpotAccountBills(params?: {}): Promise<implicitReturnType>;
102
102
  privateSpotGetV2SpotAccountTransferRecords(params?: {}): Promise<implicitReturnType>;
103
+ privateSpotGetV2AccountFundingAssets(params?: {}): Promise<implicitReturnType>;
104
+ privateSpotGetV2AccountBotAssets(params?: {}): Promise<implicitReturnType>;
105
+ privateSpotGetV2AccountAllAccountBalance(params?: {}): Promise<implicitReturnType>;
103
106
  privateSpotGetV2SpotWalletDepositAddress(params?: {}): Promise<implicitReturnType>;
104
107
  privateSpotGetV2SpotWalletDepositRecords(params?: {}): Promise<implicitReturnType>;
105
108
  privateSpotGetV2SpotWalletWithdrawalRecords(params?: {}): Promise<implicitReturnType>;
@@ -58,6 +58,9 @@ interface Exchange {
58
58
  publicGetSprdBooks(params?: {}): Promise<implicitReturnType>;
59
59
  publicGetSprdTicker(params?: {}): Promise<implicitReturnType>;
60
60
  publicGetSprdPublicTrades(params?: {}): Promise<implicitReturnType>;
61
+ publicGetMarketSprdTicker(params?: {}): Promise<implicitReturnType>;
62
+ publicGetMarketSprdCandles(params?: {}): Promise<implicitReturnType>;
63
+ publicGetMarketSprdHistoryCandles(params?: {}): Promise<implicitReturnType>;
61
64
  publicGetTradingBotGridAiParam(params?: {}): Promise<implicitReturnType>;
62
65
  publicGetTradingBotGridMinInvestment(params?: {}): Promise<implicitReturnType>;
63
66
  publicGetTradingBotPublicRsiBackTesting(params?: {}): Promise<implicitReturnType>;
@@ -71,7 +71,7 @@ export default class ascendex extends Exchange {
71
71
  };
72
72
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<any>;
73
73
  modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
74
- parseMarginModification(data: any, market?: Market): MarginModification;
74
+ parseMarginModification(data: Dict, market?: Market): MarginModification;
75
75
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
76
76
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
77
77
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
@@ -1091,7 +1091,7 @@ export default class Exchange {
1091
1091
  convertMarketIdExpireDate(date: string): string;
1092
1092
  fetchPositionHistory(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Position>;
1093
1093
  fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
1094
- parseMarginModification(data: any, market?: Market): MarginModification;
1094
+ parseMarginModification(data: Dict, market?: Market): MarginModification;
1095
1095
  parseMarginModifications(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): MarginModification[];
1096
1096
  fetchTransfer(id: string, code?: Str, params?: {}): Promise<TransferEntry>;
1097
1097
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntries>;
@@ -5935,6 +5935,9 @@ export default class Exchange {
5935
5935
  if (method === 'fetchAccounts') {
5936
5936
  response = await this[method](params);
5937
5937
  }
5938
+ else if (method === 'getLeverageTiersPaginated') {
5939
+ response = await this[method](symbol, params);
5940
+ }
5938
5941
  else {
5939
5942
  response = await this[method](symbol, since, maxEntriesPerRequest, params);
5940
5943
  }
@@ -2,5 +2,6 @@ declare const isBrowser: boolean;
2
2
  declare const isElectron: boolean;
3
3
  declare const isWebWorker: boolean;
4
4
  declare const isWindows: boolean;
5
+ declare const isDeno: boolean;
5
6
  declare const isNode: boolean;
6
- export { isBrowser, isElectron, isWebWorker, isNode, isWindows, };
7
+ export { isBrowser, isElectron, isWebWorker, isNode, isDeno, isWindows, };
@@ -21,6 +21,7 @@ const isElectron = typeof process !== 'undefined' &&
21
21
  typeof process.versions.electron !== 'undefined';
22
22
  const isWebWorker = typeof WorkerGlobalScope !== 'undefined' && (self instanceof WorkerGlobalScope);
23
23
  const isWindows = typeof process !== 'undefined' && process.platform === "win32";
24
- const isNode = !(isBrowser || isWebWorker);
24
+ const isDeno = typeof Deno !== 'undefined';
25
+ const isNode = !(isBrowser || isWebWorker || isDeno);
25
26
  // ----------------------------------------------------------------------------
26
- export { isBrowser, isElectron, isWebWorker, isNode, isWindows, };
27
+ export { isBrowser, isElectron, isWebWorker, isNode, isDeno, isWindows, };
@@ -280,7 +280,7 @@ export default class binance extends Exchange {
280
280
  calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
281
281
  request(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any, config?: {}): Promise<any>;
282
282
  modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
283
- parseMarginModification(data: any, market?: Market): MarginModification;
283
+ parseMarginModification(data: Dict, market?: Market): MarginModification;
284
284
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
285
285
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
286
286
  fetchCrossBorrowRate(code: string, params?: {}): Promise<CrossBorrowRate>;
package/js/src/binance.js CHANGED
@@ -133,7 +133,7 @@ export default class binance extends Exchange {
133
133
  'fetchPositions': true,
134
134
  'fetchPositionsHistory': false,
135
135
  'fetchPositionsRisk': true,
136
- 'fetchPremiumIndexOHLCV': false,
136
+ 'fetchPremiumIndexOHLCV': true,
137
137
  'fetchSettlementHistory': true,
138
138
  'fetchStatus': true,
139
139
  'fetchTicker': true,
@@ -782,6 +782,7 @@ export default class binance extends Exchange {
782
782
  'continuousKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
783
783
  'markPriceKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
784
784
  'indexPriceKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
785
+ 'premiumIndexKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
785
786
  'fundingRate': 1,
786
787
  'fundingInfo': 1,
787
788
  'premiumIndex': 1,
@@ -4299,6 +4300,14 @@ export default class binance extends Exchange {
4299
4300
  response = await this.fapiPublicGetIndexPriceKlines(this.extend(request, params));
4300
4301
  }
4301
4302
  }
4303
+ else if (price === 'premiumIndex') {
4304
+ if (market['inverse']) {
4305
+ response = await this.dapiPublicGetPremiumIndexKlines(this.extend(request, params));
4306
+ }
4307
+ else {
4308
+ response = await this.fapiPublicGetPremiumIndexKlines(this.extend(request, params));
4309
+ }
4310
+ }
4302
4311
  else if (market['linear']) {
4303
4312
  response = await this.fapiPublicGetKlines(this.extend(request, params));
4304
4313
  }
package/js/src/bingx.d.ts CHANGED
@@ -104,7 +104,7 @@ export default class bingx extends Exchange {
104
104
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
105
105
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
106
106
  setMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
107
- parseMarginModification(data: any, market?: Market): MarginModification;
107
+ parseMarginModification(data: Dict, market?: Market): MarginModification;
108
108
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
109
109
  parseLeverage(leverage: Dict, market?: Market): Leverage;
110
110
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
@@ -144,7 +144,7 @@ export default class bitget extends Exchange {
144
144
  };
145
145
  parseFundingHistories(contracts: any, market?: any, since?: Int, limit?: Int): FundingHistory[];
146
146
  modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
147
- parseMarginModification(data: any, market?: Market): MarginModification;
147
+ parseMarginModification(data: Dict, market?: Market): MarginModification;
148
148
  reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
149
149
  addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
150
150
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
package/js/src/bitget.js CHANGED
@@ -313,6 +313,9 @@ export default class bitget extends Exchange {
313
313
  'v2/spot/account/subaccount-assets': 2,
314
314
  'v2/spot/account/bills': 2,
315
315
  'v2/spot/account/transferRecords': 1,
316
+ 'v2/account/funding-assets': 2,
317
+ 'v2/account/bot-assets': 2,
318
+ 'v2/account/all-account-balance': 20,
316
319
  'v2/spot/wallet/deposit-address': 2,
317
320
  'v2/spot/wallet/deposit-records': 2,
318
321
  'v2/spot/wallet/withdrawal-records': 2,
package/js/src/bitmex.js CHANGED
@@ -244,6 +244,7 @@ export default class bitmex extends Exchange {
244
244
  'orderQty is invalid': InvalidOrder,
245
245
  'Invalid price': InvalidOrder,
246
246
  'Invalid stopPx for ordType': InvalidOrder,
247
+ 'Account is restricted': PermissionDenied, // {"error":{"message":"Account is restricted","name":"HTTPError"}}
247
248
  },
248
249
  'broad': {
249
250
  'Signature not valid': AuthenticationError,
package/js/src/bybit.d.ts CHANGED
@@ -211,6 +211,7 @@ export default class bybit extends Exchange {
211
211
  parseGreeks(greeks: Dict, market?: Market): Greeks;
212
212
  fetchMyLiquidations(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
213
213
  parseLiquidation(liquidation: any, market?: Market): Liquidation;
214
+ getLeverageTiersPaginated(symbol?: Str, params?: {}): Promise<any>;
214
215
  fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<{}>;
215
216
  parseLeverageTiers(response: any, symbols?: Strings, marketIdKey?: any): {};
216
217
  parseMarketLeverageTiers(info: any, market?: Market): any[];