ccxt 4.2.80__py2.py3-none-any.whl → 4.2.81__py2.py3-none-any.whl

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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

ccxt/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.2.80'
25
+ __version__ = '4.2.81'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.80'
7
+ __version__ = '4.2.81'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.2.80'
5
+ __version__ = '4.2.81'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -8,7 +8,7 @@ from ccxt.abstract.binance import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Leverages, MarginMode, MarginModes, Market, MarketInterface, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Leverages, MarginMode, MarginModes, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import PermissionDenied
@@ -134,6 +134,8 @@ class binance(Exchange, ImplicitAPI):
134
134
  'fetchOpenInterestHistory': True,
135
135
  'fetchOpenOrder': True,
136
136
  'fetchOpenOrders': True,
137
+ 'fetchOption': True,
138
+ 'fetchOptionChain': False,
137
139
  'fetchOrder': True,
138
140
  'fetchOrderBook': True,
139
141
  'fetchOrderBooks': False,
@@ -11411,3 +11413,89 @@ class binance(Exchange, ImplicitAPI):
11411
11413
  'symbol': market['symbol'],
11412
11414
  'marginMode': 'isolated' if isIsolated else 'cross',
11413
11415
  }
11416
+
11417
+ async def fetch_option(self, symbol: str, params={}) -> Option:
11418
+ """
11419
+ fetches option data that is commonly found in an option chain
11420
+ :see: https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics
11421
+ :param str symbol: unified market symbol
11422
+ :param dict [params]: extra parameters specific to the exchange API endpoint
11423
+ :returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
11424
+ """
11425
+ await self.load_markets()
11426
+ market = self.market(symbol)
11427
+ request = {
11428
+ 'symbol': market['id'],
11429
+ }
11430
+ response = await self.eapiPublicGetTicker(self.extend(request, params))
11431
+ #
11432
+ # [
11433
+ # {
11434
+ # "symbol": "BTC-241227-80000-C",
11435
+ # "priceChange": "0",
11436
+ # "priceChangePercent": "0",
11437
+ # "lastPrice": "2750",
11438
+ # "lastQty": "0",
11439
+ # "open": "2750",
11440
+ # "high": "2750",
11441
+ # "low": "2750",
11442
+ # "volume": "0",
11443
+ # "amount": "0",
11444
+ # "bidPrice": "4880",
11445
+ # "askPrice": "0",
11446
+ # "openTime": 0,
11447
+ # "closeTime": 0,
11448
+ # "firstTradeId": 0,
11449
+ # "tradeCount": 0,
11450
+ # "strikePrice": "80000",
11451
+ # "exercisePrice": "63944.09893617"
11452
+ # }
11453
+ # ]
11454
+ #
11455
+ chain = self.safe_dict(response, 0, {})
11456
+ return self.parse_option(chain, None, market)
11457
+
11458
+ def parse_option(self, chain, currency: Currency = None, market: Market = None):
11459
+ #
11460
+ # {
11461
+ # "symbol": "BTC-241227-80000-C",
11462
+ # "priceChange": "0",
11463
+ # "priceChangePercent": "0",
11464
+ # "lastPrice": "2750",
11465
+ # "lastQty": "0",
11466
+ # "open": "2750",
11467
+ # "high": "2750",
11468
+ # "low": "2750",
11469
+ # "volume": "0",
11470
+ # "amount": "0",
11471
+ # "bidPrice": "4880",
11472
+ # "askPrice": "0",
11473
+ # "openTime": 0,
11474
+ # "closeTime": 0,
11475
+ # "firstTradeId": 0,
11476
+ # "tradeCount": 0,
11477
+ # "strikePrice": "80000",
11478
+ # "exercisePrice": "63944.09893617"
11479
+ # }
11480
+ #
11481
+ marketId = self.safe_string(chain, 'symbol')
11482
+ market = self.safe_market(marketId, market)
11483
+ return {
11484
+ 'info': chain,
11485
+ 'currency': None,
11486
+ 'symbol': market['symbol'],
11487
+ 'timestamp': None,
11488
+ 'datetime': None,
11489
+ 'impliedVolatility': None,
11490
+ 'openInterest': None,
11491
+ 'bidPrice': self.safe_number(chain, 'bidPrice'),
11492
+ 'askPrice': self.safe_number(chain, 'askPrice'),
11493
+ 'midPrice': None,
11494
+ 'markPrice': None,
11495
+ 'lastPrice': self.safe_number(chain, 'lastPrice'),
11496
+ 'underlyingPrice': self.safe_number(chain, 'exercisePrice'),
11497
+ 'change': self.safe_number(chain, 'priceChange'),
11498
+ 'percentage': self.safe_number(chain, 'priceChangePercent'),
11499
+ 'baseVolume': self.safe_number(chain, 'volume'),
11500
+ 'quoteVolume': None,
11501
+ }
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import PermissionDenied
@@ -107,6 +107,8 @@ class bybit(Exchange, ImplicitAPI):
107
107
  'fetchOpenInterestHistory': True,
