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.
@@ -18559,6 +18559,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18559
18559
  'fetchOpenInterestHistory': true,
18560
18560
  'fetchOpenOrder': true,
18561
18561
  'fetchOpenOrders': true,
18562
+ 'fetchOption': true,
18563
+ 'fetchOptionChain': false,
18562
18564
  'fetchOrder': true,
18563
18565
  'fetchOrderBook': true,
18564
18566
  'fetchOrderBooks': false,
@@ -30856,6 +30858,94 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
30856
30858
  'marginMode': isIsolated ? 'isolated' : 'cross',
30857
30859
  };
30858
30860
  }
30861
+ async fetchOption(symbol, params = {}) {
30862
+ /**
30863
+ * @method
30864
+ * @name binance#fetchOption
30865
+ * @description fetches option data that is commonly found in an option chain
30866
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics
30867
+ * @param {string} symbol unified market symbol
30868
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
30869
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
30870
+ */
30871
+ await this.loadMarkets();
30872
+ const market = this.market(symbol);
30873
+ const request = {
30874
+ 'symbol': market['id'],
30875
+ };
30876
+ const response = await this.eapiPublicGetTicker(this.extend(request, params));
30877
+ //
30878
+ // [
30879
+ // {
30880
+ // "symbol": "BTC-241227-80000-C",
30881
+ // "priceChange": "0",
30882
+ // "priceChangePercent": "0",
30883
+ // "lastPrice": "2750",
30884
+ // "lastQty": "0",
30885
+ // "open": "2750",
30886
+ // "high": "2750",
30887
+ // "low": "2750",
30888
+ // "volume": "0",
30889
+ // "amount": "0",
30890
+ // "bidPrice": "4880",
30891
+ // "askPrice": "0",
30892
+ // "openTime": 0,
30893
+ // "closeTime": 0,
30894
+ // "firstTradeId": 0,
30895
+ // "tradeCount": 0,
30896
+ // "strikePrice": "80000",
30897
+ // "exercisePrice": "63944.09893617"
30898
+ // }
30899
+ // ]
30900
+ //
30901
+ const chain = this.safeDict(response, 0, {});
30902
+ return this.parseOption(chain, undefined, market);
30903
+ }
30904
+ parseOption(chain, currency = undefined, market = undefined) {
30905
+ //
30906
+ // {
30907
+ // "symbol": "BTC-241227-80000-C",
30908
+ // "priceChange": "0",
30909
+ // "priceChangePercent": "0",
30910
+ // "lastPrice": "2750",
30911
+ // "lastQty": "0",
30912
+ // "open": "2750",
30913
+ // "high": "2750",
30914
+ // "low": "2750",
30915
+ // "volume": "0",
30916
+ // "amount": "0",
30917
+ // "bidPrice": "4880",
30918
+ // "askPrice": "0",
30919
+ // "openTime": 0,
30920
+ // "closeTime": 0,
30921
+ // "firstTradeId": 0,
30922
+ // "tradeCount": 0,
30923
+ // "strikePrice": "80000",
30924
+ // "exercisePrice": "63944.09893617"
30925
+ // }
30926
+ //
30927
+ const marketId = this.safeString(chain, 'symbol');
30928
+ market = this.safeMarket(marketId, market);
30929
+ return {
30930
+ 'info': chain,
30931
+ 'currency': undefined,
30932
+ 'symbol': market['symbol'],
30933
+ 'timestamp': undefined,
30934
+ 'datetime': undefined,
30935
+ 'impliedVolatility': undefined,
30936
+ 'openInterest': undefined,
30937
+ 'bidPrice': this.safeNumber(chain, 'bidPrice'),
30938
+ 'askPrice': this.safeNumber(chain, 'askPrice'),
30939
+ 'midPrice': undefined,
30940
+ 'markPrice': undefined,
30941
+ 'lastPrice': this.safeNumber(chain, 'lastPrice'),
30942
+ 'underlyingPrice': this.safeNumber(chain, 'exercisePrice'),
30943
+ 'change': this.safeNumber(chain, 'priceChange'),
30944
+ 'percentage': this.safeNumber(chain, 'priceChangePercent'),
30945
+ 'baseVolume': this.safeNumber(chain, 'volume'),
30946
+ 'quoteVolume': undefined,
30947
+ };
30948
+ }
30859
30949
  }
30860
30950
 
30861
30951
 
@@ -83629,6 +83719,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83629
83719
  'fetchOpenInterestHistory': true,
83630
83720
  'fetchOpenOrder': true,
83631
83721
  'fetchOpenOrders': true,
83722
+ 'fetchOption': true,
83723
+ 'fetchOptionChain': true,
83632
83724
  'fetchOrder': false,
83633
83725
  'fetchOrderBook': true,
83634
83726
  'fetchOrders': false,
@@ -91748,6 +91840,181 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
91748
91840
  'rate': this.safeNumber(income, 'feeRate'),
91749
91841
  };
91750
91842
  }
