ccxt 4.1.49 → 4.1.50

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.
package/js/src/okx.js CHANGED
@@ -71,6 +71,7 @@ export default class okx extends Exchange {
71
71
  'fetchFundingRate': true,
72
72
  'fetchFundingRateHistory': true,
73
73
  'fetchFundingRates': false,
74
+ 'fetchGreeks': true,
74
75
  'fetchIndexOHLCV': true,
75
76
  'fetchL3OrderBook': false,
76
77
  'fetchLedger': true,
@@ -6948,6 +6949,113 @@ export default class okx extends Exchange {
6948
6949
  const underlyings = this.safeValue(response, 'data', []);
6949
6950
  return underlyings[0];
6950
6951
  }
6952
+ async fetchGreeks(symbol, params = {}) {
6953
+ /**
6954
+ * @method
6955
+ * @name okx#fetchGreeks
6956
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
6957
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
6958
+ * @param {string} symbol unified symbol of the market to fetch greeks for
6959
+ * @param {object} [params] extra parameters specific to the okx api endpoint
6960
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
6961
+ */
6962
+ await this.loadMarkets();
6963
+ const market = this.market(symbol);
6964
+ const marketId = market['id'];
6965
+ const optionParts = marketId.split('-');
6966
+ const request = {
6967
+ 'uly': market['info']['uly'],
6968
+ 'instFamily': market['info']['instFamily'],
6969
+ 'expTime': this.safeString(optionParts, 2),
6970
+ };
6971
+ const response = await this.publicGetPublicOptSummary(this.extend(request, params));
6972
+ //
6973
+ // {
6974
+ // "code": "0",
6975
+ // "data": [
6976
+ // {
6977
+ // "askVol": "0",
6978
+ // "bidVol": "0",
6979
+ // "delta": "0.5105464486882039",
6980
+ // "deltaBS": "0.7325502184143025",
6981
+ // "fwdPx": "37675.80158694987186",
6982
+ // "gamma": "-0.13183515090501083",
6983
+ // "gammaBS": "0.000024139685826358558",
6984
+ // "instId": "BTC-USD-240329-32000-C",
6985
+ // "instType": "OPTION",
6986
+ // "lever": "4.504428015946619",
6987
+ // "markVol": "0.5916253554539876",
6988
+ // "realVol": "0",
6989
+ // "theta": "-0.0004202992014012855",
6990
+ // "thetaBS": "-18.52354631567909",
6991
+ // "ts": "1699586421976",
6992
+ // "uly": "BTC-USD",
6993
+ // "vega": "0.0020207455080045846",
6994
+ // "vegaBS": "74.44022302387287",
6995
+ // "volLv": "0.5948549730405797"
6996
+ // },
6997
+ // ],
6998
+ // "msg": ""
6999
+ // }
7000
+ //
7001
+ const data = this.safeValue(response, 'data', []);
7002
+ for (let i = 0; i < data.length; i++) {
7003
+ const entry = data[i];
7004
+ const entryMarketId = this.safeString(entry, 'instId');
7005
+ if (entryMarketId === marketId) {
7006
+ return this.parseGreeks(entry, market);
7007
+ }
7008
+ }
7009
+ }
7010
+ parseGreeks(greeks, market = undefined) {
7011
+ //
7012
+ // {
7013
+ // "askVol": "0",
7014
+ // "bidVol": "0",
7015
+ // "delta": "0.5105464486882039",
7016
+ // "deltaBS": "0.7325502184143025",
7017
+ // "fwdPx": "37675.80158694987186",
7018
+ // "gamma": "-0.13183515090501083",
7019
+ // "gammaBS": "0.000024139685826358558",
7020
+ // "instId": "BTC-USD-240329-32000-C",
7021
+ // "instType": "OPTION",
7022
+ // "lever": "4.504428015946619",
7023
+ // "markVol": "0.5916253554539876",
7024
+ // "realVol": "0",
7025
+ // "theta": "-0.0004202992014012855",
7026
+ // "thetaBS": "-18.52354631567909",
7027
+ // "ts": "1699586421976",
7028
+ // "uly": "BTC-USD",
7029
+ // "vega": "0.0020207455080045846",
7030
+ // "vegaBS": "74.44022302387287",
7031
+ // "volLv": "0.5948549730405797"
7032
+ // }
7033
+ //
7034
+ const timestamp = this.safeInteger(greeks, 'ts');
7035
+ const marketId = this.safeString(greeks, 'instId');
7036
+ const symbol = this.safeSymbol(marketId, market);
7037
+ return {
7038
+ 'symbol': symbol,
7039
+ 'timestamp': timestamp,
7040
+ 'datetime': this.iso8601(timestamp),
7041
+ 'delta': this.safeNumber(greeks, 'delta'),
7042
+ 'gamma': this.safeNumber(greeks, 'gamma'),
7043
+ 'theta': this.safeNumber(greeks, 'theta'),
7044
+ 'vega': this.safeNumber(greeks, 'vega'),
7045
+ 'rho': undefined,
7046
+ 'bidSize': undefined,
7047
+ 'askSize': undefined,
7048
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bidVol'),
7049
+ 'askImpliedVolatility': this.safeNumber(greeks, 'askVol'),
7050
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markVol'),
7051
+ 'bidPrice': undefined,
7052
+ 'askPrice': undefined,
7053
+ 'markPrice': undefined,
7054
+ 'lastPrice': undefined,
7055
+ 'underlyingPrice': undefined,
7056
+ 'info': greeks,
7057
+ };
7058
+ }
6951
7059
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
6952
7060
  if (!response) {
6953
7061
  return undefined; // fallback to default error handler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.49",
3
+ "version": "4.1.50",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",
package/skip-tests.json CHANGED
@@ -124,6 +124,8 @@
124
124
  }
125
125
  },
126
126
  "bit2c": {
127
+ "skip": "temporary certificate issues",
128
+ "until": "2023-11-25",
127
129
  "skipMethods": {
128
130
  "loadMarkets": {
129
131
  "precision": "not provided",