ccxt 4.2.79__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.

@@ -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,
@@ -3960,8 +3962,13 @@ class gate(Exchange, ImplicitAPI):
3960
3962
  'account': account,
3961
3963
  }
3962
3964
  if amount is not None:
3963
- amountKey = 'amount' if (market['spot']) else 'size'
3964
- request[amountKey] = self.amount_to_precision(symbol, amount)
3965
+ if market['spot']:
3966
+ request['amount'] = self.amount_to_precision(symbol, amount)
3967
+ else:
3968
+ if side == 'sell':
3969
+ request['size'] = Precise.string_neg(self.amount_to_precision(symbol, amount))
3970
+ else:
3971
+ request['size'] = self.amount_to_precision(symbol, amount)
3965
3972
  if price is not None:
3966
3973
  request['price'] = self.price_to_precision(symbol, price)
3967
3974
  response = None
@@ -4691,8 +4698,8 @@ class gate(Exchange, ImplicitAPI):
4691
4698
  """
4692
4699
  await self.load_markets()
4693
4700
  market = None if (symbol is None) else self.market(symbol)
4694
- stop = self.safe_value(params, 'stop')
4695
- params = self.omit(params, 'stop')
4701
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
4702
+ params = self.omit(params, ['stop', 'trigger'])
4696
4703
  type, query = self.handle_market_type_and_params('cancelAllOrders', market, params)
4697
4704
  request, requestParams = self.multi_order_spot_prepare_request(market, stop, query) if (type == 'spot') else self.prepare_request(market, type, query)
4698
4705
  response = None
@@ -4986,7 +4993,7 @@ class gate(Exchange, ImplicitAPI):
4986
4993
  'unrealizedPnl': self.parse_number(unrealisedPnl),
4987
4994
  'realizedPnl': self.safe_number(position, 'realised_pnl'),
4988
4995
  'contracts': self.parse_number(Precise.string_abs(size)),
4989
- 'contractSize': self.safe_value(market, 'contractSize'),
4996
+ 'contractSize': self.safe_number(market, 'contractSize'),
4990
4997
  # 'realisedPnl': position['realised_pnl'],
4991
4998
  'marginRatio': None,
4992
4999
  'liquidationPrice': self.safe_number(position, 'liq_price'),
@@ -6683,6 +6690,186 @@ class gate(Exchange, ImplicitAPI):
6683
6690
  'shortLeverage': leverageValue,
6684
6691
  }
6685
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
+
6686
6873
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
6687
6874
  if response is None:
6688
6875
  return None
@@ -754,6 +754,8 @@ class hyperliquid(Exchange, ImplicitAPI):
754
754
  """
755
755
  await self.load_markets()
756
756
  market = self.market(symbol)
757
+ vaultAddress = self.safe_string(params, 'vaultAddress')
758
+ params = self.omit(params, 'vaultAddress')
757
759
  symbol = market['symbol']
758
760
  order = {
759
761
  'symbol': symbol,
@@ -763,7 +765,10 @@ class hyperliquid(Exchange, ImplicitAPI):
763
765
  'price': price,
764
766
  'params': params,
765
767
  }
766
- response = await self.create_orders([order], params)
768
+ globalParams = {}
769
+ if vaultAddress is not None:
770
+ globalParams['vaultAddress'] = vaultAddress
771
+ response = await self.create_orders([order], globalParams)
767
772
  first = self.safe_dict(response, 0)
768
773
  return first
769
774
 
@@ -807,7 +812,6 @@ class hyperliquid(Exchange, ImplicitAPI):
807
812
  amount = self.safe_string(rawOrder, 'amount')
808
813
  price = self.safe_string(rawOrder, 'price')
809
814
  orderParams = self.safe_dict(rawOrder, 'params', {})
810
- orderParams = self.extend(params, orderParams)
811
815
  clientOrderId = self.safe_string_2(orderParams, 'clientOrderId', 'client_id')
