ccxt 4.1.49 → 4.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1040 -153
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +76 -0
  7. package/dist/cjs/src/bybit.js +121 -0
  8. package/dist/cjs/src/cryptocom.js +1 -0
  9. package/dist/cjs/src/delta.js +149 -0
  10. package/dist/cjs/src/deribit.js +132 -0
  11. package/dist/cjs/src/gate.js +102 -4
  12. package/dist/cjs/src/htx.js +313 -135
  13. package/dist/cjs/src/kraken.js +7 -10
  14. package/dist/cjs/src/okx.js +108 -0
  15. package/dist/cjs/src/pro/krakenfutures.js +24 -3
  16. package/js/ccxt.d.ts +3 -3
  17. package/js/ccxt.js +1 -1
  18. package/js/src/abstract/htx.d.ts +1 -1
  19. package/js/src/abstract/huobi.d.ts +1 -1
  20. package/js/src/abstract/huobipro.d.ts +1 -1
  21. package/js/src/abstract/kraken.d.ts +0 -5
  22. package/js/src/base/Exchange.d.ts +4 -2
  23. package/js/src/base/Exchange.js +6 -0
  24. package/js/src/base/types.d.ts +21 -0
  25. package/js/src/binance.d.ts +23 -1
  26. package/js/src/binance.js +76 -0
  27. package/js/src/bybit.d.ts +23 -1
  28. package/js/src/bybit.js +121 -0
  29. package/js/src/cryptocom.js +1 -0
  30. package/js/src/delta.d.ts +23 -1
  31. package/js/src/delta.js +149 -0
  32. package/js/src/deribit.d.ts +23 -1
  33. package/js/src/deribit.js +132 -0
  34. package/js/src/gate.d.ts +23 -1
  35. package/js/src/gate.js +102 -4
  36. package/js/src/htx.d.ts +4 -3
  37. package/js/src/htx.js +313 -135
  38. package/js/src/kraken.js +7 -10
  39. package/js/src/okx.d.ts +23 -1
  40. package/js/src/okx.js +108 -0
  41. package/js/src/pro/krakenfutures.js +24 -3
  42. package/package.json +1 -1
  43. package/skip-tests.json +2 -0
