ccxt 4.2.80 → 4.2.82

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/dist/cjs/ccxt.js CHANGED
@@ -181,7 +181,7 @@ var woo$1 = require('./src/pro/woo.js');
181
181
 
182
182
  //-----------------------------------------------------------------------------
183
183
  // this is updated by vss.js when building
184
- const version = '4.2.80';
184
+ const version = '4.2.82';
185
185
  Exchange["default"].ccxtVersion = version;
186
186
  const exchanges = {
187
187
  'ace': ace,
@@ -111,6 +111,8 @@ class binance extends binance$1 {
111
111
  'fetchOpenInterestHistory': true,
112
112
  'fetchOpenOrder': true,
113
113
  'fetchOpenOrders': true,
114
+ 'fetchOption': true,
115
+ 'fetchOptionChain': false,
114
116
  'fetchOrder': true,
115
117
  'fetchOrderBook': true,
116
118
  'fetchOrderBooks': false,
@@ -12408,6 +12410,94 @@ class binance extends binance$1 {
12408
12410
  'marginMode': isIsolated ? 'isolated' : 'cross',
12409
12411
  };
12410
12412
  }
12413
+ async fetchOption(symbol, params = {}) {
12414
+ /**
12415
+ * @method
12416
+ * @name binance#fetchOption
12417
+ * @description fetches option data that is commonly found in an option chain
12418
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics
12419
+ * @param {string} symbol unified market symbol
12420
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12421
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
12422
+ */
12423
+ await this.loadMarkets();
12424
+ const market = this.market(symbol);
12425
+ const request = {
12426
+ 'symbol': market['id'],
12427
+ };
12428
+ const response = await this.eapiPublicGetTicker(this.extend(request, params));
12429
+ //
12430
+ // [
12431
+ // {
12432
+ // "symbol": "BTC-241227-80000-C",
12433
+ // "priceChange": "0",
12434
+ // "priceChangePercent": "0",
12435
+ // "lastPrice": "2750",
12436
+ // "lastQty": "0",
12437
+ // "open": "2750",
12438
+ // "high": "2750",
12439
+ // "low": "2750",
12440
+ // "volume": "0",
12441
+ // "amount": "0",
12442
+ // "bidPrice": "4880",
12443
+ // "askPrice": "0",
12444
+ // "openTime": 0,
12445
+ // "closeTime": 0,
12446
+ // "firstTradeId": 0,
12447
+ // "tradeCount": 0,
12448
+ // "strikePrice": "80000",
12449
+ // "exercisePrice": "63944.09893617"
12450
+ // }
12451
+ // ]
12452
+ //
12453
+ const chain = this.safeDict(response, 0, {});
12454
+ return this.parseOption(chain, undefined, market);
12455
+ }
12456
+ parseOption(chain, currency = undefined, market = undefined) {
12457
+ //
12458
+ // {
12459
+ // "symbol": "BTC-241227-80000-C",
12460
+ // "priceChange": "0",
12461
+ // "priceChangePercent": "0",
12462
+ // "lastPrice": "2750",
12463
+ // "lastQty": "0",
12464
+ // "open": "2750",
12465
+ // "high": "2750",
12466
+ // "low": "2750",
12467
+ // "volume": "0",
12468
+ // "amount": "0",
12469
+ // "bidPrice": "4880",
12470
+ // "askPrice": "0",
12471
+ // "openTime": 0,
12472
+ // "closeTime": 0,
12473
+ // "firstTradeId": 0,
12474
+ // "tradeCount": 0,
12475
+ // "strikePrice": "80000",
12476
+ // "exercisePrice": "63944.09893617"
12477
+ // }
12478
+ //
12479
+ const marketId = this.safeString(chain, 'symbol');
12480
+ market = this.safeMarket(marketId, market);
12481
+ return {
12482
+ 'info': chain,
12483
+ 'currency': undefined,
12484
+ 'symbol': market['symbol'],
12485
+ 'timestamp': undefined,
12486
+ 'datetime': undefined,
12487
+ 'impliedVolatility': undefined,
12488
+ 'openInterest': undefined,
12489
+ 'bidPrice': this.safeNumber(chain, 'bidPrice'),
12490
+ 'askPrice': this.safeNumber(chain, 'askPrice'),
12491
+ 'midPrice': undefined,
12492
+ 'markPrice': undefined,
12493
+ 'lastPrice': this.safeNumber(chain, 'lastPrice'),
12494
+ 'underlyingPrice': this.safeNumber(chain, 'exercisePrice'),
12495
+ 'change': this.safeNumber(chain, 'priceChange'),
12496
+ 'percentage': this.safeNumber(chain, 'priceChangePercent'),
12497
+ 'baseVolume': this.safeNumber(chain, 'volume'),
12498
+ 'quoteVolume': undefined,
12499
+ };
12500
+ }
12411
12501
  }
