ccxt 4.2.80__py2.py3-none-any.whl → 4.2.82__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.
- 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/bitrue.py +1 -1
- ccxt/async_support/bybit.py +174 -1
- ccxt/async_support/delta.py +146 -1
- ccxt/async_support/deribit.py +1 -1
- ccxt/async_support/gate.py +183 -1
- ccxt/async_support/hyperliquid.py +4 -4
- ccxt/async_support/okx.py +153 -35
- ccxt/base/exchange.py +1 -1
- ccxt/binance.py +89 -1
- ccxt/bitrue.py +1 -1
- ccxt/bybit.py +174 -1
- ccxt/delta.py +146 -1
- ccxt/deribit.py +1 -1
- ccxt/gate.py +183 -1
- ccxt/hyperliquid.py +4 -4
- ccxt/okx.py +153 -35
- ccxt/pro/__init__.py +1 -1
- {ccxt-4.2.80.dist-info → ccxt-4.2.82.dist-info}/METADATA +4 -4
- {ccxt-4.2.80.dist-info → ccxt-4.2.82.dist-info}/RECORD +25 -25
- {ccxt-4.2.80.dist-info → ccxt-4.2.82.dist-info}/WHEEL +0 -0
- {ccxt-4.2.80.dist-info → ccxt-4.2.82.dist-info}/top_level.txt +0 -0
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/delta.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.delta import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, MarginMode, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
|
9
|
+
from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, MarginMode, Market, MarketInterface, Num, Option, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import ArgumentsRequired
|
@@ -71,6 +71,8 @@ class delta(Exchange, ImplicitAPI):
|
|
71
71
|
'fetchOHLCV': True,
|
72
72
|
'fetchOpenInterest': True,
|
73
73
|
'fetchOpenOrders': True,
|
74
|
+
'fetchOption': True,
|
75
|
+
'fetchOptionChain': False,
|
74
76
|
'fetchOrderBook': True,
|
75
77
|
'fetchPosition': True,
|
76
78
|
'fetchPositionMode': False,
|
@@ -3192,6 +3194,149 @@ class delta(Exchange, ImplicitAPI):
|
|
3192
3194
|
'marginMode': self.safe_string(marginMode, 'margin_mode'),
|
3193
3195
|
}
|
3194
3196
|
|
3197
|
+
def fetch_option(self, symbol: str, params={}) -> Option:
|
3198
|
+
"""
|
3199
|
+
fetches option data that is commonly found in an option chain
|
3200
|
+
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
3201
|
+
:param str symbol: unified market symbol
|
3202
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3203
|
+
:returns dict: an `option chain structure <https://docs.ccxt.com/#/?id=option-chain-structure>`
|
3204
|
+
"""
|
3205
|
+
self.load_markets()
|
3206
|
+
market = self.market(symbol)
|
3207
|
+
request = {
|
3208
|
+
'symbol': market['id'],
|
3209
|
+
}
|
3210
|
+
response = self.publicGetTickersSymbol(self.extend(request, params))
|
3211
|
+
#
|
3212
|
+
# {
|
3213
|
+
# "result": {
|
3214
|
+
# "close": 6793.0,
|
3215
|
+
# "contract_type": "call_options",
|
3216
|
+
# "greeks": {
|
3217
|
+
# "delta": "0.94739174",
|
3218
|
+
# "gamma": "0.00002206",
|
3219
|
+
# "rho": "11.00890725",
|
3220
|
+
# "spot": "36839.58124652",
|
3221
|
+
# "theta": "-18.18365310",
|
3222
|
+
# "vega": "7.85209698"
|
3223
|
+
# },
|
3224
|
+
# "high": 7556.0,
|
3225
|
+
# "low": 6793.0,
|
3226
|
+
# "mark_price": "6955.70698909",
|
3227
|
+
# "mark_vol": "0.66916863",
|
3228
|
+
# "oi": "1.8980",
|
3229
|
+
# "oi_change_usd_6h": "110.4600",
|
3230
|
+
# "oi_contracts": "1898",
|
3231
|
+
# "oi_value": "1.8980",
|
3232
|
+
# "oi_value_symbol": "BTC",
|
3233
|
+
# "oi_value_usd": "69940.7319",
|
3234
|
+
# "open": 7.2e3,
|
3235
|
+
# "price_band": {
|
3236
|
+
# "lower_limit": "5533.89814767",
|
3237
|
+
# "upper_limit": "11691.37688371"
|
3238
|
+
# },
|
3239
|
+
# "product_id": 129508,
|
3240
|
+
# "quotes": {
|
3241
|
+
# "ask_iv": "0.90180438",
|
3242
|
+
# "ask_size": "1898",
|
3243
|
+
# "best_ask": "7210",
|
3244
|
+
# "best_bid": "6913",
|
3245
|
+
# "bid_iv": "0.60881706",
|
3246
|
+
# "bid_size": "3163",
|
3247
|
+
# "impact_mid_price": null,
|
3248
|
+
# "mark_iv": "0.66973549"
|
3249
|
+
# },
|
3250
|
+
# "size": 5,
|
3251
|
+
# "spot_price": "36839.58153868",
|
3252
|
+
# "strike_price": "30000",
|
3253
|
+
# "symbol": "C-BTC-30000-241123",
|
3254
|
+
# "timestamp": 1699584998504530,
|
3255
|
+
# "turnover": 184.41206804,
|
3256
|
+
# "turnover_symbol": "USDT",
|
3257
|
+
# "turnover_usd": 184.41206804,
|
3258
|
+
# "volume": 0.005
|
3259
|
+
# },
|
3260
|
+
# "success": True
|
3261
|
+
# }
|
3262
|
+
#
|
3263
|
+
result = self.safe_dict(response, 'result', {})
|
3264
|
+
return self.parse_option(result, None, market)
|
3265
|
+
|
3266
|
+
def parse_option(self, chain, currency: Currency = None, market: Market = None):
|
3267
|
+
#
|
3268
|
+
# {
|
3269
|
+
# "close": 6793.0,
|
3270
|
+
# "contract_type": "call_options",
|
3271
|
+
# "greeks": {
|
3272
|
+
# "delta": "0.94739174",
|
3273
|
+
# "gamma": "0.00002206",
|
3274
|
+
# "rho": "11.00890725",
|
3275
|
+
# "spot": "36839.58124652",
|
3276
|
+
# "theta": "-18.18365310",
|
3277
|
+
# "vega": "7.85209698"
|
3278
|
+
# },
|
3279
|
+
# "high": 7556.0,
|
3280
|
+
# "low": 6793.0,
|
3281
|
+
# "mark_price": "6955.70698909",
|
3282
|
+
# "mark_vol": "0.66916863",
|
3283
|
+
# "oi": "1.8980",
|
3284
|
+
# "oi_change_usd_6h": "110.4600",
|
3285
|
+
# "oi_contracts": "1898",
|
3286
|
+
# "oi_value": "1.8980",
|
3287
|
+
# "oi_value_symbol": "BTC",
|
3288
|
+
# "oi_value_usd": "69940.7319",
|
3289
|
+
# "open": 7.2e3,
|
3290
|
+
# "price_band": {
|
3291
|
+
# "lower_limit": "5533.89814767",
|
3292
|
+
# "upper_limit": "11691.37688371"
|
3293
|
+
# },
|
3294
|
+
# "product_id": 129508,
|
3295
|
+
# "quotes": {
|
3296
|
+
# "ask_iv": "0.90180438",
|
3297
|
+
# "ask_size": "1898",
|
3298
|
+
# "best_ask": "7210",
|
3299
|
+
# "best_bid": "6913",
|
3300
|
+
# "bid_iv": "0.60881706",
|
3301
|
+
# "bid_size": "3163",
|
3302
|
+
# "impact_mid_price": null,
|
3303
|
+
# "mark_iv": "0.66973549"
|
3304
|
+
# },
|
3305
|
+
# "size": 5,
|
3306
|
+
# "spot_price": "36839.58153868",
|
3307
|
+
# "strike_price": "30000",
|
3308
|
+
# "symbol": "C-BTC-30000-241123",
|
3309
|
+
# "timestamp": 1699584998504530,
|
3310
|
+
# "turnover": 184.41206804,
|
3311
|
+
# "turnover_symbol": "USDT",
|
3312
|
+
# "turnover_usd": 184.41206804,
|
3313
|
+
# "volume": 0.005
|
3314
|
+
# }
|
3315
|
+
#
|
3316
|
+
marketId = self.safe_string(chain, 'symbol')
|
3317
|
+
market = self.safe_market(marketId, market)
|
3318
|
+
quotes = self.safe_dict(chain, 'quotes', {})
|
3319
|
+
timestamp = self.safe_integer_product(chain, 'timestamp', 0.001)
|
3320
|
+
return {
|
3321
|
+
'info': chain,
|
3322
|
+
'currency': None,
|
3323
|
+
'symbol': market['symbol'],
|
3324
|
+
'timestamp': timestamp,
|
3325
|
+
'datetime': self.iso8601(timestamp),
|
3326
|
+
'impliedVolatility': self.safe_number(quotes, 'mark_iv'),
|
3327
|
+
'openInterest': self.safe_number(chain, 'oi'),
|
3328
|
+
'bidPrice': self.safe_number(quotes, 'best_bid'),
|
3329
|
+
'askPrice': self.safe_number(quotes, 'best_ask'),
|
3330
|
+
'midPrice': self.safe_number(quotes, 'impact_mid_price'),
|
3331
|
+
'markPrice': self.safe_number(chain, 'mark_price'),
|
3332
|
+
'lastPrice': None,
|
3333
|
+
'underlyingPrice': self.safe_number(chain, 'spot_price'),
|
3334
|
+
'change': None,
|
3335
|
+
'percentage': None,
|
3336
|
+
'baseVolume': self.safe_number(chain, 'volume'),
|
3337
|
+
'quoteVolume': None,
|
3338
|
+
}
|
3339
|
+
|
3195
3340
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
3196
3341
|
requestPath = '/' + self.version + '/' + self.implode_params(path, params)
|
3197
3342
|
url = self.urls['api'][api] + requestPath
|
ccxt/deribit.py
CHANGED
@@ -3403,7 +3403,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3403
3403
|
timestamp = self.safe_integer(chain, 'timestamp')
|
3404
3404
|
return {
|
3405
3405
|
'info': chain,
|
3406
|
-
'currency': code
|
3406
|
+
'currency': code,
|
3407
3407
|
'symbol': market['symbol'],
|
3408
3408
|
'timestamp': timestamp,
|
3409
3409
|
'datetime': self.iso8601(timestamp),
|
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/hyperliquid.py
CHANGED
@@ -50,7 +50,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
50
50
|
'createMarketSellOrderWithCost': False,
|
51
51
|
'createOrder': True,
|
52
52
|
'createOrders': True,
|
53
|
-
'createReduceOnlyOrder':
|
53
|
+
'createReduceOnlyOrder': True,
|
54
54
|
'editOrder': True,
|
55
55
|
'fetchAccounts': False,
|
56
56
|
'fetchBalance': True,
|
@@ -851,7 +851,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
851
851
|
orderType['limit'] = {
|
852
852
|
'tif': timeInForce,
|
853
853
|
}
|
854
|
-
orderParams = self.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id'])
|
854
|
+
orderParams = self.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly'])
|
855
855
|
orderObj = {
|
856
856
|
'a': self.parse_to_int(market['baseId']),
|
857
857
|
'b': isBuy,
|
@@ -1920,9 +1920,9 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1920
1920
|
userAux, params = self.handle_option_and_params(params, methodName, 'user')
|
1921
1921
|
user = userAux
|
1922
1922
|
user, params = self.handle_option_and_params(params, methodName, 'address', userAux)
|
1923
|
-
if user is not None:
|
1923
|
+
if (user is not None) and (user != ''):
|
1924
1924
|
return [user, params]
|
1925
|
-
if self.walletAddress is not None:
|
1925
|
+
if (self.walletAddress is not None) and (self.walletAddress != ''):
|
1926
1926
|
return [self.walletAddress, params]
|
1927
1927
|
raise ArgumentsRequired(self.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set')
|
1928
1928
|
|