108
108
  'fetchOpenOrder': True,
109
109
  'fetchOpenOrders': True,
110
+ 'fetchOption': True,
111
+ 'fetchOptionChain': True,
110
112
  'fetchOrder': False,
111
113
  'fetchOrderBook': True,
112
114
  'fetchOrders': False,
@@ -7632,6 +7634,177 @@ class bybit(Exchange, ImplicitAPI):
7632
7634
  'rate': self.safe_number(income, 'feeRate'),
7633
7635
  }
7634
7636
 
7637
+ async def fetch_option(self, symbol: str, params={}) -> Option:
7638
+ """
7639
+ fetches option data that is commonly found in an option chain
7640
+ :see: https://bybit-exchange.github.io/docs/v5/market/tickers
7641
+ :param str symbol: unified market symbol
7642
+ :param dict [params]: extra parameters specific to the exchange API endpoint
7643
+ :returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
7644
+ """
7645
+ await self.load_markets()
7646
+ market = self.market(symbol)
7647
+ request = {
7648
+ 'category': 'option',
7649
+ 'symbol': market['id'],
7650
+ }
7651
+ response = await self.publicGetV5MarketTickers(self.extend(request, params))
7652
+ #
7653
+ # {
7654
+ # "retCode": 0,
7655
+ # "retMsg": "SUCCESS",
7656
+ # "result": {
7657
+ # "category": "option",
7658
+ # "list": [
7659
+ # {
7660
+ # "symbol": "BTC-27DEC24-55000-P",
7661
+ # "bid1Price": "0",
7662
+ # "bid1Size": "0",
7663
+ # "bid1Iv": "0",
7664
+ # "ask1Price": "0",
7665
+ # "ask1Size": "0",
7666
+ # "ask1Iv": "0",
7667
+ # "lastPrice": "10980",
7668
+ # "highPrice24h": "0",
7669
+ # "lowPrice24h": "0",
7670
+ # "markPrice": "11814.66756236",
7671
+ # "indexPrice": "63838.92",
7672
+ # "markIv": "0.8866",
7673
+ # "underlyingPrice": "71690.55303594",
7674
+ # "openInterest": "0.01",
7675
+ # "turnover24h": "0",
7676
+ # "volume24h": "0",
7677
+ # "totalVolume": "2",
7678
+ # "totalTurnover": "78719",
7679
+ # "delta": "-0.23284954",
7680
+ # "gamma": "0.0000055",
7681
+ # "vega": "191.70757975",
7682
+ # "theta": "-30.43617927",
7683
+ # "predictedDeliveryPrice": "0",
7684
+ # "change24h": "0"
7685
+ # }
7686
+ # ]
7687
+ # },
7688
+ # "retExtInfo": {},
7689
+ # "time": 1711162003672
7690
+ # }
7691
+ #
7692
+ result = self.safe_dict(response, 'result', {})
7693
+ resultList = self.safe_list(result, 'list', [])
7694
+ chain = self.safe_dict(resultList, 0, {})
7695
+ return self.parse_option(chain, None, market)
7696
+
7697
+ async def fetch_option_chain(self, code: str, params={}) -> OptionChain:
7698
+ """
7699
+ fetches data for an underlying asset that is commonly found in an option chain
7700
+ :see: https://bybit-exchange.github.io/docs/v5/market/tickers
7701
+ :param str currency: base currency to fetch an option chain for
7702
+ :param dict [params]: extra parameters specific to the exchange API endpoint
7703
+ :returns dict: a list of `option chain structures <https://docs.ccxt.com/#/?id=option-chain-structure>`
7704
+ """
7705
+ await self.load_markets()
7706
+ currency = self.currency(code)
7707
+ request = {
7708
+ 'category': 'option',
7709
+ 'baseCoin': currency['id'],
7710
+ }
7711
+ response = await self.publicGetV5MarketTickers(self.extend(request, params))
7712
+ #
7713
+ # {
7714
+ # "retCode": 0,
7715
+ # "retMsg": "SUCCESS",
7716
+ # "result": {
7717
+ # "category": "option",
7718
+ # "list": [
7719
+ # {
7720
+ # "symbol": "BTC-27DEC24-55000-P",
7721
+ # "bid1Price": "0",
7722
+ # "bid1Size": "0",
7723
+ # "bid1Iv": "0",
7724
+ # "ask1Price": "0",
7725
+ # "ask1Size": "0",
7726
+ # "ask1Iv": "0",
7727
+ # "lastPrice": "10980",
7728
+ # "highPrice24h": "0",
7729
+ # "lowPrice24h": "0",
7730
+ # "markPrice": "11814.66756236",
7731
+ # "indexPrice": "63838.92",
7732
+ # "markIv": "0.8866",
7733
+ # "underlyingPrice": "71690.55303594",
7734
+ # "openInterest": "0.01",
7735
+ # "turnover24h": "0",
7736
+ # "volume24h": "0",
7737
+ # "totalVolume": "2",
7738
+ # "totalTurnover": "78719",
7739
+ # "delta": "-0.23284954",
7740
+ # "gamma": "0.0000055",
7741
+ # "vega": "191.70757975",
7742
+ # "theta": "-30.43617927",
7743
+ # "predictedDeliveryPrice": "0",
7744
+ # "change24h": "0"
7745
+ # },
7746
+ # ]
7747
+ # },
7748
+ # "retExtInfo": {},
7749
+ # "time": 1711162003672
7750
+ # }
7751
+ #
7752
+ result = self.safe_dict(response, 'result', {})
7753
+ resultList = self.safe_list(result, 'list', [])
7754
+ return self.parse_option_chain(resultList, None, 'symbol')
7755
+
7756
+ def parse_option(self, chain, currency: Currency = None, market: Market = None):
7757
+ #
7758
+ # {
7759
+ # "symbol": "BTC-27DEC24-55000-P",
7760
+ # "bid1Price": "0",
7761
+ # "bid1Size": "0",
7762
+ # "bid1Iv": "0",
7763
+ # "ask1Price": "0",
7764
+ # "ask1Size": "0",
7765
+ # "ask1Iv": "0",
7766
+ # "lastPrice": "10980",
7767
+ # "highPrice24h": "0",
7768
+ # "lowPrice24h": "0",
7769
+ # "markPrice": "11814.66756236",
7770
+ # "indexPrice": "63838.92",
7771
+ # "markIv": "0.8866",
7772
+ # "underlyingPrice": "71690.55303594",
7773
+ # "openInterest": "0.01",
7774
+ # "turnover24h": "0",
7775
+ # "volume24h": "0",
7776
+ # "totalVolume": "2",
7777
+ # "totalTurnover": "78719",
7778
+ # "delta": "-0.23284954",
7779
+ # "gamma": "0.0000055",
7780
+ # "vega": "191.70757975",
7781
+ # "theta": "-30.43617927",
7782
+ # "predictedDeliveryPrice": "0",
7783
+ # "change24h": "0"
7784
+ # }
7785
+ #
7786
+ marketId = self.safe_string(chain, 'symbol')
7787
+ market = self.safe_market(marketId, market)
7788
+ return {
7789
+ 'info': chain,
7790
+ 'currency': None,
7791
+ 'symbol': market['symbol'],
7792
+ 'timestamp': None,
7793
+ 'datetime': None,
7794
+ 'impliedVolatility': self.safe_number(chain, 'markIv'),
7795
+ 'openInterest': self.safe_number(chain, 'openInterest'),
7796
+ 'bidPrice': self.safe_number(chain, 'bid1Price'),
7797
+ 'askPrice': self.safe_number(chain, 'ask1Price'),
7798
+ 'midPrice': None,
7799
+ 'markPrice': self.safe_number(chain, 'markPrice'),
7800
+ 'lastPrice': self.safe_number(chain, 'lastPrice'),
7801
+ 'underlyingPrice': self.safe_number(chain, 'underlyingPrice'),
7802
+ 'change': self.safe_number(chain, 'change24h'),
7803
+ 'percentage': None,
7804
+ 'baseVolume': self.safe_number(chain, 'totalVolume'),
7805
+ 'quoteVolume': None,
7806
+ }
7807
+
7635
7808
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
7636
7809
  url = self.implode_hostname(self.urls['api'][api]) + '/' + path