91843
+ async fetchOption(symbol, params = {}) {
91844
+ /**
91845
+ * @method
91846
+ * @name bybit#fetchOption
91847
+ * @description fetches option data that is commonly found in an option chain
91848
+ * @see https://bybit-exchange.github.io/docs/v5/market/tickers
91849
+ * @param {string} symbol unified market symbol
91850
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
91851
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
91852
+ */
91853
+ await this.loadMarkets();
91854
+ const market = this.market(symbol);
91855
+ const request = {
91856
+ 'category': 'option',
91857
+ 'symbol': market['id'],
91858
+ };
91859
+ const response = await this.publicGetV5MarketTickers(this.extend(request, params));
91860
+ //
91861
+ // {
91862
+ // "retCode": 0,
91863
+ // "retMsg": "SUCCESS",
91864
+ // "result": {
91865
+ // "category": "option",
91866
+ // "list": [
91867
+ // {
91868
+ // "symbol": "BTC-27DEC24-55000-P",
91869
+ // "bid1Price": "0",
91870
+ // "bid1Size": "0",
91871
+ // "bid1Iv": "0",
91872
+ // "ask1Price": "0",
91873
+ // "ask1Size": "0",
91874
+ // "ask1Iv": "0",
91875
+ // "lastPrice": "10980",
91876
+ // "highPrice24h": "0",
91877
+ // "lowPrice24h": "0",
91878
+ // "markPrice": "11814.66756236",
91879
+ // "indexPrice": "63838.92",
91880
+ // "markIv": "0.8866",
91881
+ // "underlyingPrice": "71690.55303594",
91882
+ // "openInterest": "0.01",
91883
+ // "turnover24h": "0",
91884
+ // "volume24h": "0",
91885
+ // "totalVolume": "2",
91886
+ // "totalTurnover": "78719",
91887
+ // "delta": "-0.23284954",
91888
+ // "gamma": "0.0000055",
91889
+ // "vega": "191.70757975",
91890
+ // "theta": "-30.43617927",
91891
+ // "predictedDeliveryPrice": "0",
91892
+ // "change24h": "0"
91893
+ // }
91894
+ // ]
91895
+ // },
91896
+ // "retExtInfo": {},
91897
+ // "time": 1711162003672
91898
+ // }
91899
+ //
91900
+ const result = this.safeDict(response, 'result', {});
91901
+ const resultList = this.safeList(result, 'list', []);
91902
+ const chain = this.safeDict(resultList, 0, {});
91903
+ return this.parseOption(chain, undefined, market);
91904
+ }
91905
+ async fetchOptionChain(code, params = {}) {
91906
+ /**
91907
+ * @method
91908
+ * @name bybit#fetchOptionChain
91909
+ * @description fetches data for an underlying asset that is commonly found in an option chain
91910
+ * @see https://bybit-exchange.github.io/docs/v5/market/tickers
91911
+ * @param {string} currency base currency to fetch an option chain for
91912
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
91913
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
91914
+ */
91915
+ await this.loadMarkets();
91916
+ const currency = this.currency(code);
91917
+ const request = {
91918
+ 'category': 'option',
91919
+ 'baseCoin': currency['id'],
91920
+ };
91921
+ const response = await this.publicGetV5MarketTickers(this.extend(request, params));
91922
+ //
91923
+ // {
91924
+ // "retCode": 0,
91925
+ // "retMsg": "SUCCESS",
91926
+ // "result": {
91927
+ // "category": "option",
91928
+ // "list": [
91929
+ // {
91930
+ // "symbol": "BTC-27DEC24-55000-P",
91931
+ // "bid1Price": "0",
91932
+ // "bid1Size": "0",
91933
+ // "bid1Iv": "0",
91934
+ // "ask1Price": "0",
91935
+ // "ask1Size": "0",
91936
+ // "ask1Iv": "0",
91937
+ // "lastPrice": "10980",
91938
+ // "highPrice24h": "0",
91939
+ // "lowPrice24h": "0",
91940
+ // "markPrice": "11814.66756236",
91941
+ // "indexPrice": "63838.92",
91942
+ // "markIv": "0.8866",
91943
+ // "underlyingPrice": "71690.55303594",
91944
+ // "openInterest": "0.01",
91945
+ // "turnover24h": "0",
91946
+ // "volume24h": "0",
91947
+ // "totalVolume": "2",
91948
+ // "totalTurnover": "78719",
91949
+ // "delta": "-0.23284954",
91950
+ // "gamma": "0.0000055",
91951
+ // "vega": "191.70757975",
91952
+ // "theta": "-30.43617927",
91953
+ // "predictedDeliveryPrice": "0",
91954
+ // "change24h": "0"
91955
+ // },
91956
+ // ]
91957
+ // },
91958
+ // "retExtInfo": {},
91959
+ // "time": 1711162003672
91960
+ // }
91961
+ //
91962
+ const result = this.safeDict(response, 'result', {});
91963
+ const resultList = this.safeList(result, 'list', []);
91964
+ return this.parseOptionChain(resultList, undefined, 'symbol');
91965
+ }
91966
+ parseOption(chain, currency = undefined, market = undefined) {
91967
+ //
91968
+ // {
91969
+ // "symbol": "BTC-27DEC24-55000-P",
91970
+ // "bid1Price": "0",
91971
+ // "bid1Size": "0",
91972
+ // "bid1Iv": "0",
91973
+ // "ask1Price": "0",
91974
+ // "ask1Size": "0",
91975
+ // "ask1Iv": "0",
91976
+ // "lastPrice": "10980",
91977
+ // "highPrice24h": "0",
91978
+ // "lowPrice24h": "0",
91979
+ // "markPrice": "11814.66756236",
91980
+ // "indexPrice": "63838.92",
91981
+ // "markIv": "0.8866",
91982
+ // "underlyingPrice": "71690.55303594",
91983
+ // "openInterest": "0.01",
91984
+ // "turnover24h": "0",
91985
+ // "volume24h": "0",
91986
+ // "totalVolume": "2",
91987
+ // "totalTurnover": "78719",
91988
+ // "delta": "-0.23284954",
91989
+ // "gamma": "0.0000055",
91990
+ // "vega": "191.70757975",
91991
+ // "theta": "-30.43617927",
91992
+ // "predictedDeliveryPrice": "0",
91993
+ // "change24h": "0"
91994
+ // }
91995
+ //
91996
+ const marketId = this.safeString(chain, 'symbol');
91997
+ market = this.safeMarket(marketId, market);
91998
+ return {
91999
+ 'info': chain,
92000
+ 'currency': undefined,
92001
+ 'symbol': market['symbol'],
92002
+ 'timestamp': undefined,
92003
+ 'datetime': undefined,
92004
+ 'impliedVolatility': this.safeNumber(chain, 'markIv'),
92005
+ 'openInterest': this.safeNumber(chain, 'openInterest'),
92006
+ 'bidPrice': this.safeNumber(chain, 'bid1Price'),
92007
+ 'askPrice': this.safeNumber(chain, 'ask1Price'),
92008
+ 'midPrice': undefined,
92009
+ 'markPrice': this.safeNumber(chain, 'markPrice'),
92010
+ 'lastPrice': this.safeNumber(chain, 'lastPrice'),
92011
+ 'underlyingPrice': this.safeNumber(chain, 'underlyingPrice'),
92012
+ 'change': this.safeNumber(chain, 'change24h'),
92013
+ 'percentage': undefined,
92014
+ 'baseVolume': this.safeNumber(chain, 'totalVolume'),
92015
+ 'quoteVolume': undefined,
92016
+ };
92017
+ }
91751
92018
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
91752
92019
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
91753
92020
  if (api === 'public') {
@@ -122082,6 +122349,8 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
122082
122349
  'fetchOHLCV': true,
122083
122350
  'fetchOpenInterest': true,
122084
122351
  'fetchOpenOrders': true,
122352
+ 'fetchOption': true,
122353
+ 'fetchOptionChain': false,
122085
122354
  'fetchOrderBook': true,
122086
122355
  'fetchPosition': true,
122087
122356
  'fetchPositionMode': false,
@@ -125333,6 +125602,151 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
125333
125602
  'marginMode': this.safeString(marginMode, 'margin_mode'),
125334
125603
  };