812
816
  slippage = self.safe_string(orderParams, 'slippage', defaultSlippage)
813
817
  defaultTimeInForce = 'ioc' if (isMarket) else 'gtc'
@@ -847,6 +851,7 @@ class hyperliquid(Exchange, ImplicitAPI):
847
851
  orderType['limit'] = {
848
852
  'tif': timeInForce,
849
853
  }
854
+ orderParams = self.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id'])
850
855
  orderObj = {
851
856
  'a': self.parse_to_int(market['baseId']),
852
857
  'b': isBuy,
@@ -858,8 +863,8 @@ class hyperliquid(Exchange, ImplicitAPI):
858
863
  }
859
864
  if clientOrderId is not None:
860
865
  orderObj['c'] = clientOrderId
861
- orderReq.append(orderObj)
862
- vaultAddress = self.safe_string(params, 'vaultAddress')
866
+ orderReq.append(self.extend(orderObj, orderParams))
867
+ vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
863
868
  orderAction = {
864
869
  'type': 'order',
865
870
  'orders': orderReq,
@@ -875,6 +880,9 @@ class hyperliquid(Exchange, ImplicitAPI):
875
880
  'signature': signature,
876
881
  # 'vaultAddress': vaultAddress,
877
882
  }
883
+ if vaultAddress is not None:
884
+ params = self.omit(params, 'vaultAddress')
885
+ request['vaultAddress'] = vaultAddress
878
886
  response = await self.privatePostExchange(self.extend(request, params))
879
887
  #
880
888
  # {
@@ -957,10 +965,13 @@ class hyperliquid(Exchange, ImplicitAPI):
957
965
  'o': self.parse_to_numeric(ids[i]),
958
966
  })
959
967
  cancelAction['cancels'] = cancelReq
960
- vaultAddress = self.safe_string(params, 'vaultAddress')
968
+ vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
961
969
  signature = self.sign_l1_action(cancelAction, nonce, vaultAddress)
962
970
  request['action'] = cancelAction
963
971
  request['signature'] = signature
972
+ if vaultAddress is not None:
973
+ params = self.omit(params, 'vaultAddress')
974
+ request['vaultAddress'] = vaultAddress
964
975
  response = await self.privatePostExchange(self.extend(request, params))
965
976
  #
966
977
  # {
@@ -1066,7 +1077,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1066
1077
  'type': 'batchModify',
1067
1078
  'modifies': [modifyReq],
1068
1079
  }
1069
- vaultAddress = self.safe_string(params, 'vaultAddress')
1080
+ vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
1070
1081
  signature = self.sign_l1_action(modifyAction, nonce, vaultAddress)
1071
1082
  request = {
1072
1083
  'action': modifyAction,
@@ -1074,6 +1085,9 @@ class hyperliquid(Exchange, ImplicitAPI):
1074
1085
  'signature': signature,
1075
1086
  # 'vaultAddress': vaultAddress,
1076
1087
  }
1088
+ if vaultAddress is not None:
1089
+ params = self.omit(params, 'vaultAddress')
1090
+ request['vaultAddress'] = vaultAddress
1077
1091
  response = await self.privatePostExchange(self.extend(request, params))
1078
1092
  #
1079
1093
  # {
@@ -1643,7 +1657,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1643
1657
  'isolated': isIsolated,
1644
1658
  'hedged': None,
1645
1659
  'side': side,
1646
- 'contracts': self.parse_number(quantity),
1660
+ 'contracts': self.safe_number(entry, 'szi'),
1647
1661
  'contractSize': None,
1648
1662
  'entryPrice': self.safe_number(entry, 'entryPx'),
1649
1663
  'markPrice': None,
@@ -1687,6 +1701,10 @@ class hyperliquid(Exchange, ImplicitAPI):
1687
1701
  'leverage': leverage,
1688
1702
  }
