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.
@@ -68,6 +68,7 @@ class okx extends okx$1 {
68
68
  'fetchFundingRate': true,
69
69
  'fetchFundingRateHistory': true,
70
70
  'fetchFundingRates': false,
71
+ 'fetchGreeks': true,
71
72
  'fetchIndexOHLCV': true,
72
73
  'fetchL3OrderBook': false,
73
74
  'fetchLedger': true,
@@ -6945,6 +6946,113 @@ class okx extends okx$1 {
6945
6946
  const underlyings = this.safeValue(response, 'data', []);
6946
6947
  return underlyings[0];
6947
6948
  }
6949
+ async fetchGreeks(symbol, params = {}) {
6950
+ /**
6951
+ * @method
6952
+ * @name okx#fetchGreeks
6953
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
6954
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
6955
+ * @param {string} symbol unified symbol of the market to fetch greeks for
6956
+ * @param {object} [params] extra parameters specific to the okx api endpoint
6957
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
6958
+ */
6959
+ await this.loadMarkets();
6960
+ const market = this.market(symbol);
6961
+ const marketId = market['id'];
6962
+ const optionParts = marketId.split('-');
6963
+ const request = {
6964
+ 'uly': market['info']['uly'],
6965
+ 'instFamily': market['info']['instFamily'],
6966
+ 'expTime': this.safeString(optionParts, 2),
6967
+ };
6968
+ const response = await this.publicGetPublicOptSummary(this.extend(request, params));
6969
+ //
6970
+ // {
6971
+ // "code": "0",
6972
+ // "data": [
6973
+ // {
6974
+ // "askVol": "0",
6975
+ // "bidVol": "0",
6976
+ // "delta": "0.5105464486882039",
6977
+ // "deltaBS": "0.7325502184143025",
6978
+ // "fwdPx": "37675.80158694987186",
6979
+ // "gamma": "-0.13183515090501083",
6980
+ // "gammaBS": "0.000024139685826358558",
6981
+ // "instId": "BTC-USD-240329-32000-C",
6982
+ // "instType": "OPTION",
6983
+ // "lever": "4.504428015946619",
6984
+ // "markVol": "0.5916253554539876",
6985
+ // "realVol": "0",
6986
+ // "theta": "-0.0004202992014012855",
6987
+ // "thetaBS": "-18.52354631567909",
6988
+ // "ts": "1699586421976",
6989
+ // "uly": "BTC-USD",
6990
+ // "vega": "0.0020207455080045846",
6991
+ // "vegaBS": "74.44022302387287",
6992
+ // "volLv": "0.5948549730405797"
6993
+ // },
6994
+ // ],
6995
+ // "msg": ""
6996
+ // }
6997
+ //
6998
+ const data = this.safeValue(response, 'data', []);
6999
+ for (let i = 0; i < data.length; i++) {
7000
+ const entry = data[i];
7001
+ const entryMarketId = this.safeString(entry, 'instId');
7002
+ if (entryMarketId === marketId) {
7003
+ return this.parseGreeks(entry, market);
7004
+ }
7005
+ }
7006
+ }
7007
+ parseGreeks(greeks, market = undefined) {
7008
+ //
7009
+ // {
7010
+ // "askVol": "0",
7011
+ // "bidVol": "0",
7012
+ // "delta": "0.5105464486882039",
7013
+ // "deltaBS": "0.7325502184143025",
7014
+ // "fwdPx": "37675.80158694987186",
7015
+ // "gamma": "-0.13183515090501083",
7016
+ // "gammaBS": "0.000024139685826358558",
7017
+ // "instId": "BTC-USD-240329-32000-C",
7018
+ // "instType": "OPTION",
7019
+ // "lever": "4.504428015946619",
7020
+ // "markVol": "0.5916253554539876",
7021
+ // "realVol": "0",
7022
+ // "theta": "-0.0004202992014012855",
7023
+ // "thetaBS": "-18.52354631567909",
7024
+ // "ts": "1699586421976",
7025
+ // "uly": "BTC-USD",
7026
+ // "vega": "0.0020207455080045846",
7027
+ // "vegaBS": "74.44022302387287",
7028
+ // "volLv": "0.5948549730405797"
7029
+ // }
7030
+ //
7031
+ const timestamp = this.safeInteger(greeks, 'ts');
7032
+ const marketId = this.safeString(greeks, 'instId');
7033
+ const symbol = this.safeSymbol(marketId, market);
7034
+ return {
7035
+ 'symbol': symbol,
7036
+ 'timestamp': timestamp,
7037
+ 'datetime': this.iso8601(timestamp),
7038
+ 'delta': this.safeNumber(greeks, 'delta'),
7039
+ 'gamma': this.safeNumber(greeks, 'gamma'),
7040
+ 'theta': this.safeNumber(greeks, 'theta'),
7041
+ 'vega': this.safeNumber(greeks, 'vega'),
7042
+ 'rho': undefined,
7043
+ 'bidSize': undefined,
7044
+ 'askSize': undefined,
7045
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bidVol'),
7046
+ 'askImpliedVolatility': this.safeNumber(greeks, 'askVol'),
7047
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markVol'),
7048
+ 'bidPrice': undefined,
7049
+ 'askPrice': undefined,
7050
+ 'markPrice': undefined,
7051
+ 'lastPrice': undefined,
7052
+ 'underlyingPrice': undefined,
7053
+ 'info': greeks,
7054
+ };
7055
+ }
6948
7056
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
6949
7057
  if (!response) {
6950
7058
  return undefined; // fallback to default error handler
package/js/ccxt.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
2
2
  import { Precise } from './src/base/Precise.js';
3
3
  import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
- import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode } from './src/base/types.js';
5
+ import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } 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.48";
7
+ declare const version = "4.1.49";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -522,5 +522,5 @@ declare const ccxt: {
522
522
  zaif: typeof zaif;
523
523
  zonda: typeof zonda;
524
524
  } & typeof functions & typeof errors;