125335
125604
  }
125605
+ async fetchOption(symbol, params = {}) {
125606
+ /**
125607
+ * @method
125608
+ * @name delta#fetchOption
125609
+ * @description fetches option data that is commonly found in an option chain
125610
+ * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
125611
+ * @param {string} symbol unified market symbol
125612
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
125613
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
125614
+ */
125615
+ await this.loadMarkets();
125616
+ const market = this.market(symbol);
125617
+ const request = {
125618
+ 'symbol': market['id'],
125619
+ };
125620
+ const response = await this.publicGetTickersSymbol(this.extend(request, params));
125621
+ //
125622
+ // {
125623
+ // "result": {
125624
+ // "close": 6793.0,
125625
+ // "contract_type": "call_options",
125626
+ // "greeks": {
125627
+ // "delta": "0.94739174",
125628
+ // "gamma": "0.00002206",
125629
+ // "rho": "11.00890725",
125630
+ // "spot": "36839.58124652",
125631
+ // "theta": "-18.18365310",
125632
+ // "vega": "7.85209698"
125633
+ // },
125634
+ // "high": 7556.0,
125635
+ // "low": 6793.0,
125636
+ // "mark_price": "6955.70698909",
125637
+ // "mark_vol": "0.66916863",
125638
+ // "oi": "1.8980",
125639
+ // "oi_change_usd_6h": "110.4600",
125640
+ // "oi_contracts": "1898",
125641
+ // "oi_value": "1.8980",
125642
+ // "oi_value_symbol": "BTC",
125643
+ // "oi_value_usd": "69940.7319",
125644
+ // "open": 7.2e3,
125645
+ // "price_band": {
125646
+ // "lower_limit": "5533.89814767",
125647
+ // "upper_limit": "11691.37688371"
125648
+ // },
125649
+ // "product_id": 129508,
125650
+ // "quotes": {
125651
+ // "ask_iv": "0.90180438",
125652
+ // "ask_size": "1898",
125653
+ // "best_ask": "7210",
125654
+ // "best_bid": "6913",
125655
+ // "bid_iv": "0.60881706",
125656
+ // "bid_size": "3163",
125657
+ // "impact_mid_price": null,
125658
+ // "mark_iv": "0.66973549"
125659
+ // },
125660
+ // "size": 5,
125661
+ // "spot_price": "36839.58153868",
125662
+ // "strike_price": "30000",
125663
+ // "symbol": "C-BTC-30000-241123",
125664
+ // "timestamp": 1699584998504530,
125665
+ // "turnover": 184.41206804,
125666
+ // "turnover_symbol": "USDT",
125667
+ // "turnover_usd": 184.41206804,
125668
+ // "volume": 0.005
125669
+ // },
125670
+ // "success": true
125671
+ // }
125672
+ //
125673
+ const result = this.safeDict(response, 'result', {});
125674
+ return this.parseOption(result, undefined, market);
125675
+ }
125676
+ parseOption(chain, currency = undefined, market = undefined) {
125677
+ //
125678
+ // {
125679
+ // "close": 6793.0,
125680
+ // "contract_type": "call_options",
125681
+ // "greeks": {
125682
+ // "delta": "0.94739174",
125683
+ // "gamma": "0.00002206",
125684
+ // "rho": "11.00890725",
125685
+ // "spot": "36839.58124652",
125686
+ // "theta": "-18.18365310",
125687
+ // "vega": "7.85209698"
125688
+ // },
125689
+ // "high": 7556.0,
125690
+ // "low": 6793.0,
125691
+ // "mark_price": "6955.70698909",
125692
+ // "mark_vol": "0.66916863",
125693
+ // "oi": "1.8980",
125694
+ // "oi_change_usd_6h": "110.4600",
125695
+ // "oi_contracts": "1898",
125696
+ // "oi_value": "1.8980",
125697
+ // "oi_value_symbol": "BTC",
125698
+ // "oi_value_usd": "69940.7319",
125699
+ // "open": 7.2e3,
125700
+ // "price_band": {
125701
+ // "lower_limit": "5533.89814767",
125702
+ // "upper_limit": "11691.37688371"
125703
+ // },
125704
+ // "product_id": 129508,
125705
+ // "quotes": {
125706
+ // "ask_iv": "0.90180438",
125707
+ // "ask_size": "1898",
125708
+ // "best_ask": "7210",
125709
+ // "best_bid": "6913",
125710
+ // "bid_iv": "0.60881706",
125711
+ // "bid_size": "3163",
125712
+ // "impact_mid_price": null,
125713
+ // "mark_iv": "0.66973549"
125714
+ // },
125715
+ // "size": 5,
125716
+ // "spot_price": "36839.58153868",
125717
+ // "strike_price": "30000",
125718
+ // "symbol": "C-BTC-30000-241123",
125719
+ // "timestamp": 1699584998504530,
125720
+ // "turnover": 184.41206804,
125721
+ // "turnover_symbol": "USDT",
125722
+ // "turnover_usd": 184.41206804,
125723
+ // "volume": 0.005
125724
+ // }
125725
+ //
125726
+ const marketId = this.safeString(chain, 'symbol');
125727
+ market = this.safeMarket(marketId, market);
125728
+ const quotes = this.safeDict(chain, 'quotes', {});
125729
+ const timestamp = this.safeIntegerProduct(chain, 'timestamp', 0.001);
125730
+ return {
125731
+ 'info': chain,
125732
+ 'currency': undefined,
125733
+ 'symbol': market['symbol'],
125734
+ 'timestamp': timestamp,
125735
+ 'datetime': this.iso8601(timestamp),
125736
+ 'impliedVolatility': this.safeNumber(quotes, 'mark_iv'),
125737
+ 'openInterest': this.safeNumber(chain, 'oi'),
125738
+ 'bidPrice': this.safeNumber(quotes, 'best_bid'),
125739
+ 'askPrice': this.safeNumber(quotes, 'best_ask'),
125740
+ 'midPrice': this.safeNumber(quotes, 'impact_mid_price'),
125741
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
125742
+ 'lastPrice': undefined,
125743
+ 'underlyingPrice': this.safeNumber(chain, 'spot_price'),
125744
+ 'change': undefined,
125745
+ 'percentage': undefined,
125746
+ 'baseVolume': this.safeNumber(chain, 'volume'),
125747
+ 'quoteVolume': undefined,
125748
+ };
125749
+ }
125336
125750
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
125337
125751
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
125338
125752
  let url = this.urls['api'][api] + requestPath;