12412
12502
 
12413
12503
  module.exports = binance;
@@ -92,6 +92,8 @@ class bybit extends bybit$1 {
92
92
  'fetchOpenInterestHistory': true,
93
93
  'fetchOpenOrder': true,
94
94
  'fetchOpenOrders': true,
95
+ 'fetchOption': true,
96
+ 'fetchOptionChain': true,
95
97
  'fetchOrder': false,
96
98
  'fetchOrderBook': true,
97
99
  'fetchOrders': false,
@@ -8207,6 +8209,181 @@ class bybit extends bybit$1 {
8207
8209
  'rate': this.safeNumber(income, 'feeRate'),
8208
8210
  };
8209
8211
  }
8212
+ async fetchOption(symbol, params = {}) {
8213
+ /**
8214
+ * @method
8215
+ * @name bybit#fetchOption
8216
+ * @description fetches option data that is commonly found in an option chain
8217
+ * @see https://bybit-exchange.github.io/docs/v5/market/tickers
8218
+ * @param {string} symbol unified market symbol
8219
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8220
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
8221
+ */
8222
+ await this.loadMarkets();
8223
+ const market = this.market(symbol);
8224
+ const request = {
8225
+ 'category': 'option',
8226
+ 'symbol': market['id'],
8227
+ };
8228
+ const response = await this.publicGetV5MarketTickers(this.extend(request, params));
8229
+ //
8230
+ // {
8231
+ // "retCode": 0,
8232
+ // "retMsg": "SUCCESS",
8233
+ // "result": {
8234
+ // "category": "option",
8235
+ // "list": [
8236
+ // {
8237
+ // "symbol": "BTC-27DEC24-55000-P",
8238
+ // "bid1Price": "0",
8239
+ // "bid1Size": "0",
8240
+ // "bid1Iv": "0",
8241
+ // "ask1Price": "0",
8242
+ // "ask1Size": "0",
8243
+ // "ask1Iv": "0",
8244
+ // "lastPrice": "10980",
8245
+ // "highPrice24h": "0",
8246
+ // "lowPrice24h": "0",
8247
+ // "markPrice": "11814.66756236",
8248
+ // "indexPrice": "63838.92",
8249
+ // "markIv": "0.8866",
8250
+ // "underlyingPrice": "71690.55303594",
8251
+ // "openInterest": "0.01",
8252
+ // "turnover24h": "0",
8253
+ // "volume24h": "0",
8254
+ // "totalVolume": "2",
8255
+ // "totalTurnover": "78719",
8256
+ // "delta": "-0.23284954",
8257
+ // "gamma": "0.0000055",
8258
+ // "vega": "191.70757975",
8259
+ // "theta": "-30.43617927",
8260
+ // "predictedDeliveryPrice": "0",
8261
+ // "change24h": "0"
8262
+ // }
8263
+ // ]
8264
+ // },
8265
+ // "retExtInfo": {},
8266
+ // "time": 1711162003672
8267
+ // }
8268
+ //
8269
+ const result = this.safeDict(response, 'result', {});
8270
+ const resultList = this.safeList(result, 'list', []);
8271
+ const chain = this.safeDict(resultList, 0, {});
8272
+ return this.parseOption(chain, undefined, market);
8273
+ }
8274
+ async fetchOptionChain(code, params = {}) {
8275
+ /**
8276
+ * @method
8277
+ * @name bybit#fetchOptionChain
8278
+ * @description fetches data for an underlying asset that is commonly found in an option chain
8279
+ * @see https://bybit-exchange.github.io/docs/v5/market/tickers
8280
+ * @param {string} currency base currency to fetch an option chain for
8281
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8282
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
8283
+ */
8284
+ await this.loadMarkets();
8285
+ const currency = this.currency(code);
8286
+ const request = {
8287
+ 'category': 'option',
8288
+ 'baseCoin': currency['id'],
8289
+ };
8290
+ const response = await this.publicGetV5MarketTickers(this.extend(request, params));
8291
+ //
8292
+ // {
8293
+ // "retCode": 0,
8294
+ // "retMsg": "SUCCESS",
8295
+ // "result": {
8296
+ // "category": "option",
8297
+ // "list": [
8298
+ // {
8299
+ // "symbol": "BTC-27DEC24-55000-P",
8300
+ // "bid1Price": "0",
8301
+ // "bid1Size": "0",
8302
+ // "bid1Iv": "0",
8303
+ // "ask1Price": "0",
8304
+ // "ask1Size": "0",
8305
+ // "ask1Iv": "0",
8306
+ // "lastPrice": "10980",
8307
+ // "highPrice24h": "0",
8308
+ // "lowPrice24h": "0",
8309
+ // "markPrice": "11814.66756236",
8310
+ // "indexPrice": "63838.92",
8311
+ // "markIv": "0.8866",
8312
+ // "underlyingPrice": "71690.55303594",
8313
+ // "openInterest": "0.01",
8314
+ // "turnover24h": "0",
8315
+ // "volume24h": "0",
8316
+ // "totalVolume": "2",
8317
+ // "totalTurnover": "78719",
8318
+ // "delta": "-0.23284954",
8319
+ // "gamma": "0.0000055",
8320
+ // "vega": "191.70757975",
8321
+ // "theta": "-30.43617927",
8322
+ // "predictedDeliveryPrice": "0",
8323
+ // "change24h": "0"
8324
+ // },
8325
+ // ]
8326
+ // },
8327
+ // "retExtInfo": {},
8328
+ // "time": 1711162003672
8329
+ // }
8330
+ //
8331
+ const result = this.safeDict(response, 'result', {});
8332
+ const resultList = this.safeList(result, 'list', []);
8333
+ return this.parseOptionChain(resultList, undefined, 'symbol');
8334
+ }
8335
+ parseOption(chain, currency = undefined, market = undefined) {
8336
+ //
8337
+ // {
8338
+ // "symbol": "BTC-27DEC24-55000-P",
8339
+ // "bid1Price": "0",
8340
+ // "bid1Size": "0",
8341
+ // "bid1Iv": "0",
8342
+ // "ask1Price": "0",
8343
+ // "ask1Size": "0",
8344
+ // "ask1Iv": "0",
8345
+ // "lastPrice": "10980",
8346
+ // "highPrice24h": "0",
8347
+ // "lowPrice24h": "0",
8348
+ // "markPrice": "11814.66756236",
8349
+ // "indexPrice": "63838.92",
8350
+ // "markIv": "0.8866",
8351
+ // "underlyingPrice": "71690.55303594",
8352
+ // "openInterest": "0.01",
8353
+ // "turnover24h": "0",
8354
+ // "volume24h": "0",
8355
+ // "totalVolume": "2",
8356
+ // "totalTurnover": "78719",
8357
+ // "delta": "-0.23284954",
8358
+ // "gamma": "0.0000055",
8359
+ // "vega": "191.70757975",
8360
+ // "theta": "-30.43617927",
8361
+ // "predictedDeliveryPrice": "0",
8362
+ // "change24h": "0"
8363
+ // }
8364
+ //
8365
+ const marketId = this.safeString(chain, 'symbol');
8366
+ market = this.safeMarket(marketId, market);
8367
+ return {
8368
+ 'info': chain,
8369
+ 'currency': undefined,
8370
+ 'symbol': market['symbol'],
8371
+ 'timestamp': undefined,
8372
+ 'datetime': undefined,
8373
+ 'impliedVolatility': this.safeNumber(chain, 'markIv'),
8374
+ 'openInterest': this.safeNumber(chain, 'openInterest'),
8375
+ 'bidPrice': this.safeNumber(chain, 'bid1Price'),
8376
+ 'askPrice': this.safeNumber(chain, 'ask1Price'),
8377
+ 'midPrice': undefined,
8378
+ 'markPrice': this.safeNumber(chain, 'markPrice'),
8379
+ 'lastPrice': this.safeNumber(chain, 'lastPrice'),
8380
+ 'underlyingPrice': this.safeNumber(chain, 'underlyingPrice'),
8381
+ 'change': this.safeNumber(chain, 'change24h'),
8382
+ 'percentage': undefined,
8383
+ 'baseVolume': this.safeNumber(chain, 'totalVolume'),
8384
+ 'quoteVolume': undefined,
8385
+ };
8386
+ }
8210
8387
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
8211
8388
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
8212
8389
  if (api === 'public') {
@@ -61,6 +61,8 @@ class delta extends delta$1 {
61
61
  'fetchOHLCV': true,
62
62
  'fetchOpenInterest': true,
63
63
  'fetchOpenOrders': true,
64
+ 'fetchOption': true,
65
+ 'fetchOptionChain': false,
64
66
  'fetchOrderBook': true,
65
67
  'fetchPosition': true,
66
68
  'fetchPositionMode': false,
@@ -3312,6 +3314,151 @@ class delta extends delta$1 {
3312
3314
  'marginMode': this.safeString(marginMode, 'margin_mode'),
3313
3315
  };
3314
3316
  }
3317
+ async fetchOption(symbol, params = {}) {
3318
+ /**
3319
+ * @method
3320
+ * @name delta#fetchOption
3321
+ * @description fetches option data that is commonly found in an option chain
3322
+ * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
3323
+ * @param {string} symbol unified market symbol
3324
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3325
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
3326
+ */
3327
+ await this.loadMarkets();
3328
+ const market = this.market(symbol);
3329
+ const request = {
3330
+ 'symbol': market['id'],
3331
+ };
3332
+ const response = await this.publicGetTickersSymbol(this.extend(request, params));
3333
+ //
3334
+ // {
3335
+ // "result": {
3336
+ // "close": 6793.0,
3337
+ // "contract_type": "call_options",
3338
+ // "greeks": {
3339
+ // "delta": "0.94739174",
3340
+ // "gamma": "0.00002206",
3341
+ // "rho": "11.00890725",
3342
+ // "spot": "36839.58124652",
3343
+ // "theta": "-18.18365310",
3344
+ // "vega": "7.85209698"
3345
+ // },
3346
+ // "high": 7556.0,
3347
+ // "low": 6793.0,
3348
+ // "mark_price": "6955.70698909",
3349
+ // "mark_vol": "0.66916863",
3350
+ // "oi": "1.8980",
3351
+ // "oi_change_usd_6h": "110.4600",
3352
+ // "oi_contracts": "1898",
3353
+ // "oi_value": "1.8980",
3354
+ // "oi_value_symbol": "BTC",
3355
+ // "oi_value_usd": "69940.7319",
3356
+ // "open": 7.2e3,
3357
+ // "price_band": {
3358
+ // "lower_limit": "5533.89814767",
3359
+ // "upper_limit": "11691.37688371"
3360
+ // },
3361
+ // "product_id": 129508,
3362
+ // "quotes": {
3363
+ // "ask_iv": "0.90180438",
3364
+ // "ask_size": "1898",
3365
+ // "best_ask": "7210",
3366
+ // "best_bid": "6913",
3367
+ // "bid_iv": "0.60881706",
3368
+ // "bid_size": "3163",
3369
+ // "impact_mid_price": null,
3370
+ // "mark_iv": "0.66973549"
3371
+ // },
3372
+ // "size": 5,
3373
+ // "spot_price": "36839.58153868",
3374
+ // "strike_price": "30000",
3375
+ // "symbol": "C-BTC-30000-241123",
3376
+ // "timestamp": 1699584998504530,
3377
+ // "turnover": 184.41206804,
3378
+ // "turnover_symbol": "USDT",
3379
+ // "turnover_usd": 184.41206804,
3380
+ // "volume": 0.005
3381
+ // },
3382
+ // "success": true
3383
+ // }
3384
+ //
3385
+ const result = this.safeDict(response, 'result', {});
3386
+ return this.parseOption(result, undefined, market);
3387
+ }
3388
+ parseOption(chain, currency = undefined, market = undefined) {
3389
+ //
3390
+ // {
3391
+ // "close": 6793.0,
3392
+ // "contract_type": "call_options",
3393
+ // "greeks": {
3394
+ // "delta": "0.94739174",
3395
+ // "gamma": "0.00002206",
3396
+ // "rho": "11.00890725",
3397
+ // "spot": "36839.58124652",
3398
+ // "theta": "-18.18365310",
3399
+ // "vega": "7.85209698"
3400
+ // },
3401
+ // "high": 7556.0,
3402
+ // "low": 6793.0,
3403
+ // "mark_price": "6955.70698909",
3404
+ // "mark_vol": "0.66916863",
3405
+ // "oi": "1.8980",
3406
+ // "oi_change_usd_6h": "110.4600",
3407
+ // "oi_contracts": "1898",
3408
+ // "oi_value": "1.8980",
3409
+ // "oi_value_symbol": "BTC",
3410
+ // "oi_value_usd": "69940.7319",
3411
+ // "open": 7.2e3,
3412
+ // "price_band": {
3413
+ // "lower_limit": "5533.89814767",
3414
+ // "upper_limit": "11691.37688371"
3415
+ // },
3416
+ // "product_id": 129508,
3417
+ // "quotes": {
3418
+ // "ask_iv": "0.90180438",
3419
+ // "ask_size": "1898",
3420
+ // "best_ask": "7210",
3421
+ // "best_bid": "6913",
3422
+ // "bid_iv": "0.60881706",
3423
+ // "bid_size": "3163",
3424
+ // "impact_mid_price": null,
3425
+ // "mark_iv": "0.66973549"
3426
+ // },
3427
+ // "size": 5,
3428
+ // "spot_price": "36839.58153868",
3429
+ // "strike_price": "30000",
3430
+ // "symbol": "C-BTC-30000-241123",
3431
+ // "timestamp": 1699584998504530,
3432
+ // "turnover": 184.41206804,
3433
+ // "turnover_symbol": "USDT",
3434
+ // "turnover_usd": 184.41206804,
3435
+ // "volume": 0.005
3436
+ // }
3437
+ //
3438
+ const marketId = this.safeString(chain, 'symbol');
3439
+ market = this.safeMarket(marketId, market);
3440
+ const quotes = this.safeDict(chain, 'quotes', {});
3441
+ const timestamp = this.safeIntegerProduct(chain, 'timestamp', 0.001);
3442
+ return {
3443
+ 'info': chain,
3444
+ 'currency': undefined,
3445
+ 'symbol': market['symbol'],
3446
+ 'timestamp': timestamp,
3447
+ 'datetime': this.iso8601(timestamp),
3448
+ 'impliedVolatility': this.safeNumber(quotes, 'mark_iv'),
3449
+ 'openInterest': this.safeNumber(chain, 'oi'),
3450
+ 'bidPrice': this.safeNumber(quotes, 'best_bid'),
3451
+ 'askPrice': this.safeNumber(quotes, 'best_ask'),
3452
+ 'midPrice': this.safeNumber(quotes, 'impact_mid_price'),
3453
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
3454
+ 'lastPrice': undefined,
3455
+ 'underlyingPrice': this.safeNumber(chain, 'spot_price'),
3456
+ 'change': undefined,
3457
+ 'percentage': undefined,
3458
+ 'baseVolume': this.safeNumber(chain, 'volume'),
3459
+ 'quoteVolume': undefined,
3460
+ };
3461
+ }
3315
3462
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3316
3463
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
3317
3464
  let url = this.urls['api'][api] + requestPath;
@@ -3593,7 +3593,7 @@ class deribit extends deribit$1 {
3593
3593
  const timestamp = this.safeInteger(chain, 'timestamp');
3594
3594
  return {
3595
3595
  'info': chain,
3596
- 'currency': code['code'],
3596
+ 'currency': code,
3597
3597
  'symbol': market['symbol'],
3598
3598
  'timestamp': timestamp,
3599
3599
  'datetime': this.iso8601(timestamp),