525
- export { version, Exchange, exchanges, pro, Precise, functions, errors, 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, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinlist, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
525
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, 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, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinlist, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
526
526
  export default ccxt;
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.49';
41
+ const version = '4.1.50';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -344,7 +344,7 @@ interface Exchange {
344
344
  contractPrivatePostApiV3ContractFinancialRecordExact(params?: {}): Promise<implicitReturnType>;
345
345
  contractPrivatePostApiV1ContractCancelAfter(params?: {}): Promise<implicitReturnType>;
346
346
  contractPrivatePostApiV1ContractOrder(params?: {}): Promise<implicitReturnType>;
347
- contractPrivatePostV1ContractBatchorder(params?: {}): Promise<implicitReturnType>;
347
+ contractPrivatePostApiV1ContractBatchorder(params?: {}): Promise<implicitReturnType>;
348
348
  contractPrivatePostApiV1ContractCancel(params?: {}): Promise<implicitReturnType>;
349
349
  contractPrivatePostApiV1ContractCancelall(params?: {}): Promise<implicitReturnType>;
350
350
  contractPrivatePostApiV1ContractSwitchLeverRate(params?: {}): Promise<implicitReturnType>;
@@ -344,7 +344,7 @@ interface htx {
344
344
  contractPrivatePostApiV3ContractFinancialRecordExact(params?: {}): Promise<implicitReturnType>;
345
345
  contractPrivatePostApiV1ContractCancelAfter(params?: {}): Promise<implicitReturnType>;
346
346
  contractPrivatePostApiV1ContractOrder(params?: {}): Promise<implicitReturnType>;
347
- contractPrivatePostV1ContractBatchorder(params?: {}): Promise<implicitReturnType>;
347
+ contractPrivatePostApiV1ContractBatchorder(params?: {}): Promise<implicitReturnType>;
348
348
  contractPrivatePostApiV1ContractCancel(params?: {}): Promise<implicitReturnType>;
349
349
  contractPrivatePostApiV1ContractCancelall(params?: {}): Promise<implicitReturnType>;
350
350
  contractPrivatePostApiV1ContractSwitchLeverRate(params?: {}): Promise<implicitReturnType>;
@@ -344,7 +344,7 @@ interface huobi {
344
344
  contractPrivatePostApiV3ContractFinancialRecordExact(params?: {}): Promise<implicitReturnType>;
345
345
  contractPrivatePostApiV1ContractCancelAfter(params?: {}): Promise<implicitReturnType>;
346
346
  contractPrivatePostApiV1ContractOrder(params?: {}): Promise<implicitReturnType>;
347
- contractPrivatePostV1ContractBatchorder(params?: {}): Promise<implicitReturnType>;
347
+ contractPrivatePostApiV1ContractBatchorder(params?: {}): Promise<implicitReturnType>;
348
348
  contractPrivatePostApiV1ContractCancel(params?: {}): Promise<implicitReturnType>;
349
349
  contractPrivatePostApiV1ContractCancelall(params?: {}): Promise<implicitReturnType>;
350
350
  contractPrivatePostApiV1ContractSwitchLeverRate(params?: {}): Promise<implicitReturnType>;
@@ -4,8 +4,8 @@ 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, OpenInterest, Liquidation, OrderRequest, FundingHistory, MarginMode, Tickers } from './types.js';
8
- export { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory, Liquidation, FundingHistory } 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, Liquidation, OrderRequest, FundingHistory, MarginMode, Tickers, Greeks } from './types.js';
8
+ export { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory, Liquidation, FundingHistory, Greeks } from './types.js';
9
9
  /**
10
10
  * @class Exchange
11
11
  */
@@ -745,6 +745,7 @@ export default class Exchange {
745
745
  fetchMyTradesWs(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
746
746
  watchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
747
747
  fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
748
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
748
749
  fetchDepositsWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
749
750
  fetchDeposits(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
750
751
  fetchWithdrawals(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
@@ -839,5 +840,6 @@ export default class Exchange {
839
840
  safeOpenInterest(interest: any, market?: any): OpenInterest;
840
841
  parseLiquidation(liquidation: any, market?: any): Liquidation;
841
842
  parseLiquidations(liquidations: any, market?: any, since?: Int, limit?: Int): Liquidation[];
843
+ parseGreeks(greeks: any, market?: any): Greeks;
842
844
  }
843
845
  export { Exchange, };
@@ -3440,6 +3440,9 @@ export default class Exchange {
3440
3440
  async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
3441
3441
  throw new NotSupported(this.id + ' fetchOHLCVWs() is not supported yet');
3442
3442
  }
3443
+ async fetchGreeks(symbol, params = {}) {
3444
+ throw new NotSupported(this.id + ' fetchGreeks() is not supported yet');
3445
+ }
3443
3446
  async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
3444
3447
  /**
3445
3448
  * @method
@@ -4600,5 +4603,8 @@ export default class Exchange {
4600
4603
  const symbol = this.safeString(market, 'symbol');
4601
4604
  return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
4602
4605
  }
4606
+ parseGreeks(greeks, market = undefined) {
4607
+ throw new NotSupported(this.id + ' parseGreeks () is not supported yet');
4608
+ }
4603
4609
  }
4604
4610
  export { Exchange, };
@@ -259,6 +259,27 @@ export interface MarginMode {
259
259
  symbol: string;
260
260
  marginMode: 'isolated' | 'cross' | string;
261
261
  }
262
+ export interface Greeks {
263
+ symbol: string;
264
+ timestamp?: number;
265
+ datetime?: string;
266
+ delta: number;
267
+ gamma: number;
268
+ theta: number;
269
+ vega: number;
270
+ rho: number;
271
+ bidSize: number;
272
+ askSize: number;
273
+ bidImpliedVolatility: number;
274
+ askImpliedVolatility: number;
275
+ markImpliedVolatility: number;
276
+ bidPrice: number;
277
+ askPrice: number;
278
+ markPrice: number;
279
+ lastPrice: number;
280
+ underlyingPrice: number;
281
+ info: any;
282
+ }
262
283
  /** [ timestamp, open, high, low, close, volume ] */
263
284
  export declare type OHLCV = [number, number, number, number, number, number];
264
285
  /** [ timestamp, open, high, low, close, volume, count ] */
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import { Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Transaction, Ticker, OrderBook, Tickers, Market } from './base/types.js';
2
+ import { Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Transaction, Ticker, OrderBook, Tickers, Market, Greeks } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @extends Exchange
@@ -433,4 +433,26 @@ export default class binance extends Exchange {
433
433
  parseOpenInterest(interest: any, market?: any): OpenInterest;
434
434
  fetchMyLiquidations(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
435
435
  parseLiquidation(liquidation: any, market?: any): Liquidation;
436
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
437
+ parseGreeks(greeks: any, market?: any): {
438
+ symbol: any;
439
+ timestamp: any;
440
+ datetime: any;
441
+ delta: number;
442
+ gamma: number;
443
+ theta: number;
444
+ vega: number;
445
+ rho: any;
446
+ bidSize: any;
447
+ askSize: any;
448
+ bidImpliedVolatility: number;
449
+ askImpliedVolatility: number;
450
+ markImpliedVolatility: number;
451
+ bidPrice: any;
452
+ askPrice: any;
453
+ markPrice: number;
454
+ lastPrice: any;
455
+ underlyingPrice: any;
456
+ info: any;
457
+ };
436
458
  }
package/js/src/binance.js CHANGED
@@ -74,6 +74,7 @@ export default class binance extends Exchange {
74
74
  'fetchFundingRate': true,
75
75
  'fetchFundingRateHistory': true,
76
76
  'fetchFundingRates': true,
77
+ 'fetchGreeks': true,
77
78
  'fetchIndexOHLCV': true,
78
79
  'fetchL3OrderBook': false,
79
80
  'fetchLastPrices': true,
@@ -9547,4 +9548,79 @@ export default class binance extends Exchange {
9547
9548
  'datetime': this.iso8601(timestamp),
9548
9549
  });
9549
9550
  }
9551
+ async fetchGreeks(symbol, params = {}) {
9552
+ /**
9553
+ * @method
9554
+ * @name binance#fetchGreeks
9555
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
9556
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#option-mark-price
9557
+ * @param {string} symbol unified symbol of the market to fetch greeks for
9558
+ * @param {object} [params] extra parameters specific to the binance api endpoint
9559
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
9560
+ */
9561
+ await this.loadMarkets();
9562
+ const market = this.market(symbol);
9563
+ const request = {
9564
+ 'symbol': market['id'],
9565
+ };
9566
+ const response = await this.eapiPublicGetMark(this.extend(request, params));
9567
+ //
9568
+ // [
9569
+ // {
9570
+ // "symbol": "BTC-231229-40000-C",
9571
+ // "markPrice": "2012",
9572
+ // "bidIV": "0.60236275",
9573
+ // "askIV": "0.62267244",
9574
+ // "markIV": "0.6125176",
9575
+ // "delta": "0.39111646",
9576
+ // "theta": "-32.13948531",
9577
+ // "gamma": "0.00004656",
9578
+ // "vega": "51.70062218",
9579
+ // "highPriceLimit": "6474",
9580
+ // "lowPriceLimit": "5"
9581
+ // }
9582
+ // ]
9583
+ //
9584
+ return this.parseGreeks(response[0], market);
9585
+ }
9586
+ parseGreeks(greeks, market = undefined) {
9587
+ //
9588
+ // {
9589
+ // "symbol": "BTC-231229-40000-C",
9590
+ // "markPrice": "2012",
9591
+ // "bidIV": "0.60236275",
9592
+ // "askIV": "0.62267244",
9593
+ // "markIV": "0.6125176",
9594
+ // "delta": "0.39111646",
9595
+ // "theta": "-32.13948531",
9596
+ // "gamma": "0.00004656",
9597
+ // "vega": "51.70062218",
9598
+ // "highPriceLimit": "6474",
9599
+ // "lowPriceLimit": "5"
9600
+ // }
9601
+ //
9602
+ const marketId = this.safeString(greeks, 'symbol');
9603
+ const symbol = this.safeSymbol(marketId, market);
9604
+ return {
9605
+ 'symbol': symbol,
9606
+ 'timestamp': undefined,
9607
+ 'datetime': undefined,
9608
+ 'delta': this.safeNumber(greeks, 'delta'),
9609
+ 'gamma': this.safeNumber(greeks, 'gamma'),
9610
+ 'theta': this.safeNumber(greeks, 'theta'),
9611
+ 'vega': this.safeNumber(greeks, 'vega'),
9612
+ 'rho': undefined,
9613
+ 'bidSize': undefined,
9614
+ 'askSize': undefined,
9615
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bidIV'),
9616
+ 'askImpliedVolatility': this.safeNumber(greeks, 'askIV'),
9617
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markIV'),
9618
+ 'bidPrice': undefined,
9619
+ 'askPrice': undefined,
9620
+ 'markPrice': this.safeNumber(greeks, 'markPrice'),
9621
+ 'lastPrice': undefined,
9622
+ 'underlyingPrice': undefined,
9623
+ 'info': greeks,
9624
+ };
9625
+ }
9550
9626
  }
package/js/src/bybit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bybit.js';
2
- import { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Transaction, Ticker, OrderBook, Tickers } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Transaction, Ticker, OrderBook, Tickers, Greeks } from './base/types.js';
3
3
  /**
4
4
  * @class bybit
5
5
  * @extends Exchange
@@ -264,6 +264,28 @@ export default class bybit extends Exchange {
264
264
  parseSettlements(settlements: any, market: any): any[];
265
265
  fetchVolatilityHistory(code: string, params?: {}): Promise<any[]>;
266
266
  parseVolatilityHistory(volatility: any): any[];
267
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
268
+ parseGreeks(greeks: any, market?: any): {
269
+ symbol: any;
270
+ timestamp: any;
271
+ datetime: any;
272
+ delta: number;
273
+ gamma: number;
274
+ theta: number;
275
+ vega: number;
276
+ rho: any;
277
+ bidSize: number;
278
+ askSize: number;
279
+ bidImpliedVolatility: number;
280
+ askImpliedVolatility: number;
281
+ markImpliedVolatility: number;
282
+ bidPrice: number;
283
+ askPrice: number;
284
+ markPrice: number;
285
+ lastPrice: number;
286
+ underlyingPrice: number;
287
+ info: any;
288
+ };
267
289
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
268
290
  url: string;
269
291
  method: string;
package/js/src/bybit.js CHANGED
@@ -64,6 +64,7 @@ export default class bybit extends Exchange {
64
64
  'fetchFundingRate': true,
65
65
  'fetchFundingRateHistory': true,
66
66
  'fetchFundingRates': true,
67
+ 'fetchGreeks': true,
67
68
  'fetchIndexOHLCV': true,
68
69
  'fetchLedger': true,
69
70
  'fetchMarketLeverageTiers': true,
@@ -7273,6 +7274,126 @@ export default class bybit extends Exchange {
7273
7274
  }
7274
7275
  return result;
7275
7276
  }
7277
+ async fetchGreeks(symbol, params = {}) {
7278
+ /**
7279
+ * @method
7280
+ * @name bybit#fetchGreeks
7281
+ * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
7282
+ * @see https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers
7283
+ * @param {string} symbol unified symbol of the market to fetch greeks for
7284
+ * @param {object} [params] extra parameters specific to the bybit api endpoint
7285
+ * @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
7286
+ */
7287
+ await this.loadMarkets();
7288
+ const market = this.market(symbol);
7289
+ const request = {
7290
+ 'symbol': market['id'],
7291
+ 'category': 'option',
7292
+ };
7293
+ const response = await this.publicGetV5MarketTickers(this.extend(request, params));
7294
+ //
7295
+ // {
7296
+ // "retCode": 0,
7297
+ // "retMsg": "SUCCESS",
7298
+ // "result": {
7299
+ // "category": "option",
7300
+ // "list": [
7301
+ // {
7302
+ // "symbol": "BTC-26JAN24-39000-C",
7303
+ // "bid1Price": "3205",
7304
+ // "bid1Size": "7.1",
7305
+ // "bid1Iv": "0.5478",
7306
+ // "ask1Price": "3315",
7307
+ // "ask1Size": "1.98",
7308
+ // "ask1Iv": "0.5638",
7309
+ // "lastPrice": "3230",
7310
+ // "highPrice24h": "3255",
7311
+ // "lowPrice24h": "3200",
7312
+ // "markPrice": "3273.02263032",
7313
+ // "indexPrice": "36790.96",
7314
+ // "markIv": "0.5577",
7315
+ // "underlyingPrice": "37649.67254894",
7316
+ // "openInterest": "19.67",
7317
+ // "turnover24h": "170140.33875912",
7318
+ // "volume24h": "4.56",
7319
+ // "totalVolume": "22",
7320
+ // "totalTurnover": "789305",
7321
+ // "delta": "0.49640971",
7322
+ // "gamma": "0.00004131",
7323
+ // "vega": "69.08651675",
7324
+ // "theta": "-24.9443226",
7325
+ // "predictedDeliveryPrice": "0",
7326
+ // "change24h": "0.18532111"
7327
+ // }
7328
+ // ]
7329
+ // },
7330
+ // "retExtInfo": {},
7331
+ // "time": 1699584008326
7332
+ // }
7333
+ //
7334
+ const timestamp = this.safeInteger(response, 'time');
7335
+ const result = this.safeValue(response, 'result', {});
7336
+ const data = this.safeValue(result, 'list', []);
7337
+ const greeks = this.parseGreeks(data[0], market);
7338
+ return this.extend(greeks, {
7339
+ 'timestamp': timestamp,
7340
+ 'datetime': this.iso8601(timestamp),
7341
+ });
7342
+ }
7343
+ parseGreeks(greeks, market = undefined) {
7344
+ //
7345
+ // {
7346
+ // "symbol": "BTC-26JAN24-39000-C",
7347
+ // "bid1Price": "3205",
7348
+ // "bid1Size": "7.1",
7349
+ // "bid1Iv": "0.5478",
7350
+ // "ask1Price": "3315",
7351
+ // "ask1Size": "1.98",
7352
+ // "ask1Iv": "0.5638",
7353
+ // "lastPrice": "3230",
7354
+ // "highPrice24h": "3255",
7355
+ // "lowPrice24h": "3200",
7356
+ // "markPrice": "3273.02263032",
7357
+ // "indexPrice": "36790.96",
7358
+ // "markIv": "0.5577",
7359
+ // "underlyingPrice": "37649.67254894",
7360
+ // "openInterest": "19.67",
7361
+ // "turnover24h": "170140.33875912",
7362
+ // "volume24h": "4.56",
7363
+ // "totalVolume": "22",
7364
+ // "totalTurnover": "789305",
7365
+ // "delta": "0.49640971",
7366
+ // "gamma": "0.00004131",
7367
+ // "vega": "69.08651675",
7368
+ // "theta": "-24.9443226",
7369
+ // "predictedDeliveryPrice": "0",
7370
+ // "change24h": "0.18532111"
7371
+ // }
7372
+ //
7373
+ const marketId = this.safeString(greeks, 'symbol');
7374
+ const symbol = this.safeSymbol(marketId, market);
7375
+ return {
7376
+ 'symbol': symbol,
7377
+ 'timestamp': undefined,
7378
+ 'datetime': undefined,
7379
+ 'delta': this.safeNumber(greeks, 'delta'),
7380
+ 'gamma': this.safeNumber(greeks, 'gamma'),
7381
+ 'theta': this.safeNumber(greeks, 'theta'),
7382
+ 'vega': this.safeNumber(greeks, 'vega'),
7383
+ 'rho': undefined,
7384
+ 'bidSize': this.safeNumber(greeks, 'bid1Size'),
7385
+ 'askSize': this.safeNumber(greeks, 'ask1Size'),
7386
+ 'bidImpliedVolatility': this.safeNumber(greeks, 'bid1Iv'),
7387
+ 'askImpliedVolatility': this.safeNumber(greeks, 'ask1Iv'),
7388
+ 'markImpliedVolatility': this.safeNumber(greeks, 'markIv'),
7389
+ 'bidPrice': this.safeNumber(greeks, 'bid1Price'),
7390
+ 'askPrice': this.safeNumber(greeks, 'ask1Price'),
7391
+ 'markPrice': this.safeNumber(greeks, 'markPrice'),
7392
+ 'lastPrice': this.safeNumber(greeks, 'lastPrice'),
7393
+ 'underlyingPrice': this.safeNumber(greeks, 'underlyingPrice'),
7394
+ 'info': greeks,
7395
+ };
7396
+ }
7276
7397
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
7277
7398
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
7278
7399
  if (api === 'public') {
@@ -58,6 +58,7 @@ export default class cryptocom extends Exchange {
58
58
  'fetchFundingRate': false,
59
59
  'fetchFundingRateHistory': true,
60
60
  'fetchFundingRates': false,
61
+ 'fetchGreeks': false,
61
62
  'fetchIndexOHLCV': false,
62
63
  'fetchLedger': true,
63
64
  'fetchLeverage': false,
package/js/src/delta.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/delta.js';
2
- import { Balances, Int, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade } from './base/types.js';
2
+ import { Balances, Greeks, Int, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade } from './base/types.js';
3
3
  /**
4
4
  * @class delta
5
5
  * @extends Exchange
@@ -208,6 +208,28 @@ export default class delta extends Exchange {
208
208
  datetime: string;
209
209
  };
210
210
  parseSettlements(settlements: any, market: any): any[];
211
+ fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
212
+ parseGreeks(greeks: any, market?: any): {
213
+ symbol: any;
214
+ timestamp: number;
215
+ datetime: string;
216
+ delta: number;
217
+ gamma: number;
218
+ theta: number;
219
+ vega: number;
220
+ rho: number;
221
+ bidSize: number;
222
+ askSize: number;
223
+ bidImpliedVolatility: number;
224
+ askImpliedVolatility: number;
225
+ markImpliedVolatility: number;
226
+ bidPrice: number;
227
+ askPrice: number;
228
+ markPrice: number;
229
+ lastPrice: any;
230
+ underlyingPrice: number;
231
+ info: any;
232
+ };
211
233
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
212
234
  url: string;
213
235
  method: string;