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