@@ -128993,7 +129407,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
128993
129407
  const timestamp = this.safeInteger(chain, 'timestamp');
128994
129408
  return {
128995
129409
  'info': chain,
128996
- 'currency': code['code'],
129410
+ 'currency': code,
128997
129411
  'symbol': market['symbol'],
128998
129412
  'timestamp': timestamp,
128999
129413
  'datetime': this.iso8601(timestamp),
@@ -136280,6 +136694,8 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
136280
136694
  'fetchOpenInterest': false,
136281
136695
  'fetchOpenInterestHistory': true,
136282
136696
  'fetchOpenOrders': true,
136697
+ 'fetchOption': true,
136698
+ 'fetchOptionChain': true,
136283
136699
  'fetchOrder': true,
136284
136700
  'fetchOrderBook': true,
136285
136701
  'fetchPosition': true,
@@ -143350,6 +143766,190 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
143350
143766
  'shortLeverage': leverageValue,
143351
143767
  };
143352
143768
  }
143769
+ async fetchOption(symbol, params = {}) {
143770
+ /**
143771
+ * @method
143772
+ * @name gate#fetchOption
143773
+ * @description fetches option data that is commonly found in an option chain
143774
+ * @see https://www.gate.io/docs/developers/apiv4/en/#query-specified-contract-detail
143775
+ * @param {string} symbol unified market symbol
143776
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
143777
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
143778
+ */
143779
+ await this.loadMarkets();
143780
+ const market = this.market(symbol);
143781
+ const request = {
143782
+ 'contract': market['id'],
143783
+ };
143784
+ const response = await this.publicOptionsGetContractsContract(this.extend(request, params));
143785
+ //
143786
+ // {
143787
+ // "is_active": true,
143788
+ // "mark_price_round": "0.01",
143789
+ // "settle_fee_rate": "0.00015",
143790
+ // "bid1_size": 30,
143791
+ // "taker_fee_rate": "0.0003",
143792
+ // "price_limit_fee_rate": "0.1",
143793
+ // "order_price_round": "0.1",
143794
+ // "tag": "month",
143795
+ // "ref_rebate_rate": "0",
143796
+ // "name": "ETH_USDT-20240628-4500-C",
143797
+ // "strike_price": "4500",
143798
+ // "ask1_price": "280.5",
143799
+ // "ref_discount_rate": "0",
143800
+ // "order_price_deviate": "0.2",
143801
+ // "ask1_size": -19,
143802
+ // "mark_price_down": "155.45",
143803
+ // "orderbook_id": 11724695,
143804
+ // "is_call": true,
143805
+ // "last_price": "188.7",
143806
+ // "mark_price": "274.26",
143807
+ // "underlying": "ETH_USDT",
143808
+ // "create_time": 1688024882,
143809
+ // "settle_limit_fee_rate": "0.1",
143810
+ // "orders_limit": 10,
143811
+ // "mark_price_up": "403.83",
143812
+ // "position_size": 80,
143813
+ // "order_size_max": 10000,
143814
+ // "position_limit": 100000,
143815
+ // "multiplier": "0.01",
143816
+ // "order_size_min": 1,
143817
+ // "trade_size": 229,
143818
+ // "underlying_price": "3326.6",
143819
+ // "maker_fee_rate": "0.0003",
143820
+ // "expiration_time": 1719561600,
143821
+ // "trade_id": 15,
143822
+ // "bid1_price": "269.3"
143823
+ // }
143824
+ //
143825
+ return this.parseOption(response, undefined, market);
143826
+ }
143827
+ async fetchOptionChain(code, params = {}) {
143828
+ /**
143829
+ * @method
143830
+ * @name gate#fetchOptionChain
143831
+ * @description fetches data for an underlying asset that is commonly found in an option chain
143832
+ * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
143833
+ * @param {string} currency base currency to fetch an option chain for
143834
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
143835
+ * @param {string} [params.underlying] the underlying asset, can be obtained from fetchUnderlyingAssets ()
143836
+ * @param {int} [params.expiration] unix timestamp of the expiration time
143837
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
143838
+ */
143839
+ await this.loadMarkets();
143840
+ const currency = this.currency(code);
143841
+ const request = {
143842
+ 'underlying': currency['code'] + '_USDT',
143843
+ };
143844
+ const response = await this.publicOptionsGetContracts(this.extend(request, params));
143845
+ //
143846
+ // [
143847
+ // {
143848
+ // "is_active": true,
143849
+ // "mark_price_round": "0.1",
143850
+ // "settle_fee_rate": "0.00015",
143851
+ // "bid1_size": 434,
143852
+ // "taker_fee_rate": "0.0003",
143853
+ // "price_limit_fee_rate": "0.1",
143854
+ // "order_price_round": "1",
143855
+ // "tag": "day",
143856
+ // "ref_rebate_rate": "0",
143857
+ // "name": "BTC_USDT-20240324-63500-P",
143858
+ // "strike_price": "63500",
143859
+ // "ask1_price": "387",
143860
+ // "ref_discount_rate": "0",
143861
+ // "order_price_deviate": "0.15",
143862
+ // "ask1_size": -454,
143863
+ // "mark_price_down": "124.3",
143864
+ // "orderbook_id": 29600,
143865
+ // "is_call": false,
143866
+ // "last_price": "0",
143867
+ // "mark_price": "366.6",
143868
+ // "underlying": "BTC_USDT",
143869
+ // "create_time": 1711118829,
143870
+ // "settle_limit_fee_rate": "0.1",
143871
+ // "orders_limit": 10,
143872
+ // "mark_price_up": "630",
143873
+ // "position_size": 0,
143874
+ // "order_size_max": 10000,
143875
+ // "position_limit": 10000,
143876
+ // "multiplier": "0.01",
143877
+ // "order_size_min": 1,
143878
+ // "trade_size": 0,
143879
+ // "underlying_price": "64084.65",
143880
+ // "maker_fee_rate": "0.0003",
143881
+ // "expiration_time": 1711267200,
143882
+ // "trade_id": 0,
143883
+ // "bid1_price": "307"
143884
+ // },
143885
+ // ]
143886
+ //
143887
+ return this.parseOptionChain(response, undefined, 'name');
143888
+ }
143889
+ parseOption(chain, currency = undefined, market = undefined) {
143890
+ //
143891
+ // {
143892
+ // "is_active": true,
143893
+ // "mark_price_round": "0.1",
143894
+ // "settle_fee_rate": "0.00015",
143895
+ // "bid1_size": 434,
143896
+ // "taker_fee_rate": "0.0003",
143897
+ // "price_limit_fee_rate": "0.1",
143898
+ // "order_price_round": "1",
143899
+ // "tag": "day",
143900
+ // "ref_rebate_rate": "0",
143901
+ // "name": "BTC_USDT-20240324-63500-P",
143902
+ // "strike_price": "63500",
143903
+ // "ask1_price": "387",
143904
+ // "ref_discount_rate": "0",
143905
+ // "order_price_deviate": "0.15",
143906
+ // "ask1_size": -454,
143907
+ // "mark_price_down": "124.3",
143908
+ // "orderbook_id": 29600,
143909
+ // "is_call": false,
143910
+ // "last_price": "0",
143911
+ // "mark_price": "366.6",
143912
+ // "underlying": "BTC_USDT",
143913
+ // "create_time": 1711118829,
143914
+ // "settle_limit_fee_rate": "0.1",
143915
+ // "orders_limit": 10,
143916
+ // "mark_price_up": "630",
143917
+ // "position_size": 0,
143918
+ // "order_size_max": 10000,
143919
+ // "position_limit": 10000,
143920
+ // "multiplier": "0.01",
143921
+ // "order_size_min": 1,
143922
+ // "trade_size": 0,
143923
+ // "underlying_price": "64084.65",
143924
+ // "maker_fee_rate": "0.0003",
143925
+ // "expiration_time": 1711267200,
143926
+ // "trade_id": 0,
143927
+ // "bid1_price": "307"
143928
+ // }
143929
+ //
143930
+ const marketId = this.safeString(chain, 'name');
143931
+ market = this.safeMarket(marketId, market);
143932
+ const timestamp = this.safeTimestamp(chain, 'create_time');
143933
+ return {
143934
+ 'info': chain,
143935
+ 'currency': undefined,
143936
+ 'symbol': market['symbol'],
143937
+ 'timestamp': timestamp,
143938
+ 'datetime': this.iso8601(timestamp),
143939
+ 'impliedVolatility': undefined,
143940
+ 'openInterest': undefined,
143941
+ 'bidPrice': this.safeNumber(chain, 'bid1_price'),
143942
+ 'askPrice': this.safeNumber(chain, 'ask1_price'),
143943
+ 'midPrice': undefined,
143944
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
143945
+ 'lastPrice': this.safeNumber(chain, 'last_price'),
143946
+ 'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
143947
+ 'change': undefined,
143948
+ 'percentage': undefined,
143949
+ 'baseVolume': undefined,
143950
+ 'quoteVolume': undefined,
143951
+ };
143952
+ }
143353
143953
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
143354
143954
  if (response === undefined) {
143355
143955
  return undefined;
@@ -162164,7 +162764,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162164
162764
  'createMarketSellOrderWithCost': false,
162165
162765
  'createOrder': true,
162166
162766
  'createOrders': true,
162167
- 'createReduceOnlyOrder': false,
162767
+ 'createReduceOnlyOrder': true,
162168
162768
  'editOrder': true,
162169
162769
  'fetchAccounts': false,
162170
162770
  'fetchBalance': true,
@@ -163001,7 +163601,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163001
163601
  'tif': timeInForce,
163002
163602
  };
