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.
- package/README.md +3 -3
- package/dist/ccxt.browser.js +1040 -153
- package/dist/ccxt.browser.min.js +6 -6
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/binance.js +76 -0
- package/dist/cjs/src/bybit.js +121 -0
- package/dist/cjs/src/cryptocom.js +1 -0
- package/dist/cjs/src/delta.js +149 -0
- package/dist/cjs/src/deribit.js +132 -0
- package/dist/cjs/src/gate.js +102 -4
- package/dist/cjs/src/htx.js +313 -135
- package/dist/cjs/src/kraken.js +7 -10
- package/dist/cjs/src/okx.js +108 -0
- package/dist/cjs/src/pro/krakenfutures.js +24 -3
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/htx.d.ts +1 -1
- package/js/src/abstract/huobi.d.ts +1 -1
- package/js/src/abstract/huobipro.d.ts +1 -1
- package/js/src/abstract/kraken.d.ts +0 -5
- package/js/src/base/Exchange.d.ts +4 -2
- package/js/src/base/Exchange.js +6 -0
- package/js/src/base/types.d.ts +21 -0
- package/js/src/binance.d.ts +23 -1
- package/js/src/binance.js +76 -0
- package/js/src/bybit.d.ts +23 -1
- package/js/src/bybit.js +121 -0
- package/js/src/cryptocom.js +1 -0
- package/js/src/delta.d.ts +23 -1
- package/js/src/delta.js +149 -0
- package/js/src/deribit.d.ts +23 -1
- package/js/src/deribit.js +132 -0
- package/js/src/gate.d.ts +23 -1
- package/js/src/gate.js +102 -4
- package/js/src/htx.d.ts +4 -3
- package/js/src/htx.js +313 -135
- package/js/src/kraken.js +7 -10
- package/js/src/okx.d.ts +23 -1
- package/js/src/okx.js +108 -0
- package/js/src/pro/krakenfutures.js +24 -3
- package/package.json +1 -1
- package/skip-tests.json +2 -0
package/dist/cjs/ccxt.js
CHANGED
|
@@ -183,7 +183,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
183
183
|
|
|
184
184
|
//-----------------------------------------------------------------------------
|
|
185
185
|
// this is updated by vss.js when building
|
|
186
|
-
const version = '4.1.
|
|
186
|
+
const version = '4.1.51';
|
|
187
187
|
Exchange["default"].ccxtVersion = version;
|
|
188
188
|
const exchanges = {
|
|
189
189
|
'ace': ace,
|
|
@@ -3444,6 +3444,9 @@ class Exchange {
|
|
|
3444
3444
|
async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
3445
3445
|
throw new errors.NotSupported(this.id + ' fetchOHLCVWs() is not supported yet');
|
|
3446
3446
|
}
|
|
3447
|
+
async fetchGreeks(symbol, params = {}) {
|
|
3448
|
+
throw new errors.NotSupported(this.id + ' fetchGreeks() is not supported yet');
|
|
3449
|
+
}
|
|
3447
3450
|
async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3448
3451
|
/**
|
|
3449
3452
|
* @method
|
|
@@ -4604,6 +4607,9 @@ class Exchange {
|
|
|
4604
4607
|
const symbol = this.safeString(market, 'symbol');
|
|
4605
4608
|
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
4606
4609
|
}
|
|
4610
|
+
parseGreeks(greeks, market = undefined) {
|
|
4611
|
+
throw new errors.NotSupported(this.id + ' parseGreeks () is not supported yet');
|
|
4612
|
+
}
|
|
4607
4613
|
}
|
|
4608
4614
|
|
|
4609
4615
|
exports.Exchange = Exchange;
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -71,6 +71,7 @@ class binance extends binance$1 {
|
|
|
71
71
|
'fetchFundingRate': true,
|
|
72
72
|
'fetchFundingRateHistory': true,
|
|
73
73
|
'fetchFundingRates': true,
|
|
74
|
+
'fetchGreeks': true,
|
|
74
75
|
'fetchIndexOHLCV': true,
|
|
75
76
|
'fetchL3OrderBook': false,
|
|
76
77
|
'fetchLastPrices': true,
|
|
@@ -9544,6 +9545,81 @@ class binance extends binance$1 {
|
|
|
9544
9545
|
'datetime': this.iso8601(timestamp),
|
|
9545
9546
|
});
|
|
9546
9547
|
}
|
|
9548
|
+
async fetchGreeks(symbol, params = {}) {
|
|
9549
|
+
/**
|
|
9550
|
+
* @method
|
|
9551
|
+
* @name binance#fetchGreeks
|
|
9552
|
+
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
9553
|
+
* @see https://binance-docs.github.io/apidocs/voptions/en/#option-mark-price
|
|
9554
|
+
* @param {string} symbol unified symbol of the market to fetch greeks for
|
|
9555
|
+
* @param {object} [params] extra parameters specific to the binance api endpoint
|
|
9556
|
+
* @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
|
|
9557
|
+
*/
|
|
9558
|
+
await this.loadMarkets();
|
|
9559
|
+
const market = this.market(symbol);
|
|
9560
|
+
const request = {
|
|
9561
|
+
'symbol': market['id'],
|
|
9562
|
+
};
|
|
9563
|
+
const response = await this.eapiPublicGetMark(this.extend(request, params));
|
|
9564
|
+
//
|
|
9565
|
+
// [
|
|
9566
|
+
// {
|
|
9567
|
+
// "symbol": "BTC-231229-40000-C",
|
|
9568
|
+
// "markPrice": "2012",
|
|
9569
|
+
// "bidIV": "0.60236275",
|
|
9570
|
+
// "askIV": "0.62267244",
|
|
9571
|
+
// "markIV": "0.6125176",
|
|
9572
|
+
// "delta": "0.39111646",
|
|
9573
|
+
// "theta": "-32.13948531",
|
|
9574
|
+
// "gamma": "0.00004656",
|
|
9575
|
+
// "vega": "51.70062218",
|
|
9576
|
+
// "highPriceLimit": "6474",
|
|
9577
|
+
// "lowPriceLimit": "5"
|
|
9578
|
+
// }
|
|
9579
|
+
// ]
|
|
9580
|
+
//
|
|
9581
|
+
return this.parseGreeks(response[0], market);
|
|
9582
|
+
}
|
|
9583
|
+
parseGreeks(greeks, market = undefined) {
|
|
9584
|
+
//
|
|
9585
|
+
// {
|
|
9586
|
+
// "symbol": "BTC-231229-40000-C",
|
|
9587
|
+
// "markPrice": "2012",
|
|
9588
|
+
// "bidIV": "0.60236275",
|
|
9589
|
+
// "askIV": "0.62267244",
|
|
9590
|
+
// "markIV": "0.6125176",
|
|
9591
|
+
// "delta": "0.39111646",
|
|
9592
|
+
// "theta": "-32.13948531",
|
|
9593
|
+
// "gamma": "0.00004656",
|
|
9594
|
+
// "vega": "51.70062218",
|
|
9595
|
+
// "highPriceLimit": "6474",
|
|
9596
|
+
// "lowPriceLimit": "5"
|
|
9597
|
+
// }
|
|
9598
|
+
//
|
|
9599
|
+
const marketId = this.safeString(greeks, 'symbol');
|
|
9600
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
9601
|
+
return {
|
|
9602
|
+
'symbol': symbol,
|
|
9603
|
+
'timestamp': undefined,
|
|
9604
|
+
'datetime': undefined,
|
|
9605
|
+
'delta': this.safeNumber(greeks, 'delta'),
|
|
9606
|
+
'gamma': this.safeNumber(greeks, 'gamma'),
|
|
9607
|
+
'theta': this.safeNumber(greeks, 'theta'),
|
|
9608
|
+
'vega': this.safeNumber(greeks, 'vega'),
|
|
9609
|
+
'rho': undefined,
|
|
9610
|
+
'bidSize': undefined,
|
|
9611
|
+
'askSize': undefined,
|
|
9612
|
+
'bidImpliedVolatility': this.safeNumber(greeks, 'bidIV'),
|
|
9613
|
+
'askImpliedVolatility': this.safeNumber(greeks, 'askIV'),
|
|
9614
|
+
'markImpliedVolatility': this.safeNumber(greeks, 'markIV'),
|
|
9615
|
+
'bidPrice': undefined,
|
|
9616
|
+
'askPrice': undefined,
|
|
9617
|
+
'markPrice': this.safeNumber(greeks, 'markPrice'),
|
|
9618
|
+
'lastPrice': undefined,
|
|
9619
|
+
'underlyingPrice': undefined,
|
|
9620
|
+
'info': greeks,
|
|
9621
|
+
};
|
|
9622
|
+
}
|
|
9547
9623
|
}
|
|
9548
9624
|
|
|
9549
9625
|
module.exports = binance;
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -61,6 +61,7 @@ class bybit extends bybit$1 {
|
|
|
61
61
|
'fetchFundingRate': true,
|
|
62
62
|
'fetchFundingRateHistory': true,
|
|
63
63
|
'fetchFundingRates': true,
|
|
64
|
+
'fetchGreeks': true,
|
|
64
65
|
'fetchIndexOHLCV': true,
|
|
65
66
|
'fetchLedger': true,
|
|
66
67
|
'fetchMarketLeverageTiers': true,
|
|
@@ -7266,6 +7267,126 @@ class bybit extends bybit$1 {
|
|
|
7266
7267
|
}
|
|
7267
7268
|
return result;
|
|
7268
7269
|
}
|
|
7270
|
+
async fetchGreeks(symbol, params = {}) {
|
|
7271
|
+
/**
|
|
7272
|
+
* @method
|
|
7273
|
+
* @name bybit#fetchGreeks
|
|
7274
|
+
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
7275
|
+
* @see https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers
|
|
7276
|
+
* @param {string} symbol unified symbol of the market to fetch greeks for
|
|
7277
|
+
* @param {object} [params] extra parameters specific to the bybit api endpoint
|
|
7278
|
+
* @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
|
|
7279
|
+
*/
|
|
7280
|
+
await this.loadMarkets();
|
|
7281
|
+
const market = this.market(symbol);
|
|
7282
|
+
const request = {
|
|
7283
|
+
'symbol': market['id'],
|
|
7284
|
+
'category': 'option',
|
|
7285
|
+
};
|
|
7286
|
+
const response = await this.publicGetV5MarketTickers(this.extend(request, params));
|
|
7287
|
+
//
|
|
7288
|
+
// {
|
|
7289
|
+
// "retCode": 0,
|
|
7290
|
+
// "retMsg": "SUCCESS",
|
|
7291
|
+
// "result": {
|
|
7292
|
+
// "category": "option",
|
|
7293
|
+
// "list": [
|
|
7294
|
+
// {
|
|
7295
|
+
// "symbol": "BTC-26JAN24-39000-C",
|
|
7296
|
+
// "bid1Price": "3205",
|
|
7297
|
+
// "bid1Size": "7.1",
|
|
7298
|
+
// "bid1Iv": "0.5478",
|
|
7299
|
+
// "ask1Price": "3315",
|
|
7300
|
+
// "ask1Size": "1.98",
|
|
7301
|
+
// "ask1Iv": "0.5638",
|
|
7302
|
+
// "lastPrice": "3230",
|
|
7303
|
+
// "highPrice24h": "3255",
|
|
7304
|
+
// "lowPrice24h": "3200",
|
|
7305
|
+
// "markPrice": "3273.02263032",
|
|
7306
|
+
// "indexPrice": "36790.96",
|
|
7307
|
+
// "markIv": "0.5577",
|
|
7308
|
+
// "underlyingPrice": "37649.67254894",
|
|
7309
|
+
// "openInterest": "19.67",
|
|
7310
|
+
// "turnover24h": "170140.33875912",
|
|
7311
|
+
// "volume24h": "4.56",
|
|
7312
|
+
// "totalVolume": "22",
|
|
7313
|
+
// "totalTurnover": "789305",
|
|
7314
|
+
// "delta": "0.49640971",
|
|
7315
|
+
// "gamma": "0.00004131",
|
|
7316
|
+
// "vega": "69.08651675",
|
|
7317
|
+
// "theta": "-24.9443226",
|
|
7318
|
+
// "predictedDeliveryPrice": "0",
|
|
7319
|
+
// "change24h": "0.18532111"
|
|
7320
|
+
// }
|
|
7321
|
+
// ]
|
|
7322
|
+
// },
|
|
7323
|
+
// "retExtInfo": {},
|
|
7324
|
+
// "time": 1699584008326
|
|
7325
|
+
// }
|
|
7326
|
+
//
|
|
7327
|
+
const timestamp = this.safeInteger(response, 'time');
|
|
7328
|
+
const result = this.safeValue(response, 'result', {});
|
|
7329
|
+
const data = this.safeValue(result, 'list', []);
|
|
7330
|
+
const greeks = this.parseGreeks(data[0], market);
|
|
7331
|
+
return this.extend(greeks, {
|
|
7332
|
+
'timestamp': timestamp,
|
|
7333
|
+
'datetime': this.iso8601(timestamp),
|
|
7334
|
+
});
|
|
7335
|
+
}
|
|
7336
|
+
parseGreeks(greeks, market = undefined) {
|
|
7337
|
+
//
|
|
7338
|
+
// {
|
|
7339
|
+
// "symbol": "BTC-26JAN24-39000-C",
|
|
7340
|
+
// "bid1Price": "3205",
|
|
7341
|
+
// "bid1Size": "7.1",
|
|
7342
|
+
// "bid1Iv": "0.5478",
|
|
7343
|
+
// "ask1Price": "3315",
|
|
7344
|
+
// "ask1Size": "1.98",
|
|
7345
|
+
// "ask1Iv": "0.5638",
|
|
7346
|
+
// "lastPrice": "3230",
|
|
7347
|
+
// "highPrice24h": "3255",
|
|
7348
|
+
// "lowPrice24h": "3200",
|
|
7349
|
+
// "markPrice": "3273.02263032",
|
|
7350
|
+
// "indexPrice": "36790.96",
|
|
7351
|
+
// "markIv": "0.5577",
|
|
7352
|
+
// "underlyingPrice": "37649.67254894",
|
|
7353
|
+
// "openInterest": "19.67",
|
|
7354
|
+
// "turnover24h": "170140.33875912",
|
|
7355
|
+
// "volume24h": "4.56",
|
|
7356
|
+
// "totalVolume": "22",
|
|
7357
|
+
// "totalTurnover": "789305",
|
|
7358
|
+
// "delta": "0.49640971",
|
|
7359
|
+
// "gamma": "0.00004131",
|
|
7360
|
+
// "vega": "69.08651675",
|
|
7361
|
+
// "theta": "-24.9443226",
|
|
7362
|
+
// "predictedDeliveryPrice": "0",
|
|
7363
|
+
// "change24h": "0.18532111"
|
|
7364
|
+
// }
|
|
7365
|
+
//
|
|
7366
|
+
const marketId = this.safeString(greeks, 'symbol');
|
|
7367
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
7368
|
+
return {
|
|
7369
|
+
'symbol': symbol,
|
|
7370
|
+
'timestamp': undefined,
|
|
7371
|
+
'datetime': undefined,
|
|
7372
|
+
'delta': this.safeNumber(greeks, 'delta'),
|
|
7373
|
+
'gamma': this.safeNumber(greeks, 'gamma'),
|
|
7374
|
+
'theta': this.safeNumber(greeks, 'theta'),
|
|
7375
|
+
'vega': this.safeNumber(greeks, 'vega'),
|
|
7376
|
+
'rho': undefined,
|
|
7377
|
+
'bidSize': this.safeNumber(greeks, 'bid1Size'),
|
|
7378
|
+
'askSize': this.safeNumber(greeks, 'ask1Size'),
|
|
7379
|
+
'bidImpliedVolatility': this.safeNumber(greeks, 'bid1Iv'),
|
|
7380
|
+
'askImpliedVolatility': this.safeNumber(greeks, 'ask1Iv'),
|
|
7381
|
+
'markImpliedVolatility': this.safeNumber(greeks, 'markIv'),
|
|
7382
|
+
'bidPrice': this.safeNumber(greeks, 'bid1Price'),
|
|
7383
|
+
'askPrice': this.safeNumber(greeks, 'ask1Price'),
|
|
7384
|
+
'markPrice': this.safeNumber(greeks, 'markPrice'),
|
|
7385
|
+
'lastPrice': this.safeNumber(greeks, 'lastPrice'),
|
|
7386
|
+
'underlyingPrice': this.safeNumber(greeks, 'underlyingPrice'),
|
|
7387
|
+
'info': greeks,
|
|
7388
|
+
};
|
|
7389
|
+
}
|
|
7269
7390
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
7270
7391
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
7271
7392
|
if (api === 'public') {
|
package/dist/cjs/src/delta.js
CHANGED
|
@@ -44,6 +44,7 @@ class delta extends delta$1 {
|
|
|
44
44
|
'fetchFundingRate': true,
|
|
45
45
|
'fetchFundingRateHistory': false,
|
|
46
46
|
'fetchFundingRates': true,
|
|
47
|
+
'fetchGreeks': true,
|
|
47
48
|
'fetchIndexOHLCV': true,
|
|
48
49
|
'fetchLedger': true,
|
|
49
50
|
'fetchLeverage': true,
|
|
@@ -3020,6 +3021,154 @@ class delta extends delta$1 {
|
|
|
3020
3021
|
}
|
|
3021
3022
|
return result;
|
|
3022
3023
|
}
|
|
3024
|
+
async fetchGreeks(symbol, params = {}) {
|
|
3025
|
+
/**
|
|
3026
|
+
* @method
|
|
3027
|
+
* @name delta#fetchGreeks
|
|
3028
|
+
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
3029
|
+
* @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
|
3030
|
+
* @param {string} symbol unified symbol of the market to fetch greeks for
|
|
3031
|
+
* @param {object} [params] extra parameters specific to the delta api endpoint
|
|
3032
|
+
* @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
|
|
3033
|
+
*/
|
|
3034
|
+
await this.loadMarkets();
|
|
3035
|
+
const market = this.market(symbol);
|
|
3036
|
+
const request = {
|
|
3037
|
+
'symbol': market['id'],
|
|
3038
|
+
};
|
|
3039
|
+
const response = await this.publicGetTickersSymbol(this.extend(request, params));
|
|
3040
|
+
//
|
|
3041
|
+
// {
|
|
3042
|
+
// "result": {
|
|
3043
|
+
// "close": 6793.0,
|
|
3044
|
+
// "contract_type": "call_options",
|
|
3045
|
+
// "greeks": {
|
|
3046
|
+
// "delta": "0.94739174",
|
|
3047
|
+
// "gamma": "0.00002206",
|
|
3048
|
+
// "rho": "11.00890725",
|
|
3049
|
+
// "spot": "36839.58124652",
|
|
3050
|
+
// "theta": "-18.18365310",
|
|
3051
|
+
// "vega": "7.85209698"
|
|
3052
|
+
// },
|
|
3053
|
+
// "high": 7556.0,
|
|
3054
|
+
// "low": 6793.0,
|
|
3055
|
+
// "mark_price": "6955.70698909",
|
|
3056
|
+
// "mark_vol": "0.66916863",
|
|
3057
|
+
// "oi": "1.8980",
|
|
3058
|
+
// "oi_change_usd_6h": "110.4600",
|
|
3059
|
+
// "oi_contracts": "1898",
|
|
3060
|
+
// "oi_value": "1.8980",
|
|
3061
|
+
// "oi_value_symbol": "BTC",
|
|
3062
|
+
// "oi_value_usd": "69940.7319",
|
|
3063
|
+
// "open": 7.2e3,
|
|
3064
|
+
// "price_band": {
|
|
3065
|
+
// "lower_limit": "5533.89814767",
|
|
3066
|
+
// "upper_limit": "11691.37688371"
|
|
3067
|
+
// },
|
|
3068
|
+
// "product_id": 129508,
|
|
3069
|
+
// "quotes": {
|
|
3070
|
+
// "ask_iv": "0.90180438",
|
|
3071
|
+
// "ask_size": "1898",
|
|
3072
|
+
// "best_ask": "7210",
|
|
3073
|
+
// "best_bid": "6913",
|
|
3074
|
+
// "bid_iv": "0.60881706",
|
|
3075
|
+
// "bid_size": "3163",
|
|
3076
|
+
// "impact_mid_price": null,
|
|
3077
|
+
// "mark_iv": "0.66973549"
|
|
3078
|
+
// },
|
|
3079
|
+
// "size": 5,
|
|
3080
|
+
// "spot_price": "36839.58153868",
|
|
3081
|
+
// "strike_price": "30000",
|
|
3082
|
+
// "symbol": "C-BTC-30000-241123",
|
|
3083
|
+
// "timestamp": 1699584998504530,
|
|
3084
|
+
// "turnover": 184.41206804,
|
|
3085
|
+
// "turnover_symbol": "USDT",
|
|
3086
|
+
// "turnover_usd": 184.41206804,
|
|
3087
|
+
// "volume": 0.005
|
|
3088
|
+
// },
|
|
3089
|
+
// "success": true
|
|
3090
|
+
// }
|
|
3091
|
+
//
|
|
3092
|
+
const result = this.safeValue(response, 'result', {});
|
|
3093
|
+
return this.parseGreeks(result, market);
|
|
3094
|
+
}
|
|
3095
|
+
parseGreeks(greeks, market = undefined) {
|
|
3096
|
+
//
|
|
3097
|
+
// {
|
|
3098
|
+
// "close": 6793.0,
|
|
3099
|
+
// "contract_type": "call_options",
|
|
3100
|
+
// "greeks": {
|
|
3101
|
+
// "delta": "0.94739174",
|
|
3102
|
+
// "gamma": "0.00002206",
|
|
3103
|
+
// "rho": "11.00890725",
|
|
3104
|
+
// "spot": "36839.58124652",
|
|
3105
|
+
// "theta": "-18.18365310",
|
|
3106
|
+
// "vega": "7.85209698"
|
|
3107
|
+
// },
|
|
3108
|
+
// "high": 7556.0,
|
|
3109
|
+
// "low": 6793.0,
|
|
3110
|
+
// "mark_price": "6955.70698909",
|
|
3111
|
+
// "mark_vol": "0.66916863",
|
|
3112
|
+
// "oi": "1.8980",
|
|
3113
|
+
// "oi_change_usd_6h": "110.4600",
|
|
3114
|
+
// "oi_contracts": "1898",
|
|
3115
|
+
// "oi_value": "1.8980",
|
|
3116
|
+
// "oi_value_symbol": "BTC",
|
|
3117
|
+
// "oi_value_usd": "69940.7319",
|
|
3118
|
+
// "open": 7.2e3,
|
|
3119
|
+
// "price_band": {
|
|
3120
|
+
// "lower_limit": "5533.89814767",
|
|
3121
|
+
// "upper_limit": "11691.37688371"
|
|
3122
|
+
// },
|
|
3123
|
+
// "product_id": 129508,
|
|
3124
|
+
// "quotes": {
|
|
3125
|
+
// "ask_iv": "0.90180438",
|
|
3126
|
+
// "ask_size": "1898",
|
|
3127
|
+
// "best_ask": "7210",
|
|
3128
|
+
// "best_bid": "6913",
|
|
3129
|
+
// "bid_iv": "0.60881706",
|
|
3130
|
+
// "bid_size": "3163",
|
|
3131
|
+
// "impact_mid_price": null,
|
|
3132
|
+
// "mark_iv": "0.66973549"
|
|
3133
|
+
// },
|
|
3134
|
+
// "size": 5,
|
|
3135
|
+
// "spot_price": "36839.58153868",
|
|
3136
|
+
// "strike_price": "30000",
|
|
3137
|
+
// "symbol": "C-BTC-30000-241123",
|
|
3138
|
+
// "timestamp": 1699584998504530,
|
|
3139
|
+
// "turnover": 184.41206804,
|
|
3140
|
+
// "turnover_symbol": "USDT",
|
|
3141
|
+
// "turnover_usd": 184.41206804,
|
|
3142
|
+
// "volume": 0.005
|
|
3143
|
+
// }
|
|
3144
|
+
//
|
|
3145
|
+
const timestamp = this.safeIntegerProduct(greeks, 'timestamp', 0.001);
|
|
3146
|
+
const marketId = this.safeString(greeks, 'symbol');
|
|
3147
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
3148
|
+
const stats = this.safeValue(greeks, 'greeks', {});
|
|
3149
|
+
const quotes = this.safeValue(greeks, 'quotes', {});
|
|
3150
|
+
return {
|
|
3151
|
+
'symbol': symbol,
|
|
3152
|
+
'timestamp': timestamp,
|
|
3153
|
+
'datetime': this.iso8601(timestamp),
|
|
3154
|
+
'delta': this.safeNumber(stats, 'delta'),
|
|
3155
|
+
'gamma': this.safeNumber(stats, 'gamma'),
|
|
3156
|
+
'theta': this.safeNumber(stats, 'theta'),
|
|
3157
|
+
'vega': this.safeNumber(stats, 'vega'),
|
|
3158
|
+
'rho': this.safeNumber(stats, 'rho'),
|
|
3159
|
+
'bidSize': this.safeNumber(quotes, 'bid_size'),
|
|
3160
|
+
'askSize': this.safeNumber(quotes, 'ask_size'),
|
|
3161
|
+
'bidImpliedVolatility': this.safeNumber(quotes, 'bid_iv'),
|
|
3162
|
+
'askImpliedVolatility': this.safeNumber(quotes, 'ask_iv'),
|
|
3163
|
+
'markImpliedVolatility': this.safeNumber(quotes, 'mark_iv'),
|
|
3164
|
+
'bidPrice': this.safeNumber(quotes, 'best_bid'),
|
|
3165
|
+
'askPrice': this.safeNumber(quotes, 'best_ask'),
|
|
3166
|
+
'markPrice': this.safeNumber(greeks, 'mark_price'),
|
|
3167
|
+
'lastPrice': undefined,
|
|
3168
|
+
'underlyingPrice': this.safeNumber(greeks, 'spot_price'),
|
|
3169
|
+
'info': greeks,
|
|
3170
|
+
};
|
|
3171
|
+
}
|
|
3023
3172
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3024
3173
|
const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
|
|
3025
3174
|
let url = this.urls['api'][api] + requestPath;
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -56,6 +56,7 @@ class deribit extends deribit$1 {
|
|
|
56
56
|
'fetchDepositWithdrawFees': true,
|
|
57
57
|
'fetchFundingRate': true,
|
|
58
58
|
'fetchFundingRateHistory': true,
|
|
59
|
+
'fetchGreeks': true,
|
|
59
60
|
'fetchIndexOHLCV': false,
|
|
60
61
|
'fetchLeverageTiers': false,
|
|
61
62
|
'fetchLiquidations': true,
|
|
@@ -3079,6 +3080,137 @@ class deribit extends deribit$1 {
|
|
|
3079
3080
|
'datetime': this.iso8601(timestamp),
|
|
3080
3081
|
});
|
|
3081
3082
|
}
|
|
3083
|
+
async fetchGreeks(symbol, params = {}) {
|
|
3084
|
+
/**
|
|
3085
|
+
* @method
|
|
3086
|
+
* @name deribit#fetchGreeks
|
|
3087
|
+
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
|
3088
|
+
* @see https://docs.deribit.com/#public-ticker
|
|
3089
|
+
* @param {string} symbol unified symbol of the market to fetch greeks for
|
|
3090
|
+
* @param {object} [params] extra parameters specific to the deribit api endpoint
|
|
3091
|
+
* @returns {object} a [greeks structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#greeks-structure}
|
|
3092
|
+
*/
|
|
3093
|
+
await this.loadMarkets();
|
|
3094
|
+
const market = this.market(symbol);
|
|
3095
|
+
const request = {
|
|
3096
|
+
'instrument_name': market['id'],
|
|
3097
|
+
};
|
|
3098
|
+
const response = await this.publicGetTicker(this.extend(request, params));
|
|
3099
|
+
//
|
|
3100
|
+
// {
|
|
3101
|
+
// "jsonrpc": "2.0",
|
|
3102
|
+
// "result": {
|
|
3103
|
+
// "estimated_delivery_price": 36552.72,
|
|
3104
|
+
// "best_bid_amount": 0.2,
|
|
3105
|
+
// "best_ask_amount": 9.1,
|
|
3106
|
+
// "interest_rate": 0.0,
|
|
3107
|
+
// "best_bid_price": 0.214,
|
|
3108
|
+
// "best_ask_price": 0.219,
|
|
3109
|
+
// "open_interest": 368.8,
|
|
3110
|
+
// "settlement_price": 0.22103022,
|
|
3111
|
+
// "last_price": 0.215,
|
|
3112
|
+
// "bid_iv": 60.51,
|
|
3113
|
+
// "ask_iv": 61.88,
|
|
3114
|
+
// "mark_iv": 61.27,
|
|
3115
|
+
// "underlying_index": "BTC-27SEP24",
|
|
3116
|
+
// "underlying_price": 38992.71,
|
|
3117
|
+
// "min_price": 0.1515,
|
|
3118
|
+
// "max_price": 0.326,
|
|
3119
|
+
// "mark_price": 0.2168,
|
|
3120
|
+
// "instrument_name": "BTC-27SEP24-40000-C",
|
|
3121
|
+
// "index_price": 36552.72,
|
|
3122
|
+
// "greeks": {
|
|
3123
|
+
// "rho": 130.63998,
|
|
3124
|
+
// "theta": -13.48784,
|
|
3125
|
+
// "vega": 141.90146,
|
|
3126
|
+
// "gamma": 0.00002,
|
|
3127
|
+
// "delta": 0.59621
|
|
3128
|
+
// },
|
|
3129
|
+
// "stats": {
|
|
3130
|
+
// "volume_usd": 100453.9,
|
|
3131
|
+
// "volume": 12.0,
|
|
3132
|
+
// "price_change": -2.2727,
|
|
3133
|
+
// "low": 0.2065,
|
|
3134
|
+
// "high": 0.238
|
|
3135
|
+
// },
|
|
3136
|
+
// "state": "open",
|
|
3137
|
+
// "timestamp": 1699578548021
|
|
3138
|
+
// },
|
|
3139
|
+
// "usIn": 1699578548308414,
|
|
3140
|
+
// "usOut": 1699578548308606,
|
|
3141
|
+
// "usDiff": 192,
|
|
3142
|
+
// "testnet": false
|
|
3143
|
+
// }
|
|
3144
|
+
//
|
|
3145
|
+
const result = this.safeValue(response, 'result', {});
|
|
3146
|
+
return this.parseGreeks(result, market);
|
|
3147
|
+
}
|
|
3148
|
+
parseGreeks(greeks, market = undefined) {
|
|
3149
|
+
//
|
|
3150
|
+
// {
|
|
3151
|
+
// "estimated_delivery_price": 36552.72,
|
|
3152
|
+
// "best_bid_amount": 0.2,
|
|
3153
|
+
// "best_ask_amount": 9.1,
|
|
3154
|
+
// "interest_rate": 0.0,
|
|
3155
|
+
// "best_bid_price": 0.214,
|
|
3156
|
+
// "best_ask_price": 0.219,
|
|
3157
|
+
// "open_interest": 368.8,
|
|
3158
|
+
// "settlement_price": 0.22103022,
|
|
3159
|
+
// "last_price": 0.215,
|
|
3160
|
+
// "bid_iv": 60.51,
|
|
3161
|
+
// "ask_iv": 61.88,
|
|
3162
|
+
// "mark_iv": 61.27,
|
|
3163
|
+
// "underlying_index": "BTC-27SEP24",
|
|
3164
|
+
// "underlying_price": 38992.71,
|
|
3165
|
+
// "min_price": 0.1515,
|
|
3166
|
+
// "max_price": 0.326,
|
|
3167
|
+
// "mark_price": 0.2168,
|
|
3168
|
+
// "instrument_name": "BTC-27SEP24-40000-C",
|
|
3169
|
+
// "index_price": 36552.72,
|
|
3170
|
+
// "greeks": {
|
|
3171
|
+
// "rho": 130.63998,
|
|
3172
|
+
// "theta": -13.48784,
|
|
3173
|
+
// "vega": 141.90146,
|
|
3174
|
+
// "gamma": 0.00002,
|
|
3175
|
+
// "delta": 0.59621
|
|
3176
|
+
// },
|
|
3177
|
+
// "stats": {
|
|
3178
|
+
// "volume_usd": 100453.9,
|
|
3179
|
+
// "volume": 12.0,
|
|
3180
|
+
// "price_change": -2.2727,
|
|
3181
|
+
// "low": 0.2065,
|
|
3182
|
+
// "high": 0.238
|
|
3183
|
+
// },
|
|
3184
|
+
// "state": "open",
|
|
3185
|
+
// "timestamp": 1699578548021
|
|
3186
|
+
// }
|
|
3187
|
+
//
|
|
3188
|
+
const timestamp = this.safeInteger(greeks, 'timestamp');
|
|
3189
|
+
const marketId = this.safeString(greeks, 'instrument_name');
|
|
3190
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
3191
|
+
const stats = this.safeValue(greeks, 'greeks', {});
|
|
3192
|
+
return {
|
|
3193
|
+
'symbol': symbol,
|
|
3194
|
+
'timestamp': timestamp,
|
|
3195
|
+
'datetime': this.iso8601(timestamp),
|
|
3196
|
+
'delta': this.safeNumber(stats, 'delta'),
|
|
3197
|
+
'gamma': this.safeNumber(stats, 'gamma'),
|
|
3198
|
+
'theta': this.safeNumber(stats, 'theta'),
|
|
3199
|
+
'vega': this.safeNumber(stats, 'vega'),
|
|
3200
|
+
'rho': this.safeNumber(stats, 'rho'),
|
|
3201
|
+
'bidSize': this.safeNumber(greeks, 'best_bid_amount'),
|
|
3202
|
+
'askSize': this.safeNumber(greeks, 'best_ask_amount'),
|
|
3203
|
+
'bidImpliedVolatility': this.safeNumber(greeks, 'bid_iv'),
|
|
3204
|
+
'askImpliedVolatility': this.safeNumber(greeks, 'ask_iv'),
|
|
3205
|
+
'markImpliedVolatility': this.safeNumber(greeks, 'mark_iv'),
|
|
3206
|
+
'bidPrice': this.safeNumber(greeks, 'best_bid_price'),
|
|
3207
|
+
'askPrice': this.safeNumber(greeks, 'best_ask_price'),
|
|
3208
|
+
'markPrice': this.safeNumber(greeks, 'mark_price'),
|
|
3209
|
+
'lastPrice': this.safeNumber(greeks, 'last_price'),
|
|
3210
|
+
'underlyingPrice': this.safeNumber(greeks, 'underlying_price'),
|
|
3211
|
+
'info': greeks,
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3082
3214
|
nonce() {
|
|
3083
3215
|
return this.milliseconds();
|
|
3084
3216
|
}
|