ccxt 4.3.1 → 4.3.3

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 +6 -5
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +25 -0
  4. package/dist/cjs/src/binance.js +320 -21
  5. package/dist/cjs/src/bingx.js +2 -2
  6. package/dist/cjs/src/bitget.js +81 -4
  7. package/dist/cjs/src/coinbase.js +11 -2
  8. package/dist/cjs/src/coinbasepro.js +1 -1
  9. package/dist/cjs/src/coinex.js +109 -146
  10. package/dist/cjs/src/cryptocom.js +5 -5
  11. package/dist/cjs/src/hyperliquid.js +161 -13
  12. package/dist/cjs/src/okx.js +116 -0
  13. package/dist/cjs/src/poloniexfutures.js +12 -2
  14. package/dist/cjs/src/pro/hyperliquid.js +8 -7
  15. package/dist/cjs/src/pro/kraken.js +1 -1
  16. package/dist/cjs/src/pro/wazirx.js +2 -1
  17. package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +27 -2
  18. package/dist/cjs/src/woo.js +110 -6
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/base/Exchange.d.ts +3 -1
  22. package/js/src/base/Exchange.js +25 -0
  23. package/js/src/base/types.d.ts +5 -0
  24. package/js/src/binance.d.ts +3 -0
  25. package/js/src/binance.js +320 -21
  26. package/js/src/bingx.js +3 -3
  27. package/js/src/bitget.d.ts +1 -0
  28. package/js/src/bitget.js +81 -4
  29. package/js/src/coinbase.js +11 -2
  30. package/js/src/coinbasepro.js +1 -1
  31. package/js/src/coinex.js +109 -146
  32. package/js/src/cryptocom.js +5 -5
  33. package/js/src/hyperliquid.d.ts +3 -1
  34. package/js/src/hyperliquid.js +162 -14
  35. package/js/src/okx.d.ts +2 -0
  36. package/js/src/okx.js +116 -0
  37. package/js/src/poloniexfutures.js +12 -2
  38. package/js/src/pro/hyperliquid.js +8 -7
  39. package/js/src/pro/kraken.js +1 -1
  40. package/js/src/pro/wazirx.js +2 -1
  41. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +2 -2
  42. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -357
  43. package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +27 -0
  44. package/js/src/woo.d.ts +2 -0
  45. package/js/src/woo.js +110 -6
  46. package/package.json +1 -1