7637
7810
  if api == 'public':
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, Market, MarketInterface, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import PermissionDenied
@@ -151,6 +151,8 @@ class gate(Exchange, ImplicitAPI):
151
151
  'fetchOpenInterest': False,
152
152
  'fetchOpenInterestHistory': True,
153
153
  'fetchOpenOrders': True,
154
+ 'fetchOption': True,
155
+ 'fetchOptionChain': True,
154
156
  'fetchOrder': True,
155
157
  'fetchOrderBook': True,
156
158
  'fetchPosition': True,
@@ -6688,6 +6690,186 @@ class gate(Exchange, ImplicitAPI):
6688
6690
  'shortLeverage': leverageValue,
6689
6691
  }
6690
6692
 
6693
+ async def fetch_option(self, symbol: str, params={}) -> Option:
6694
+ """
6695
+ fetches option data that is commonly found in an option chain
6696
+ :see: https://www.gate.io/docs/developers/apiv4/en/#query-specified-contract-detail
6697
+ :param str symbol: unified market symbol
6698
+ :param dict [params]: extra parameters specific to the exchange API endpoint
6699
+ :returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
6700
+ """
6701
+ await self.load_markets()
6702
+ market = self.market(symbol)
6703
+ request = {
6704
+ 'contract': market['id'],
6705
+ }
6706
+ response = await self.publicOptionsGetContractsContract(self.extend(request, params))
6707
+ #
6708
+ # {
6709
+ # "is_active": True,
6710
+ # "mark_price_round": "0.01",
6711
+ # "settle_fee_rate": "0.00015",
6712
+ # "bid1_size": 30,
6713
+ # "taker_fee_rate": "0.0003",
6714
+ # "price_limit_fee_rate": "0.1",
6715
+ # "order_price_round": "0.1",
6716
+ # "tag": "month",
6717
+ # "ref_rebate_rate": "0",
6718
+ # "name": "ETH_USDT-20240628-4500-C",
6719
+ # "strike_price": "4500",
6720
+ # "ask1_price": "280.5",
6721
+ # "ref_discount_rate": "0",
6722
+ # "order_price_deviate": "0.2",
6723
+ # "ask1_size": -19,
6724
+ # "mark_price_down": "155.45",
6725
+ # "orderbook_id": 11724695,
6726
+ # "is_call": True,
6727
+ # "last_price": "188.7",
6728
+ # "mark_price": "274.26",
6729
+ # "underlying": "ETH_USDT",
6730
+ # "create_time": 1688024882,
6731
+ # "settle_limit_fee_rate": "0.1",
6732
+ # "orders_limit": 10,
6733
+ # "mark_price_up": "403.83",
6734
+ # "position_size": 80,
6735
+ # "order_size_max": 10000,
6736
+ # "position_limit": 100000,
6737
+ # "multiplier": "0.01",
6738
+ # "order_size_min": 1,
6739
+ # "trade_size": 229,
6740
+ # "underlying_price": "3326.6",
6741
+ # "maker_fee_rate": "0.0003",
6742
+ # "expiration_time": 1719561600,
6743
+ # "trade_id": 15,
6744
+ # "bid1_price": "269.3"
6745
+ # }
6746
+ #
6747
+ return self.parse_option(response, None, market)
6748
+
6749
+ async def fetch_option_chain(self, code: str, params={}) -> OptionChain:
6750
+ """
6751
+ fetches data for an underlying asset that is commonly found in an option chain
6752
+ :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-the-contracts-with-specified-underlying-and-expiration-time
6753
+ :param str currency: base currency to fetch an option chain for
6754
+ :param dict [params]: extra parameters specific to the exchange API endpoint
6755
+ :param str [params.underlying]: the underlying asset, can be obtained from fetchUnderlyingAssets()
6756
+ :param int [params.expiration]: unix timestamp of the expiration time
6757
+ :returns dict: a list of `option chain structures <https://docs.ccxt.com/#/?id=option-chain-structure>`
6758
+ """
6759
+ await self.load_markets()
6760
+ currency = self.currency(code)
6761
+ request = {
6762
+ 'underlying': currency['code'] + '_USDT',
6763
+ }
6764
+ response = await self.publicOptionsGetContracts(self.extend(request, params))
6765
+ #
6766
+ # [
6767
+ # {
6768
+ # "is_active": True,
6769
+ # "mark_price_round": "0.1",
6770
+ # "settle_fee_rate": "0.00015",
6771
+ # "bid1_size": 434,
6772
+ # "taker_fee_rate": "0.0003",
6773
+ # "price_limit_fee_rate": "0.1",
6774
+ # "order_price_round": "1",
6775
+ # "tag": "day",
6776
+ # "ref_rebate_rate": "0",
6777
+ # "name": "BTC_USDT-20240324-63500-P",
6778
+ # "strike_price": "63500",
6779
+ # "ask1_price": "387",
6780
+ # "ref_discount_rate": "0",
6781
+ # "order_price_deviate": "0.15",
6782
+ # "ask1_size": -454,
6783
+ # "mark_price_down": "124.3",
6784
+ # "orderbook_id": 29600,
6785
+ # "is_call": False,
6786
+ # "last_price": "0",
6787
+ # "mark_price": "366.6",
6788
+ # "underlying": "BTC_USDT",
6789
+ # "create_time": 1711118829,
6790
+ # "settle_limit_fee_rate": "0.1",
6791
+ # "orders_limit": 10,
6792
+ # "mark_price_up": "630",
6793
+ # "position_size": 0,
6794
+ # "order_size_max": 10000,
6795
+ # "position_limit": 10000,
6796
+ # "multiplier": "0.01",
6797
+ # "order_size_min": 1,
6798
+ # "trade_size": 0,
6799
+ # "underlying_price": "64084.65",
6800
+ # "maker_fee_rate": "0.0003",
6801
+ # "expiration_time": 1711267200,
6802
+ # "trade_id": 0,
6803
+ # "bid1_price": "307"
6804
+ # },
6805
+ # ]
6806
+ #
6807
+ return self.parse_option_chain(response, None, 'name')
6808
+
6809
+ def parse_option(self, chain, currency: Currency = None, market: Market = None):
6810
+ #
6811
+ # {
6812
+ # "is_active": True,
6813
+ # "mark_price_round": "0.1",
6814
+ # "settle_fee_rate": "0.00015",
6815
+ # "bid1_size": 434,
6816
+ # "taker_fee_rate": "0.0003",
6817
+ # "price_limit_fee_rate": "0.1",
6818
+ # "order_price_round": "1",
6819
+ # "tag": "day",
6820
+ # "ref_rebate_rate": "0",
6821
+ # "name": "BTC_USDT-20240324-63500-P",
6822
+ # "strike_price": "63500",
6823
+ # "ask1_price": "387",
6824
+ # "ref_discount_rate": "0",
6825
+ # "order_price_deviate": "0.15",
6826
+ # "ask1_size": -454,
6827
+ # "mark_price_down": "124.3",
6828
+ # "orderbook_id": 29600,
6829
+ # "is_call": False,
6830
+ # "last_price": "0",
6831
+ # "mark_price": "366.6",
6832
+ # "underlying": "BTC_USDT",
6833
+ # "create_time": 1711118829,
6834
+ # "settle_limit_fee_rate": "0.1",
6835
+ # "orders_limit": 10,
6836
+ # "mark_price_up": "630",
6837
+ # "position_size": 0,
6838
+ # "order_size_max": 10000,
6839
+ # "position_limit": 10000,
6840
+ # "multiplier": "0.01",
6841
+ # "order_size_min": 1,
6842
+ # "trade_size": 0,
6843
+ # "underlying_price": "64084.65",
6844
+ # "maker_fee_rate": "0.0003",
6845
+ # "expiration_time": 1711267200,
6846
+ # "trade_id": 0,
6847
+ # "bid1_price": "307"
6848
+ # }
6849
+ #
6850
+ marketId = self.safe_string(chain, 'name')
6851
+ market = self.safe_market(marketId, market)
6852
+ timestamp = self.safe_timestamp(chain, 'create_time')
6853
+ return {
6854
+ 'info': chain,
6855
+ 'currency': None,
6856
+ 'symbol': market['symbol'],
6857
+ 'timestamp': timestamp,
6858
+ 'datetime': self.iso8601(timestamp),
6859
+ 'impliedVolatility': None,
6860
+ 'openInterest': None,
6861
+ 'bidPrice': self.safe_number(chain, 'bid1_price'),
6862
+ 'askPrice': self.safe_number(chain, 'ask1_price'),
6863
+ 'midPrice': None,
6864
+ 'markPrice': self.safe_number(chain, 'mark_price'),
6865
+ 'lastPrice': self.safe_number(chain, 'last_price'),
6866
+ 'underlyingPrice': self.safe_number(chain, 'underlying_price'),
6867
+ 'change': None,
6868
+ 'percentage': None,
6869
+ 'baseVolume': None,
6870
+ 'quoteVolume': None,
6871
+ }
6872
+
6691
6873
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
6692
6874
  if response is None:
6693
6875
  return None
ccxt/async_support/okx.py CHANGED
@@ -1834,16 +1834,27 @@ class okx(Exchange, ImplicitAPI):
1834
1834
  first = self.safe_value(data, 0, {})
1835
1835
  return self.parse_ticker(first, market)
1836
1836
 
1837
- async def fetch_tickers_by_type(self, type, symbols: Strings = None, params={}):
1837
+ async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1838
+ """
1839
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1840
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
1841
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1842
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1843
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
1844
+ """
1838
1845
  await self.load_markets()
1846
+ symbols = self.market_symbols(symbols)
1847
+ market = self.get_market_from_symbols(symbols)
1848
+ marketType = None
1849
+ marketType, params = self.handle_market_type_and_params('fetchTickers', market, params)
1839
1850
  request = {
1840
- 'instType': self.convert_to_instrument_type(type),
1851
+ 'instType': self.convert_to_instrument_type(marketType),
1841
1852
  }
1842
- if type == 'option':
1853
+ if marketType == 'option':
1843
1854
  defaultUnderlying = self.safe_value(self.options, 'defaultUnderlying', 'BTC-USD')
1844
1855
  currencyId = self.safe_string_2(params, 'uly', 'marketId', defaultUnderlying)
1845
1856
  if currencyId is None:
1846
- raise ArgumentsRequired(self.id + ' fetchTickersByType() requires an underlying uly or marketId parameter for options markets')
1857
+ raise ArgumentsRequired(self.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets')
1847
1858
  else:
1848
1859
  request['uly'] = currencyId
1849
1860
  response = await self.publicGetMarketTickers(self.extend(request, params))
@@ -1873,26 +1884,9 @@ class okx(Exchange, ImplicitAPI):
1873
1884
  # ]
1874
1885
  # }
1875
1886
  #
1876
- tickers = self.safe_value(response, 'data', [])
1887
+ tickers = self.safe_list(response, 'data', [])
1877
1888
  return self.parse_tickers(tickers, symbols)
1878
1889
 
1879
- async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1880
- """
1881
- fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1882
- :see: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
1883
- :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1884
- :param dict [params]: extra parameters specific to the exchange API endpoint
1885
- :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
1886
- """
1887
- await self.load_markets()
1888
- symbols = self.market_symbols(symbols)
1889
- first = self.safe_string(symbols, 0)
1890
- market = None
1891
- if first is not None:
1892
- market = self.market(first)
1893
- type, query = self.handle_market_type_and_params('fetchTickers', market, params)
1894
- return await self.fetch_tickers_by_type(type, symbols, query)
1895
-
1896
1890
  def parse_trade(self, trade, market: Market = None) -> Trade:
1897
1891
  #
1898
1892
  # public fetchTrades
@@ -4439,18 +4433,7 @@ class okx(Exchange, ImplicitAPI):
4439
4433
  if fee is None:
4440
4434
  raise ArgumentsRequired(self.id + ' withdraw() requires a "fee" string parameter, network transaction fee must be ≥ 0. Withdrawals to OKCoin or OKX are fee-free, please set "0". Withdrawing to external digital asset address requires network transaction fee.')
4441
4435
  request['fee'] = self.number_to_string(fee) # withdrawals to OKCoin or OKX are fee-free, please set 0
4442
- if 'password' in params:
4443
- request['pwd'] = params['password']
4444
- elif 'pwd' in params:
4445
- request['pwd'] = params['pwd']
4446
- else:
4447
- options = self.safe_value(self.options, 'withdraw', {})
4448
- password = self.safe_string_2(options, 'password', 'pwd')
4449
- if password is not None:
4450
- request['pwd'] = password
4451
- query = self.omit(params, ['fee', 'password', 'pwd'])
4452
- if not ('pwd' in request):
4453
- raise ExchangeError(self.id + ' withdraw() requires a password parameter or a pwd parameter, it must be the funding password, not the API passphrase')
4436
+ query = self.omit(params, ['fee'])
4454
4437
  response = await self.privatePostAssetWithdrawal(self.extend(request, query))
4455
4438
  #
4456
4439
  # {
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.80'
7
+ __version__ = '4.2.81'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10