@@ -102,6 +102,7 @@ class gate extends gate$1 {
102
102
  'fetchFundingRate': true,
103
103
  'fetchFundingRateHistory': true,
104
104
  'fetchFundingRates': true,
105
+ 'fetchGreeks': true,
105
106
  'fetchIndexOHLCV': true,
106
107
  'fetchLedger': true,
107
108
  'fetchLeverage': false,
@@ -4075,6 +4076,7 @@ class gate extends gate$1 {
4075
4076
  * @name gate#editOrder
4076
4077
  * @description edit a trade order, gate currently only supports the modification of the price or amount fields
4077
4078
  * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order
4079
+ * @see https://www.gate.io/docs/developers/apiv4/en/#amend-an-order-2
4078
4080
  * @param {string} id order id
4079
4081
  * @param {string} symbol unified symbol of the market to create an order in
4080
4082
  * @param {string} type 'market' or 'limit'
@@ -4086,9 +4088,6 @@ class gate extends gate$1 {
4086
4088
  */
4087
4089
  await this.loadMarkets();
4088
4090
  const market = this.market(symbol);
4089
- if (!market['spot']) {
4090
- throw new errors.BadRequest(this.id + ' editOrder() supports only spot markets');
4091
- }
4092
4091
  const [marketType, query] = this.handleMarketTypeAndParams('editOrder', market, params);
4093
4092
  const account = this.convertTypeToAccount(marketType);
4094
4093
  const isLimitOrder = (type === 'limit');
@@ -4109,7 +4108,14 @@ class gate extends gate$1 {
4109
4108
  if (price !== undefined) {
4110
4109
  request['price'] = this.priceToPrecision(symbol, price);
4111
4110
  }
4112
- const response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
4111
+ let response = undefined;
4112
+ if (market['spot']) {
4113
+ response = await this.privateSpotPatchOrdersOrderId(this.extend(request, query));
4114
+ }
4115
+ else {
4116
+ request['settle'] = market['settleId'];
4117
+ response = await this.privateFuturesPutSettleOrdersOrderId(this.extend(request, query));
4118
+ }
4113
4119
  //
4114
4120
  // {
4115
4121
  // "id": "243233276443",
@@ -6668,6 +6674,98 @@ class gate extends gate$1 {
6668
6674
  'datetime': this.iso8601(timestamp),
6669
6675
  });
6670
6676
  }
6677
+ async fetchGreeks(symbol, params = {}) {
6678
+ /**
6679
+ * @method
6680
+ * @name gate#fetchGreeks
6681
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
6682
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-tickers-of-options-contracts
6683
+ * @param {string} symbol unified symbol of the market to fetch greeks for
6684
+ * @param {object} [params] extra parameters specific to the gate api endpoint
6685
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
6686
+ */
6687
+ await this.loadMarkets();
6688
+ const market = this.market(symbol);
6689
+ const request = {
6690
+ 'underlying': market['info']['underlying'],
6691
+ };
6692
+ const response = await this.publicOptionsGetTickers(this.extend(request, params));
6693
+ //
6694
+ // [
6695
+ // {
6696
+ // "vega": "1.78992",
6697
+ // "leverage": "6.2096777055417",
6698
+ // "ask_iv": "0.6245",
6699
+ // "delta": "-0.69397",
6700
+ // "last_price": "0",
6701
+ // "theta": "-2.5723",
6702
+ // "bid1_price": "222.9",
6703
+ // "mark_iv": "0.5909",
6704
+ // "name": "ETH_USDT-20231201-2300-P",
6705
+ // "bid_iv": "0.5065",
6706
+ // "ask1_price": "243.6",
6707
+ // "mark_price": "236.57",
6708
+ // "position_size": 0,
6709
+ // "bid1_size": 368,
6710
+ // "ask1_size": -335,
6711
+ // "gamma": "0.00116"
6712
+ // },
6713
+ // ]
6714
+ //
6715
+ const marketId = market['id'];
6716
+ for (let i = 0; i < response.length; i++) {
6717
+ const entry = response[i];
6718
+ const entryMarketId = this.safeString(entry, 'name');
6719
+ if (entryMarketId === marketId) {
6720
+ return this.parseGreeks(entry, market);
6721
+ }
6722
+ }
6723
+ }
6724
+ parseGreeks(greeks, market = undefined) {
6725
+ //
6726
+ // {
6727
+ // "vega": "1.78992",
6728
+ // "leverage": "6.2096777055417",
6729
+ // "ask_iv": "0.6245",
6730
+ // "delta": "-0.69397",
6731
+ // "last_price": "0",
6732
+ // "theta": "-2.5723",
6733
+ // "bid1_price": "222.9",
6734
+ // "mark_iv": "0.5909",
6735
+ // "name": "ETH_USDT-20231201-2300-P",
6736
+ // "bid_iv": "0.5065",
6737
+ // "ask1_price": "243.6",
6738
+ // "mark_price": "236.57",
6739
+ // "position_size": 0,
6740
+ // "bid1_size": 368,
6741
+ // "ask1_size": -335,
6742
+ // "gamma": "0.00116"
6743
+ // }
6744
+ //
6745
+ const marketId = this.safeString(greeks, 'name');
6746
+ const symbol = this.safeSymbol(marketId, market);
6747
+ return {
6748
+ 'symbol': symbol,
6749
+ 'timestamp': undefined,
6750
+ 'datetime': undefined,
6751
+ 'delta': this.safeNumber(greeks, 'delta'),
6752
+ 'gamma': this.safeNumber(greeks, 'gamma'),
6753
+ 'theta': this.safeNumber(greeks, 'theta'),
6754
+ 'vega': this.safeNumber(greeks, 'vega'),
6755
+ 'rho': undefined,
6756
+ 'bidSize': this.safeNumber(greeks, 'bid1_size'),
6757
+ 'askSize': this.safeNumber(greeks, 'ask1_size'),
6758
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
6759
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
6760
+ 'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
6761
+ 'bidPrice': this.safeNumber(greeks, 'bid1_price'),
6762
+ 'askPrice': this.safeNumber(greeks, 'ask1_price'),
6763
+ 'markPrice': this.safeNumber(greeks, 'mark_price'),
6764
+ 'lastPrice': this.safeNumber(greeks, 'last_price'),
6765
+ 'underlyingPrice': this.parseNumber(market['info']['underlying_price']),
6766
+ 'info': greeks,
6767
+ };
6768
+ }
6671
6769
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
6672
6770
  if (response === undefined) {
6673
6771
  return undefined;