1689
1703
  vaultAddress = self.safe_string(params, 'vaultAddress')
1704
+ if vaultAddress is not None:
1705
+ params = self.omit(params, 'vaultAddress')
1706
+ if vaultAddress.startswith('0x'):
1707
+ vaultAddress = vaultAddress.replace('0x', '')
1690
1708
  signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
1691
1709
  request = {
1692
1710
  'action': updateAction,
@@ -1694,6 +1712,8 @@ class hyperliquid(Exchange, ImplicitAPI):
1694
1712
  'signature': signature,
1695
1713
  # 'vaultAddress': vaultAddress,
1696
1714
  }
1715
+ if vaultAddress is not None:
1716
+ request['vaultAddress'] = vaultAddress
1697
1717
  response = await self.privatePostExchange(self.extend(request, params))
1698
1718
  #
1699
1719
  # {
@@ -1729,7 +1749,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1729
1749
  'isCross': isCross,
1730
1750
  'leverage': leverage,
1731
1751
  }
1732
- vaultAddress = self.safe_string(params, 'vaultAddress')
1752
+ vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
1733
1753
  signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
1734
1754
  request = {
1735
1755
  'action': updateAction,
@@ -1737,6 +1757,9 @@ class hyperliquid(Exchange, ImplicitAPI):
1737
1757
  'signature': signature,
1738
1758
  # 'vaultAddress': vaultAddress,
1739
1759
  }
1760
+ if vaultAddress is not None:
1761
+ params = self.omit(params, 'vaultAddress')
1762
+ request['vaultAddress'] = vaultAddress
1740
1763
  response = await self.privatePostExchange(self.extend(request, params))
1741
1764
  #
1742
1765
  # {
@@ -1784,7 +1807,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1784
1807
  'isBuy': True,
1785
1808
  'ntli': sz,
1786
1809
  }
1787
- vaultAddress = self.safe_string(params, 'vaultAddress')
1810
+ vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
1788
1811
  signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
1789
1812
  request = {
1790
1813
  'action': updateAction,
@@ -1792,6 +1815,9 @@ class hyperliquid(Exchange, ImplicitAPI):
1792
1815
  'signature': signature,
1793
1816
  # 'vaultAddress': vaultAddress,
1794
1817
  }
1818
+ if vaultAddress is not None:
1819
+ params = self.omit(params, 'vaultAddress')
1820
+ request['vaultAddress'] = vaultAddress
1795
1821
  response = await self.privatePostExchange(self.extend(request, params))
1796
1822
  #
1797
1823
  # {
@@ -1882,6 +1908,13 @@ class hyperliquid(Exchange, ImplicitAPI):
1882
1908
  response = await self.privatePostExchange(self.extend(request, params))
1883
1909
  return response
1884
1910
 
1911
+ def format_vault_address(self, address: Str = None):
1912
+ if address is None:
1913
+ return None
1914
+ if address.startswith('0x'):
1915
+ return address.replace('0x', '')
1916
+ return address
1917
+
1885
1918
  def handle_public_address(self, methodName: str, params: dict):
1886
1919
  userAux = None
1887
1920
  userAux, params = self.handle_option_and_params(params, methodName, 'user')
@@ -899,8 +899,8 @@ class mexc(Exchange, ImplicitAPI):
899
899
  '30032': InvalidOrder, # Cannot exceed the maximum position
900
900
  '30041': InvalidOrder, # current order type can not place order
901
901
  '60005': ExchangeError, # your account is abnormal
902
- '700001': AuthenticationError, # API-key format invalid
903
- '700002': AuthenticationError, # Signature for self request is not valid
902
+ '700001': AuthenticationError, # {"code":700002,"msg":"Signature for self request is not valid."} # same message for expired API keys
903
+ '700002': AuthenticationError, # Signature for self request is not valid # or the API secret is incorrect
904
904
  '700004': BadRequest, # Param 'origClientOrderId' or 'orderId' must be sent, but both were empty/null