@@ -17,9 +17,10 @@ class coinbase extends coinbase$1 {
17
17
  describe() {
18
18
  return this.deepExtend(super.describe(), {
19
19
  'id': 'coinbase',
20
- 'name': 'Coinbase',
20
+ 'name': 'Coinbase Advanced',
21
21
  'countries': ['US'],
22
22
  'pro': true,
23
+ 'certified': true,
23
24
  // rate-limits:
24
25
  // ADVANCED API: https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-rate-limits
25
26
  // - max 30 req/second for private data, 10 req/s for public data
@@ -2588,7 +2589,7 @@ class coinbase extends coinbase$1 {
2588
2589
  * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
2589
2590
  * @param {float} [params.takeProfitPrice] price to trigger take-profit orders
2590
2591
  * @param {bool} [params.postOnly] true or false
2591
- * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO'
2592
+ * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO', 'FOK'
2592
2593
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2593
2594
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2594
2595
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
@@ -2693,6 +2694,14 @@ class coinbase extends coinbase$1 {
2693
2694
  },
2694
2695
  };
2695
2696
  }
2697
+ else if (timeInForce === 'FOK') {
2698
+ request['order_configuration'] = {
2699
+ 'limit_limit_fok': {
2700
+ 'base_size': this.amountToPrecision(symbol, amount),
2701
+ 'limit_price': this.priceToPrecision(symbol, price),
2702
+ },
2703
+ };
2704
+ }
2696
2705
  else {
2697
2706
  request['order_configuration'] = {
2698
2707
  'limit_limit_gtc': {
@@ -16,7 +16,7 @@ class coinbasepro extends coinbasepro$1 {
16
16
  describe() {
17
17
  return this.deepExtend(super.describe(), {
18
18
  'id': 'coinbasepro',
19
- 'name': 'Coinbase Pro',
19
+ 'name': 'Coinbase Pro(Deprecated)',
20
20
  'countries': ['US'],
21
21
  'rateLimit': 100,
22
22
  'userAgent': this.userAgents['chrome'],
@@ -812,65 +812,59 @@ class coinex extends coinex$1 {
812
812
  // Spot fetchTicker, fetchTickers
813
813
  //
814
814
  // {
815
- // "vol": "293.19415130",
816
- // "low": "38200.00",
817
- // "open": "39514.99",
818
- // "high": "39530.00",
819
- // "last": "38649.57",
820
- // "buy": "38640.20",
821
- // "buy_amount": "0.22800000",
822
- // "sell": "38640.21",
823
- // "sell_amount": "0.02828439"
815
+ // "close": "62393.47",
816
+ // "high": "64106.41",
817
+ // "last": "62393.47",
818
+ // "low": "59650.01",
819
+ // "market": "BTCUSDT",
820
+ // "open": "61616.15",
821
+ // "period": 86400,
822
+ // "value": "28711273.4065667262",
823
+ // "volume": "461.76557205",
824
+ // "volume_buy": "11.41506354",
825
+ // "volume_sell": "7.3240169"
824
826
  // }
825
827
  //
826
828
  // Swap fetchTicker, fetchTickers
827
829
  //
828
830
  // {
829
- // "vol": "7714.2175",
830
- // "low": "38200.00",
831
- // "open": "39569.23",
832
- // "high": "39569.23",
833
- // "last": "38681.37",
834
- // "buy": "38681.36",
831
+ // "close": "62480.08",
832
+ // "high": "64100",
833
+ // "index_price": "62443.05",
834
+ // "last": "62480.08",
835
+ // "low": "59600",
836
+ // "mark_price": "62443.05",
837
+ // "market": "BTCUSDT",
838
+ // "open": "61679.98",
835
839
  // "period": 86400,
836
- // "funding_time": 462,
837
- // "position_amount": "296.7552",
838
- // "funding_rate_last": "0.00009395",
839
- // "funding_rate_next": "0.00000649",
840
- // "funding_rate_predict": "-0.00007176",
841
- // "insurance": "16464465.09431942163278132918",
842
- // "sign_price": "38681.93",
843
- // "index_price": "38681.69500000",
844
- // "sell_total": "16.6039",
845
- // "buy_total": "19.8481",
846
- // "buy_amount": "4.6315",
847
- // "sell": "38681.37",
848
- // "sell_amount": "11.4044"
840
+ // "value": "180226025.69791713065326633165",
841
+ // "volume": "2900.2218",
842
+ // "volume_buy": "7.3847",
843
+ // "volume_sell": "6.1249"
849
844
  // }
850
845
  //
851
- const timestamp = this.safeInteger(ticker, 'date');
852
- const symbol = this.safeSymbol(undefined, market);
853
- ticker = this.safeValue(ticker, 'ticker', {});
854
- const last = this.safeString(ticker, 'last');
846
+ const marketType = ('mark_price' in ticker) ? 'swap' : 'spot';
847
+ const marketId = this.safeString(ticker, 'market');
848
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
855
849
  return this.safeTicker({
856
850
  'symbol': symbol,
857
- 'timestamp': timestamp,
858
- 'datetime': this.iso8601(timestamp),
851
+ 'timestamp': undefined,
852
+ 'datetime': undefined,
859
853
  'high': this.safeString(ticker, 'high'),
860
854
  'low': this.safeString(ticker, 'low'),
861
- 'bid': this.safeString(ticker, 'buy'),
862
- 'bidVolume': this.safeString(ticker, 'buy_amount'),
863
- 'ask': this.safeString(ticker, 'sell'),
864
- 'askVolume': this.safeString(ticker, 'sell_amount'),
855
+ 'bid': undefined,
856
+ 'bidVolume': this.safeString(ticker, 'volume_buy'),
857
+ 'ask': undefined,
858
+ 'askVolume': this.safeString(ticker, 'volume_sell'),
865
859
  'vwap': undefined,
866
860
  'open': this.safeString(ticker, 'open'),
867
- 'close': last,
868
- 'last': last,
861
+ 'close': this.safeString(ticker, 'close'),
862
+ 'last': this.safeString(ticker, 'last'),
869
863
  'previousClose': undefined,
870
864
  'change': undefined,
871
865
  'percentage': undefined,
872
866
  'average': undefined,
873
- 'baseVolume': this.safeString2(ticker, 'vol', 'volume'),
867
+ 'baseVolume': this.safeString(ticker, 'volume'),
874
868
  'quoteVolume': undefined,
875
869
  'info': ticker,
876
870
  }, market);
@@ -880,8 +874,8 @@ class coinex extends coinex$1 {
880
874
  * @method
881
875
  * @name coinex#fetchTicker
882
876
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
883
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market007_single_market_ticker
884
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http008_market_ticker
877
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
878
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
885
879
  * @param {string} symbol unified symbol of the market to fetch the ticker for
886
880
  * @param {object} [params] extra parameters specific to the exchange API endpoint
887
881
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -893,30 +887,31 @@ class coinex extends coinex$1 {
893
887
  };
894
888
  let response = undefined;
895
889
  if (market['swap']) {
896
- response = await this.v1PerpetualPublicGetMarketTicker(this.extend(request, params));
890
+ response = await this.v2PublicGetFuturesTicker(this.extend(request, params));
897
891
  }
898
892
  else {
899
- response = await this.v1PublicGetMarketTicker(this.extend(request, params));
893
+ response = await this.v2PublicGetSpotTicker(this.extend(request, params));
900
894
  }
901
895
  //
902
896
  // Spot
903
897
  //
904
898
  // {
905
899
  // "code": 0,
906
- // "data": {
907
- // "date": 1651306913414,
908
- // "ticker": {
909
- // "vol": "293.19415130",
910
- // "low": "38200.00",
911
- // "open": "39514.99",
912
- // "high": "39530.00",
913
- // "last": "38649.57",
914
- // "buy": "38640.20",
915
- // "buy_amount": "0.22800000",
916
- // "sell": "38640.21",
917
- // "sell_amount": "0.02828439"
900
+ // "data": [
901
+ // {
902
+ // "close": "62393.47",
903
+ // "high": "64106.41",
904
+ // "last": "62393.47",
905
+ // "low": "59650.01",
906
+ // "market": "BTCUSDT",
907
+ // "open": "61616.15",
908
+ // "period": 86400,
909
+ // "value": "28711273.4065667262",
910
+ // "volume": "461.76557205",
911
+ // "volume_buy": "11.41506354",
912
+ // "volume_sell": "7.3240169"
918
913
  // }
919
- // },
914
+ // ],
920
915
  // "message": "OK"
921
916
  // }
922
917
  //
@@ -924,43 +919,37 @@ class coinex extends coinex$1 {
924
919
  //
925
920
  // {
926
921
  // "code": 0,
927
- // "data": {
928
- // "date": 1651306641500,
929
- // "ticker": {
930
- // "vol": "7714.2175",
931
- // "low": "38200.00",
932
- // "open": "39569.23",
933
- // "high": "39569.23",
934
- // "last": "38681.37",
935
- // "buy": "38681.36",
922
+ // "data": [
923
+ // {
924
+ // "close": "62480.08",
925
+ // "high": "64100",
926
+ // "index_price": "62443.05",
927
+ // "last": "62480.08",
928
+ // "low": "59600",
929
+ // "mark_price": "62443.05",
930
+ // "market": "BTCUSDT",
931
+ // "open": "61679.98",
936
932
  // "period": 86400,
937
- // "funding_time": 462,
938
- // "position_amount": "296.7552",
939
- // "funding_rate_last": "0.00009395",
940
- // "funding_rate_next": "0.00000649",
941
- // "funding_rate_predict": "-0.00007176",
942
- // "insurance": "16464465.09431942163278132918",
943
- // "sign_price": "38681.93",
944
- // "index_price": "38681.69500000",
945
- // "sell_total": "16.6039",
946
- // "buy_total": "19.8481",
947
- // "buy_amount": "4.6315",
948
- // "sell": "38681.37",
949
- // "sell_amount": "11.4044"
933
+ // "value": "180226025.69791713065326633165",
934
+ // "volume": "2900.2218",
935
+ // "volume_buy": "7.3847",
936
+ // "volume_sell": "6.1249"
950
937
  // }
951
- // },
938
+ // ],
952
939
  // "message": "OK"
953
940
  // }
954
941
  //
955
- return this.parseTicker(response['data'], market);
942
+ const data = this.safeList(response, 'data', []);
943
+ const result = this.safeDict(data, 0, {});
944
+ return this.parseTicker(result, market);
956
945
  }
957
946
  async fetchTickers(symbols = undefined, params = {}) {
958
947
  /**
959
948
  * @method
960
949
  * @name coinex#fetchTickers
961
950
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
962
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market008_all_market_ticker
963
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http009_market_ticker_all
951
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
952
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
964
953
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
965
954
  * @param {object} [params] extra parameters specific to the exchange API endpoint
966
955
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -975,86 +964,60 @@ class coinex extends coinex$1 {
975
964
  const [marketType, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
976
965
  let response = undefined;
977
966
  if (marketType === 'swap') {
978
- response = await this.v1PerpetualPublicGetMarketTickerAll(query);
967
+ response = await this.v2PublicGetFuturesTicker(query);
979
968
  }
980
969
  else {
981
- response = await this.v1PublicGetMarketTickerAll();
970
+ response = await this.v2PublicGetSpotTicker(query);
982
971
  }
983
972
  //
984
973
  // Spot
985
974
  //
986
975
  // {
987
976
  // "code": 0,
988
- // "data": {
989
- // "date": 1651519857284,
990
- // "ticker": {
991
- // "PSPUSDT": {
992
- // "vol": "127131.55227034",
993
- // "low": "0.0669",
994
- // "open": "0.0688",
995
- // "high": "0.0747",
996
- // "last": "0.0685",
997
- // "buy": "0.0676",
998
- // "buy_amount": "702.70117866",
999
- // "sell": "0.0690",
1000
- // "sell_amount": "686.76861562"
1001
- // },
977
+ // "data": [
978
+ // {
979
+ // "close": "62393.47",
980
+ // "high": "64106.41",
981
+ // "last": "62393.47",
982
+ // "low": "59650.01",
983
+ // "market": "BTCUSDT",
984
+ // "open": "61616.15",
985
+ // "period": 86400,
986
+ // "value": "28711273.4065667262",
987
+ // "volume": "461.76557205",
988
+ // "volume_buy": "11.41506354",
989
+ // "volume_sell": "7.3240169"
1002
990
  // }
1003
- // },
1004
- // "message": "Ok"
991
+ // ],
992
+ // "message": "OK"
1005
993
  // }
1006
994
  //
1007
995
  // Swap
1008
996
  //
1009
997
  // {
1010
998
  // "code": 0,
1011
- // "data": {
1012
- // "date": 1651520268644,
1013
- // "ticker": {
1014
- // "KAVAUSDT": {
1015
- // "vol": "834924",
1016
- // "low": "3.9418",
1017
- // "open": "4.1834",
1018
- // "high": "4.4328",
1019
- // "last": "4.0516",
1020
- // "buy": "4.0443",
1021
- // "period": 86400,
1022
- // "funding_time": 262,
1023
- // "position_amount": "16111",
1024
- // "funding_rate_last": "-0.00069514",
1025
- // "funding_rate_next": "-0.00061009",
1026
- // "funding_rate_predict": "-0.00055812",
1027
- // "insurance": "16532425.53026084124483989548",
1028
- // "sign_price": "4.0516",
1029
- // "index_price": "4.0530",
1030
- // "sell_total": "59446",
1031
- // "buy_total": "62423",
1032
- // "buy_amount": "959",
1033
- // "sell": "4.0466",
1034
- // "sell_amount": "141"
1035
- // },
999
+ // "data": [
1000
+ // {
1001
+ // "close": "62480.08",
1002
+ // "high": "64100",
1003
+ // "index_price": "62443.05",
1004
+ // "last": "62480.08",
1005
+ // "low": "59600",
1006
+ // "mark_price": "62443.05",
1007
+ // "market": "BTCUSDT",
1008
+ // "open": "61679.98",
1009
+ // "period": 86400,
1010
+ // "value": "180226025.69791713065326633165",
1011
+ // "volume": "2900.2218",
1012
+ // "volume_buy": "7.3847",
1013
+ // "volume_sell": "6.1249"
1036
1014
  // }
1037
- // },
1038
- // "message": "Ok"
1015
+ // ],
1016
+ // "message": "OK"
1039
1017
  // }
1040
1018
  //
1041
- const data = this.safeValue(response, 'data');
1042
- const timestamp = this.safeInteger(data, 'date');
1043
- const tickers = this.safeValue(data, 'ticker', {});
1044
- const marketIds = Object.keys(tickers);
1045
- const result = {};
1046
- for (let i = 0; i < marketIds.length; i++) {
1047
- const marketId = marketIds[i];
1048
- const marketInner = this.safeMarket(marketId, undefined, undefined, marketType);
1049
- const symbol = marketInner['symbol'];
1050
- const ticker = this.parseTicker({
1051
- 'date': timestamp,
1052
- 'ticker': tickers[marketId],
1053
- }, marketInner);
1054
- ticker['symbol'] = symbol;
1055
- result[symbol] = ticker;
1056
- }
1057
- return this.filterByArrayTickers(result, 'symbol', symbols);
1019
+ const data = this.safeList(response, 'data', []);
1020
+ return this.parseTickers(data, symbols);
1058
1021
  }
1059
1022
  async fetchTime(params = {}) {
1060
1023
  /**
@@ -1625,7 +1625,7 @@ class cryptocom extends cryptocom$1 {
1625
1625
  */
1626
1626
  [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1627
1627
  await this.loadMarkets();
1628
- const currency = this.currency(code);
1628
+ const currency = this.safeCurrency(code); // for instance, USDC is not inferred from markets but it's still available
1629
1629
  const request = {
1630
1630
  'currency': currency['id'],
1631
1631
  'amount': amount,
@@ -1671,7 +1671,7 @@ class cryptocom extends cryptocom$1 {
1671
1671
  * @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure} indexed by the network
1672
1672
  */
1673
1673
  await this.loadMarkets();
1674
- const currency = this.currency(code);
1674
+ const currency = this.safeCurrency(code);
1675
1675
  const request = {
1676
1676
  'currency': currency['id'],
1677
1677
  };
@@ -1770,7 +1770,7 @@ class cryptocom extends cryptocom$1 {
1770
1770
  let currency = undefined;
1771
1771
  const request = {};
1772
1772
  if (code !== undefined) {
1773
- currency = this.currency(code);
1773
+ currency = this.safeCurrency(code);
1774
1774
  request['currency'] = currency['id'];
1775
1775
  }
1776
1776
  if (since !== undefined) {
@@ -1829,7 +1829,7 @@ class cryptocom extends cryptocom$1 {
1829
1829
  let currency = undefined;
1830
1830
  const request = {};
1831
1831
  if (code !== undefined) {
1832
- currency = this.currency(code);
1832
+ currency = this.safeCurrency(code);
1833
1833
  request['currency'] = currency['id'];
1834
1834
  }
1835
1835
  if (since !== undefined) {
@@ -2345,7 +2345,7 @@ class cryptocom extends cryptocom$1 {
2345
2345
  const request = {};
2346
2346
  let currency = undefined;
2347
2347
  if (code !== undefined) {
2348
- currency = this.currency(code);
2348
+ currency = this.safeCurrency(code);
2349
2349
  }
2350
2350
  if (since !== undefined) {
2351
2351
  request['start_time'] = since;