163003
163603
  }
163004
- orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id']);
163604
+ orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly']);
163005
163605
  const orderObj = {
163006
163606
  'a': this.parseToInt(market['baseId']),
163007
163607
  'b': isBuy,
@@ -164154,10 +164754,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
164154
164754
  [userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
164155
164755
  let user = userAux;
164156
164756
  [user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux);
164157
- if (user !== undefined) {
164757
+ if ((user !== undefined) && (user !== '')) {
164158
164758
  return [user, params];
164159
164759
  }
164160
- if (this.walletAddress !== undefined) {
164760
+ if ((this.walletAddress !== undefined) && (this.walletAddress !== '')) {
164161
164761
  return [this.walletAddress, params];
164162
164762
  }
164163
164763
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set');
@@ -204997,6 +205597,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
204997
205597
  'fetchOpenInterestHistory': true,
204998
205598
  'fetchOpenOrder': undefined,
204999
205599
  'fetchOpenOrders': true,
205600
+ 'fetchOption': true,
205601
+ 'fetchOptionChain': true,
205000
205602
  'fetchOrder': true,
205001
205603
  'fetchOrderBook': true,
205002
205604
  'fetchOrderBooks': false,
@@ -206758,16 +207360,29 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206758
207360
  const first = this.safeValue(data, 0, {});
206759
207361
  return this.parseTicker(first, market);
206760
207362
  }
206761
- async fetchTickersByType(type, symbols = undefined, params = {}) {
207363
+ async fetchTickers(symbols = undefined, params = {}) {
207364
+ /**
207365
+ * @method
207366
+ * @name okx#fetchTickers
207367
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
207368
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
207369
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
207370
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
207371
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
207372
+ */
206762
207373
  await this.loadMarkets();
207374
+ symbols = this.marketSymbols(symbols);
207375
+ const market = this.getMarketFromSymbols(symbols);
207376
+ let marketType = undefined;
207377
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
206763
207378
  const request = {
206764
- 'instType': this.convertToInstrumentType(type),
207379
+ 'instType': this.convertToInstrumentType(marketType),
206765
207380
  };
206766
- if (type === 'option') {
207381
+ if (marketType === 'option') {
206767
207382
  const defaultUnderlying = this.safeValue(this.options, 'defaultUnderlying', 'BTC-USD');
206768
207383
  const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
206769
207384
  if (currencyId === undefined) {
206770
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchTickersByType() requires an underlying uly or marketId parameter for options markets');
207385
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
206771
207386
  }
206772
207387
  else {
206773
207388
  request['uly'] = currencyId;
@@ -206800,29 +207415,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206800
207415
  // ]
206801
207416
  // }
206802
207417
  //
206803
- const tickers = this.safeValue(response, 'data', []);
207418
+ const tickers = this.safeList(response, 'data', []);
206804
207419
  return this.parseTickers(tickers, symbols);
206805
207420
  }
206806
- async fetchTickers(symbols = undefined, params = {}) {
206807
- /**
206808
- * @method
206809
- * @name okx#fetchTickers
206810
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
206811
- * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
206812
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
206813
- * @param {object} [params] extra parameters specific to the exchange API endpoint
206814
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
206815
- */
206816
- await this.loadMarkets();
206817
- symbols = this.marketSymbols(symbols);
206818
- const first = this.safeString(symbols, 0);
206819
- let market = undefined;
206820
- if (first !== undefined) {
206821
- market = this.market(first);
206822
- }
206823
- const [type, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
206824
- return await this.fetchTickersByType(type, symbols, query);
206825
- }
206826
207421
  parseTrade(trade, market = undefined) {
206827
207422
  //
206828
207423
  // public fetchTrades
@@ -209640,23 +210235,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
209640
210235
  }
209641
210236
  }
209642
210237
  request['fee'] = this.numberToString(fee); // withdrawals to OKCoin or OKX are fee-free, please set 0
209643
- if ('password' in params) {
209644
- request['pwd'] = params['password'];
209645
- }
209646
- else if ('pwd' in params) {
209647
- request['pwd'] = params['pwd'];
209648
- }
209649
- else {
209650
- const options = this.safeValue(this.options, 'withdraw', {});
209651
- const password = this.safeString2(options, 'password', 'pwd');
209652
- if (password !== undefined) {
209653
- request['pwd'] = password;
209654
- }
209655
- }
209656
- const query = this.omit(params, ['fee', 'password', 'pwd']);
209657
- if (!('pwd' in request)) {
209658
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' withdraw() requires a password parameter or a pwd parameter, it must be the funding password, not the API passphrase');
209659
- }
210238
+ const query = this.omit(params, ['fee']);
209660
210239
  const response = await this.privatePostAssetWithdrawal(this.extend(request, query));
209661
210240
  //
209662
210241
  // {
@@ -212336,6 +212915,143 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
212336
212915
  const order = this.safeValue(data, 0);
212337
212916
  return this.parseOrder(order, market);
212338
212917
  }
212918
+ async fetchOption(symbol, params = {}) {
212919
+ /**
212920
+ * @method
212921
+ * @name okx#fetchOption
212922
+ * @description fetches option data that is commonly found in an option chain
212923
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker
212924
+ * @param {string} symbol unified market symbol
212925
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
212926
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
212927
+ */
212928
+ await this.loadMarkets();
212929
+ const market = this.market(symbol);
212930
+ const request = {
212931
+ 'instId': market['id'],
212932
+ };
212933
+ const response = await this.publicGetMarketTicker(this.extend(request, params));
212934
+ //
212935
+ // {
212936
+ // "code": "0",
212937
+ // "msg": "",
212938
+ // "data": [
212939
+ // {
212940
+ // "instType": "OPTION",
212941
+ // "instId": "BTC-USD-241227-60000-P",
212942
+ // "last": "",
212943
+ // "lastSz": "0",
212944
+ // "askPx": "",
212945
+ // "askSz": "0",
212946
+ // "bidPx": "",
212947
+ // "bidSz": "0",
212948
+ // "open24h": "",
212949
+ // "high24h": "",
212950
+ // "low24h": "",
212951
+ // "volCcy24h": "0",
212952
+ // "vol24h": "0",
212953
+ // "ts": "1711176035035",
212954
+ // "sodUtc0": "",
212955
+ // "sodUtc8": ""
212956
+ // }
212957
+ // ]
212958
+ // }
212959
+ //
212960
+ const result = this.safeList(response, 'data', []);
212961
+ const chain = this.safeDict(result, 0, {});
212962
+ return this.parseOption(chain, undefined, market);
212963
+ }
212964
+ async fetchOptionChain(code, params = {}) {
212965
+ /**
212966
+ * @method
212967
+ * @name okx#fetchOptionChain
212968
+ * @description fetches data for an underlying asset that is commonly found in an option chain
212969
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
212970
+ * @param {string} currency base currency to fetch an option chain for
212971
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
212972
+ * @param {string} [params.uly] the underlying asset, can be obtained from fetchUnderlyingAssets ()
212973
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
212974
+ */
212975
+ await this.loadMarkets();
212976
+ const currency = this.currency(code);
212977
+ const request = {
212978
+ 'uly': currency['code'] + '-USD',
212979
+ 'instType': 'OPTION',
212980
+ };
212981
+ const response = await this.publicGetMarketTickers(this.extend(request, params));
212982
+ //
212983
+ // {
212984
+ // "code": "0",
212985
+ // "msg": "",
212986
+ // "data": [
212987
+ // {
212988
+ // "instType": "OPTION",
212989
+ // "instId": "BTC-USD-240323-52000-C",
212990
+ // "last": "",
212991
+ // "lastSz": "0",
212992
+ // "askPx": "",
212993
+ // "askSz": "0",
212994
+ // "bidPx": "",
212995
+ // "bidSz": "0",
212996
+ // "open24h": "",
212997
+ // "high24h": "",
212998
+ // "low24h": "",
212999
+ // "volCcy24h": "0",
213000
+ // "vol24h": "0",
213001
+ // "ts": "1711176207008",
213002
+ // "sodUtc0": "",
213003
+ // "sodUtc8": ""
213004
+ // },
213005
+ // ]
213006
+ // }
213007
+ //
213008
+ const result = this.safeList(response, 'data', []);
213009
+ return this.parseOptionChain(result, undefined, 'instId');
213010
+ }
213011
+ parseOption(chain, currency = undefined, market = undefined) {
213012
+ //
213013
+ // {
213014
+ // "instType": "OPTION",
213015
+ // "instId": "BTC-USD-241227-60000-P",
213016
+ // "last": "",
213017
+ // "lastSz": "0",
213018
+ // "askPx": "",
213019
+ // "askSz": "0",
213020
+ // "bidPx": "",
213021
+ // "bidSz": "0",
213022
+ // "open24h": "",
213023
+ // "high24h": "",
213024
+ // "low24h": "",
213025
+ // "volCcy24h": "0",
213026
+ // "vol24h": "0",
213027
+ // "ts": "1711176035035",
213028
+ // "sodUtc0": "",
213029
+ // "sodUtc8": ""
213030
+ // }
213031
+ //
213032
+ const marketId = this.safeString(chain, 'instId');
213033
+ market = this.safeMarket(marketId, market);
213034
+ const timestamp = this.safeInteger(chain, 'ts');
213035
+ return {
213036
+ 'info': chain,
213037
+ 'currency': undefined,
213038
+ 'symbol': market['symbol'],
213039
+ 'timestamp': timestamp,
213040
+ 'datetime': this.iso8601(timestamp),
213041
+ 'impliedVolatility': undefined,
213042
+ 'openInterest': undefined,
213043
+ 'bidPrice': this.safeNumber(chain, 'bidPx'),
213044
+ 'askPrice': this.safeNumber(chain, 'askPx'),
213045
+ 'midPrice': undefined,
213046
+ 'markPrice': undefined,
213047
+ 'lastPrice': this.safeNumber(chain, 'last'),
213048
+ 'underlyingPrice': undefined,
213049
+ 'change': undefined,
213050
+ 'percentage': undefined,
213051
+ 'baseVolume': this.safeNumber(chain, 'volCcy24h'),
213052
+ 'quoteVolume': undefined,
213053
+ };
213054
+ }
212339
213055
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
212340
213056
  if (!response) {
212341
213057
  return undefined; // fallback to default error handler
@@ -322528,7 +323244,7 @@ SOFTWARE.
322528
323244
 
322529
323245
  //-----------------------------------------------------------------------------
322530
323246
  // this is updated by vss.js when building
322531
- const version = '4.2.80';
323247
+ const version = '4.2.82';
322532
323248
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
322533
323249
  //-----------------------------------------------------------------------------
322534
323250