905
905
  '700005': InvalidNonce, # recvWindow must less than 60000
906
906
  '700006': BadRequest, # IP non white list
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
  # {
@@ -85,6 +85,7 @@ class upbit(Exchange, ImplicitAPI):
85
85
  '1m': 'minutes',
86
86
  '3m': 'minutes',
87
87
  '5m': 'minutes',
88
+ '10m': 'minutes',
88
89
  '15m': 'minutes',
89
90
  '30m': 'minutes',
90
91
  '1h': 'minutes',
@@ -114,6 +115,7 @@ class upbit(Exchange, ImplicitAPI):
114
115
  'candles/minutes/1',
115
116
  'candles/minutes/3',
116
117
  'candles/minutes/5',
118
+ 'candles/minutes/10',
117
119
  'candles/minutes/15',
118
120
  'candles/minutes/30',
119
121
  'candles/minutes/60',
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.79'
7
+ __version__ = '4.2.81'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -31,7 +31,7 @@ from ccxt.base.decimal_to_precision import decimal_to_precision
31
31
  from ccxt.base.decimal_to_precision import DECIMAL_PLACES, TICK_SIZE, NO_PADDING, TRUNCATE, ROUND, ROUND_UP, ROUND_DOWN, SIGNIFICANT_DIGITS
32
32
  from ccxt.base.decimal_to_precision import number_to_string
33
33
  from ccxt.base.precise import Precise
34
- from ccxt.base.types import BalanceAccount, Currency, IndexType, OrderSide, OrderType, Trade, OrderRequest, Market, MarketType, Str, Num
34
+ from ccxt.base.types import BalanceAccount, Currency, IndexType, OrderSide, OrderType, Trade, OrderRequest, Market, MarketType, Str, Num, Strings
35
35
 
36
36
  # -----------------------------------------------------------------------------
37
37
 
@@ -1728,6 +1728,12 @@ class Exchange(object):
1728
1728
  modifiedContent = modifiedContent.replace('}"', '}')
1729
1729
  return modifiedContent
1730
1730
 
1731
+ def extend_exchange_options(self, newOptions):
1732
+ self.options = self.extend(self.options, newOptions)
1733
+
1734
+ def create_safe_dictionary(self):
1735
+ return {}
1736
+
1731
1737
  # ########################################################################
1732
1738
  # ########################################################################
1733
1739
  # ########################################################################
@@ -3187,7 +3193,7 @@ class Exchange(object):
3187
3193
  else:
3188
3194
  raise BadResponse(errorMessage)
3189
3195
 
3190
- def market_ids(self, symbols):
3196
+ def market_ids(self, symbols: Strings = None):
3191
3197
  if symbols is None:
3192
3198
  return symbols
3193
3199
  result = []
@@ -3195,7 +3201,7 @@ class Exchange(object):
3195
3201
  result.append(self.market_id(symbols[i]))
3196
3202
  return result
3197
3203
 
3198
- def market_symbols(self, symbols, type: Str = None, allowEmpty=True, sameTypeOnly=False, sameSubTypeOnly=False):
3204
+ def market_symbols(self, symbols: Strings = None, type: Str = None, allowEmpty=True, sameTypeOnly=False, sameSubTypeOnly=False):
3199
3205
  if symbols is None:
3200
3206
  if not allowEmpty:
3201
3207
  raise ArgumentsRequired(self.id + ' empty list of symbols is not supported')
@@ -3225,7 +3231,7 @@ class Exchange(object):
3225
3231
  result.append(symbol)
3226
3232
  return result
3227
3233
 
3228
- def market_codes(self, codes):
3234
+ def market_codes(self, codes: Strings = None):
3229
3235
  if codes is None:
3230
3236
  return codes
3231
3237
  result = []
@@ -4025,6 +4031,9 @@ class Exchange(object):
4025
4031
  def fetch_order_books(self, symbols: List[str] = None, limit: Int = None, params={}):
4026
4032
  raise NotSupported(self.id + ' fetchOrderBooks() is not supported yet')
4027
4033
 
4034
+ def watch_bids_asks(self, symbols: List[str] = None, params={}):
4035
+ raise NotSupported(self.id + ' watchBidsAsks() is not supported yet')
4036
+
4028
4037
  def watch_tickers(self, symbols: List[str] = None, params={}):
4029
4038
  raise NotSupported(self.id + ' watchTickers() is not supported yet')
4030
4039
 
@@ -4327,6 +4336,12 @@ class Exchange(object):
4327
4336
  def fetch_greeks(self, symbol: str, params={}):
4328
4337
  raise NotSupported(self.id + ' fetchGreeks() is not supported yet')
4329
4338
 
4339
+ def fetch_option_chain(self, code: str, params={}):
4340
+ raise NotSupported(self.id + ' fetchOptionChain() is not supported yet')
4341
+
4342
+ def fetch_option(self, symbol: str, params={}):
4343
+ raise NotSupported(self.id + ' fetchOption() is not supported yet')
4344
+
4330
4345
  def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
4331
4346
  """
4332
4347
  fetch history of deposits and withdrawals
@@ -5324,6 +5339,20 @@ class Exchange(object):
5324
5339
  def parse_greeks(self, greeks, market: Market = None):
5325
5340
  raise NotSupported(self.id + ' parseGreeks() is not supported yet')
5326
5341
 
5342
+ def parse_option(self, chain, currency: Currency = None, market: Market = None):
5343
+ raise NotSupported(self.id + ' parseOption() is not supported yet')
5344
+
5345
+ def parse_option_chain(self, response: List[object], currencyKey: Str = None, symbolKey: Str = None):
5346
+ optionStructures = {}
5347
+ for i in range(0, len(response)):
5348
+ info = response[i]
5349
+ currencyId = self.safe_string(info, currencyKey)
5350
+ currency = self.safe_currency(currencyId)
5351
+ marketId = self.safe_string(info, symbolKey)
5352
+ market = self.safe_market(marketId, None, None, 'option')
5353
+ optionStructures[market['symbol']] = self.parseOption(info, currency, market)
5354
+ return optionStructures
5355
+
5327
5356
  def parse_margin_modes(self, response: List[object], symbols: List[str] = None, symbolKey: Str = None, marketType: MarketType = None):
5328
5357
  marginModeStructures = {}
5329
5358
  for i in range(0, len(response)):
ccxt/base/types.py CHANGED
@@ -53,6 +53,7 @@ Strings = Optional[List[str]]
53
53
  Int = Optional[int]
54
54
  Bool = Optional[bool]
55
55
  MarketType = Literal['spot', 'margin', 'swap', 'future', 'option']
56
+ SubType = Literal['linear', 'inverse']
56
57
 
57
58
 
58
59
  class FeeInterface(TypedDict):
@@ -301,6 +302,28 @@ class Greeks(TypedDict):
301
302
  info: Dict[str, Any]
302
303
 
303
304
 
305
+ class Option(TypedDict):
306
+ info: Dict[str, Any]
307
+ currency: Str
308
+ symbol: Str
309
+ timestamp: Int
310
+ datetime: Str
311
+ impliedVolatility: Num
312
+ openInterest: Num
313
+ bidPrice: Num
314
+ askPrice: Num
315
+ midPrice: Num
316
+ markPrice: Num
317
+ lastPrice: Num
318
+ underlyingPrice: Num
319
+ change: Num
320
+ percentage: Num
321
+ baseVolume: Num
322
+ quoteVolume: Num
323
+
324
+
325
+ OptionChain = Dict[str, Option]
326
+
304
327
  class MarketInterface(TypedDict):
305
328
  info: Dict[str, Any]
306
329
  id: Str