ccxt 4.4.92__py2.py3-none-any.whl → 4.4.93__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/abstract/lbank.py +1 -1
- ccxt/ascendex.py +9 -8
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +9 -8
- ccxt/async_support/base/exchange.py +4 -1
- ccxt/async_support/base/ws/client.py +3 -0
- ccxt/async_support/binance.py +42 -1
- ccxt/async_support/bitmex.py +3 -3
- ccxt/async_support/bybit.py +81 -8
- ccxt/async_support/coinbaseexchange.py +53 -0
- ccxt/async_support/coincheck.py +45 -4
- ccxt/async_support/coinex.py +16 -12
- ccxt/async_support/cryptomus.py +30 -52
- ccxt/async_support/deribit.py +6 -6
- ccxt/async_support/exmo.py +64 -52
- ccxt/async_support/hyperliquid.py +2 -1
- ccxt/async_support/kucoin.py +12 -14
- ccxt/async_support/latoken.py +19 -71
- ccxt/async_support/lbank.py +2 -2
- ccxt/async_support/okx.py +149 -0
- ccxt/async_support/paradex.py +54 -0
- ccxt/async_support/phemex.py +3 -3
- ccxt/base/exchange.py +55 -12
- ccxt/binance.py +42 -1
- ccxt/bitmex.py +3 -3
- ccxt/bybit.py +81 -8
- ccxt/coinbaseexchange.py +53 -0
- ccxt/coincheck.py +45 -4
- ccxt/coinex.py +16 -12
- ccxt/cryptomus.py +30 -52
- ccxt/deribit.py +6 -6
- ccxt/exmo.py +64 -52
- ccxt/hyperliquid.py +2 -1
- ccxt/kucoin.py +12 -14
- ccxt/latoken.py +19 -71
- ccxt/lbank.py +2 -2
- ccxt/okx.py +149 -0
- ccxt/paradex.py +54 -0
- ccxt/phemex.py +3 -3
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitstamp.py +48 -16
- ccxt/pro/bybit.py +2 -1
- {ccxt-4.4.92.dist-info → ccxt-4.4.93.dist-info}/METADATA +4 -4
- {ccxt-4.4.92.dist-info → ccxt-4.4.93.dist-info}/RECORD +48 -48
- {ccxt-4.4.92.dist-info → ccxt-4.4.93.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.92.dist-info → ccxt-4.4.93.dist-info}/WHEEL +0 -0
- {ccxt-4.4.92.dist-info → ccxt-4.4.93.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/lbank.py
CHANGED
@@ -6,7 +6,7 @@ class ImplicitAPI:
|
|
6
6
|
spot_public_get_accuracy = spotPublicGetAccuracy = Entry('accuracy', ['spot', 'public'], 'GET', {'cost': 2.5})
|
7
7
|
spot_public_get_usdtocny = spotPublicGetUsdToCny = Entry('usdToCny', ['spot', 'public'], 'GET', {'cost': 2.5})
|
8
8
|
spot_public_get_assetconfigs = spotPublicGetAssetConfigs = Entry('assetConfigs', ['spot', 'public'], 'GET', {'cost': 2.5})
|
9
|
-
spot_public_get_withdrawconfigs = spotPublicGetWithdrawConfigs = Entry('withdrawConfigs', ['spot', 'public'], 'GET', {'cost':
|
9
|
+
spot_public_get_withdrawconfigs = spotPublicGetWithdrawConfigs = Entry('withdrawConfigs', ['spot', 'public'], 'GET', {'cost': 3.75})
|
10
10
|
spot_public_get_timestamp = spotPublicGetTimestamp = Entry('timestamp', ['spot', 'public'], 'GET', {'cost': 2.5})
|
11
11
|
spot_public_get_ticker_24hr = spotPublicGetTicker24hr = Entry('ticker/24hr', ['spot', 'public'], 'GET', {'cost': 2.5})
|
12
12
|
spot_public_get_ticker = spotPublicGetTicker = Entry('ticker', ['spot', 'public'], 'GET', {'cost': 2.5})
|
ccxt/ascendex.py
CHANGED
@@ -1403,6 +1403,8 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1403
1403
|
# "timestamp": 1573576916201
|
1404
1404
|
# }
|
1405
1405
|
#
|
1406
|
+
# & linear(fetchClosedOrders)
|
1407
|
+
#
|
1406
1408
|
# {
|
1407
1409
|
# "ac": "FUTURES",
|
1408
1410
|
# "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
@@ -1410,7 +1412,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1410
1412
|
# "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
|
1411
1413
|
# "seqNum": -1,
|
1412
1414
|
# "orderType": "Limit",
|
1413
|
-
# "execInst": "NULL_VAL",
|
1415
|
+
# "execInst": "NULL_VAL", # NULL_VAL, ReduceOnly , ...
|
1414
1416
|
# "side": "Buy",
|
1415
1417
|
# "symbol": "BTC-PERP",
|
1416
1418
|
# "price": "30000",
|
@@ -1499,13 +1501,13 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1499
1501
|
status = self.parse_order_status(self.safe_string(order, 'status'))
|
1500
1502
|
marketId = self.safe_string(order, 'symbol')
|
1501
1503
|
symbol = self.safe_symbol(marketId, market, '/')
|
1502
|
-
timestamp = self.
|
1504
|
+
timestamp = self.safe_integer_n(order, ['timestamp', 'sendingTime', 'time'])
|
1503
1505
|
lastTradeTimestamp = self.safe_integer(order, 'lastExecTime')
|
1504
1506
|
if timestamp is None:
|
1505
1507
|
timestamp = lastTradeTimestamp
|
1506
1508
|
price = self.safe_string(order, 'price')
|
1507
1509
|
amount = self.safe_string(order, 'orderQty')
|
1508
|
-
average = self.
|
1510
|
+
average = self.safe_string_2(order, 'avgPx', 'avgFilledPx')
|
1509
1511
|
filled = self.safe_string_n(order, ['cumFilledQty', 'cumQty', 'fillQty'])
|
1510
1512
|
id = self.safe_string(order, 'orderId')
|
1511
1513
|
clientOrderId = self.safe_string(order, 'id')
|
@@ -1531,11 +1533,11 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1531
1533
|
}
|
1532
1534
|
triggerPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
|
1533
1535
|
reduceOnly = None
|
1534
|
-
execInst = self.
|
1535
|
-
if execInst == '
|
1536
|
+
execInst = self.safe_string_lower(order, 'execInst')
|
1537
|
+
if execInst == 'reduceonly':
|
1536
1538
|
reduceOnly = True
|
1537
1539
|
postOnly = None
|
1538
|
-
if execInst == '
|
1540
|
+
if execInst == 'post':
|
1539
1541
|
postOnly = True
|
1540
1542
|
return self.safe_order({
|
1541
1543
|
'info': order,
|
@@ -2246,8 +2248,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
2246
2248
|
# }
|
2247
2249
|
#
|
2248
2250
|
data = self.safe_list(response, 'data', [])
|
2249
|
-
|
2250
|
-
if not isArray:
|
2251
|
+
if not isinstance(data, list):
|
2251
2252
|
data = self.safe_list(data, 'data', [])
|
2252
2253
|
return self.parse_orders(data, market, since, limit)
|
2253
2254
|
|
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/ascendex.py
CHANGED
@@ -1404,6 +1404,8 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1404
1404
|
# "timestamp": 1573576916201
|
1405
1405
|
# }
|
1406
1406
|
#
|
1407
|
+
# & linear(fetchClosedOrders)
|
1408
|
+
#
|
1407
1409
|
# {
|
1408
1410
|
# "ac": "FUTURES",
|
1409
1411
|
# "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
@@ -1411,7 +1413,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1411
1413
|
# "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
|
1412
1414
|
# "seqNum": -1,
|
1413
1415
|
# "orderType": "Limit",
|
1414
|
-
# "execInst": "NULL_VAL",
|
1416
|
+
# "execInst": "NULL_VAL", # NULL_VAL, ReduceOnly , ...
|
1415
1417
|
# "side": "Buy",
|
1416
1418
|
# "symbol": "BTC-PERP",
|
1417
1419
|
# "price": "30000",
|
@@ -1500,13 +1502,13 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1500
1502
|
status = self.parse_order_status(self.safe_string(order, 'status'))
|
1501
1503
|
marketId = self.safe_string(order, 'symbol')
|
1502
1504
|
symbol = self.safe_symbol(marketId, market, '/')
|
1503
|
-
timestamp = self.
|
1505
|
+
timestamp = self.safe_integer_n(order, ['timestamp', 'sendingTime', 'time'])
|
1504
1506
|
lastTradeTimestamp = self.safe_integer(order, 'lastExecTime')
|
1505
1507
|
if timestamp is None:
|
1506
1508
|
timestamp = lastTradeTimestamp
|
1507
1509
|
price = self.safe_string(order, 'price')
|
1508
1510
|
amount = self.safe_string(order, 'orderQty')
|
1509
|
-
average = self.
|
1511
|
+
average = self.safe_string_2(order, 'avgPx', 'avgFilledPx')
|
1510
1512
|
filled = self.safe_string_n(order, ['cumFilledQty', 'cumQty', 'fillQty'])
|
1511
1513
|
id = self.safe_string(order, 'orderId')
|
1512
1514
|
clientOrderId = self.safe_string(order, 'id')
|
@@ -1532,11 +1534,11 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1532
1534
|
}
|
1533
1535
|
triggerPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
|
1534
1536
|
reduceOnly = None
|
1535
|
-
execInst = self.
|
1536
|
-
if execInst == '
|
1537
|
+
execInst = self.safe_string_lower(order, 'execInst')
|
1538
|
+
if execInst == 'reduceonly':
|
1537
1539
|
reduceOnly = True
|
1538
1540
|
postOnly = None
|
1539
|
-
if execInst == '
|
1541
|
+
if execInst == 'post':
|
1540
1542
|
postOnly = True
|
1541
1543
|
return self.safe_order({
|
1542
1544
|
'info': order,
|
@@ -2247,8 +2249,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
2247
2249
|
# }
|
2248
2250
|
#
|
2249
2251
|
data = self.safe_list(response, 'data', [])
|
2250
|
-
|
2251
|
-
if not isArray:
|
2252
|
+
if not isinstance(data, list):
|
2252
2253
|
data = self.safe_list(data, 'data', [])
|
2253
2254
|
return self.parse_orders(data, market, since, limit)
|
2254
2255
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.4.
|
5
|
+
__version__ = '4.4.93'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -1573,6 +1573,9 @@ class Exchange(BaseExchange):
|
|
1573
1573
|
async def fetch_greeks(self, symbol: str, params={}):
|
1574
1574
|
raise NotSupported(self.id + ' fetchGreeks() is not supported yet')
|
1575
1575
|
|
1576
|
+
async def fetch_all_greeks(self, symbols: Strings = None, params={}):
|
1577
|
+
raise NotSupported(self.id + ' fetchAllGreeks() is not supported yet')
|
1578
|
+
|
1576
1579
|
async def fetch_option_chain(self, code: str, params={}):
|
1577
1580
|
raise NotSupported(self.id + ' fetchOptionChain() is not supported yet')
|
1578
1581
|
|
@@ -137,6 +137,9 @@ class Client(object):
|
|
137
137
|
self.reject(error)
|
138
138
|
|
139
139
|
task.add_done_callback(after_interrupt)
|
140
|
+
else:
|
141
|
+
# connection got terminated after the connection was made and before the receive loop ran
|
142
|
+
self.on_close(1006)
|
140
143
|
|
141
144
|
async def open(self, session, backoff_delay=0):
|
142
145
|
# exponential backoff for consequent connections if necessary
|
ccxt/async_support/binance.py
CHANGED
@@ -88,6 +88,7 @@ class binance(Exchange, ImplicitAPI):
|
|
88
88
|
'editOrder': True,
|
89
89
|
'editOrders': True,
|
90
90
|
'fetchAccounts': None,
|
91
|
+
'fetchAllGreeks': True,
|
91
92
|
'fetchBalance': True,
|
92
93
|
'fetchBidsAsks': True,
|
93
94
|
'fetchBorrowInterest': True,
|
@@ -10778,6 +10779,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10778
10779
|
request: dict = {}
|
10779
10780
|
if symbol is not None:
|
10780
10781
|
request['symbol'] = market['id']
|
10782
|
+
symbol = market['symbol']
|
10781
10783
|
if since is not None:
|
10782
10784
|
request['startTime'] = since
|
10783
10785
|
if limit is not None:
|
@@ -10805,7 +10807,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10805
10807
|
#
|
10806
10808
|
settlements = self.parse_settlements(response, market)
|
10807
10809
|
sorted = self.sort_by(settlements, 'timestamp')
|
10808
|
-
return self.filter_by_symbol_since_limit(sorted,
|
10810
|
+
return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
|
10809
10811
|
|
10810
10812
|
def parse_settlement(self, settlement, market):
|
10811
10813
|
#
|
@@ -12423,6 +12425,45 @@ class binance(Exchange, ImplicitAPI):
|
|
12423
12425
|
#
|
12424
12426
|
return self.parse_greeks(response[0], market)
|
12425
12427
|
|
12428
|
+
async def fetch_all_greeks(self, symbols: Strings = None, params={}) -> List[Greeks]:
|
12429
|
+
"""
|
12430
|
+
fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
12431
|
+
|
12432
|
+
https://developers.binance.com/docs/derivatives/option/market-data/Option-Mark-Price
|
12433
|
+
|
12434
|
+
:param str[] [symbols]: unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
12435
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
12436
|
+
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
|
12437
|
+
"""
|
12438
|
+
await self.load_markets()
|
12439
|
+
symbols = self.market_symbols(symbols, None, True, True, True)
|
12440
|
+
request: dict = {}
|
12441
|
+
market = None
|
12442
|
+
if symbols is not None:
|
12443
|
+
symbolsLength = len(symbols)
|
12444
|
+
if symbolsLength == 1:
|
12445
|
+
market = self.market(symbols[0])
|
12446
|
+
request['symbol'] = market['id']
|
12447
|
+
response = await self.eapiPublicGetMark(self.extend(request, params))
|
12448
|
+
#
|
12449
|
+
# [
|
12450
|
+
# {
|
12451
|
+
# "symbol": "BTC-231229-40000-C",
|
12452
|
+
# "markPrice": "2012",
|
12453
|
+
# "bidIV": "0.60236275",
|
12454
|
+
# "askIV": "0.62267244",
|
12455
|
+
# "markIV": "0.6125176",
|
12456
|
+
# "delta": "0.39111646",
|
12457
|
+
# "theta": "-32.13948531",
|
12458
|
+
# "gamma": "0.00004656",
|
12459
|
+
# "vega": "51.70062218",
|
12460
|
+
# "highPriceLimit": "6474",
|
12461
|
+
# "lowPriceLimit": "5"
|
12462
|
+
# }
|
12463
|
+
# ]
|
12464
|
+
#
|
12465
|
+
return self.parse_all_greeks(response, symbols)
|
12466
|
+
|
12426
12467
|
def parse_greeks(self, greeks: dict, market: Market = None) -> Greeks:
|
12427
12468
|
#
|
12428
12469
|
# {
|
ccxt/async_support/bitmex.py
CHANGED
@@ -1924,7 +1924,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1924
1924
|
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1925
1925
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1926
1926
|
:param dict [params.triggerPrice]: the price at which a trigger order is triggered at
|
1927
|
-
:param dict [params.triggerDirection]: the direction whenever the trigger happens with relation to price - '
|
1927
|
+
:param dict [params.triggerDirection]: the direction whenever the trigger happens with relation to price - 'ascending' or 'descending'
|
1928
1928
|
:param float [params.trailingAmount]: the quote amount to trail away from the current market price
|
1929
1929
|
:returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
|
1930
1930
|
"""
|
@@ -1951,7 +1951,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1951
1951
|
isTrailingAmountOrder = trailingAmount is not None
|
1952
1952
|
if isTriggerOrder or isTrailingAmountOrder:
|
1953
1953
|
triggerDirection = self.safe_string(params, 'triggerDirection')
|
1954
|
-
triggerAbove = (triggerDirection == 'above')
|
1954
|
+
triggerAbove = ((triggerDirection == 'ascending') or (triggerDirection == 'above'))
|
1955
1955
|
if (type == 'limit') or (type == 'market'):
|
1956
1956
|
self.check_required_argument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below'])
|
1957
1957
|
if type == 'limit':
|
@@ -1994,7 +1994,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1994
1994
|
isTrailingAmountOrder = trailingAmount is not None
|
1995
1995
|
if isTrailingAmountOrder:
|
1996
1996
|
triggerDirection = self.safe_string(params, 'triggerDirection')
|
1997
|
-
triggerAbove = (triggerDirection == 'above')
|
1997
|
+
triggerAbove = ((triggerDirection == 'ascending') or (triggerDirection == 'above'))
|
1998
1998
|
if (type == 'limit') or (type == 'market'):
|
1999
1999
|
self.check_required_argument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below'])
|
2000
2000
|
orderType = None
|
ccxt/async_support/bybit.py
CHANGED
@@ -75,6 +75,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
75
75
|
'createTriggerOrder': True,
|
76
76
|
'editOrder': True,
|
77
77
|
'editOrders': True,
|
78
|
+
'fetchAllGreeks': True,
|
78
79
|
'fetchBalance': True,
|
79
80
|
'fetchBidsAsks': 'emulated',
|
80
81
|
'fetchBorrowInterest': False, # temporarily disabled, doesn't work
|
@@ -1173,6 +1174,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
1173
1174
|
'4h': '4h',
|
1174
1175
|
'1d': '1d',
|
1175
1176
|
},
|
1177
|
+
'useMarkPriceForPositionCollateral': False, # use mark price for position collateral
|
1176
1178
|
},
|
1177
1179
|
'features': {
|
1178
1180
|
'default': {
|
@@ -3726,7 +3728,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3726
3728
|
:param int [params.isLeverage]: *unified spot only* False then spot trading True then margin trading
|
3727
3729
|
:param str [params.tpslMode]: *contract only* 'full' or 'partial'
|
3728
3730
|
:param str [params.mmp]: *option only* market maker protection
|
3729
|
-
:param str [params.triggerDirection]: *contract only* the direction for trigger orders, '
|
3731
|
+
:param str [params.triggerDirection]: *contract only* the direction for trigger orders, 'ascending' or 'descending'
|
3730
3732
|
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
3731
3733
|
:param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
|
3732
3734
|
:param float [params.takeProfitPrice]: The price at which a take profit order is triggered at
|
@@ -3936,8 +3938,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
3936
3938
|
raise NotSupported(self.id + ' createOrder() : trigger order does not support triggerDirection for spot markets yet')
|
3937
3939
|
else:
|
3938
3940
|
if triggerDirection is None:
|
3939
|
-
raise ArgumentsRequired(self.id + ' stop/trigger orders require a triggerDirection parameter, either "
|
3940
|
-
isAsending = ((triggerDirection == 'above') or (triggerDirection == '1'))
|
3941
|
+
raise ArgumentsRequired(self.id + ' stop/trigger orders require a triggerDirection parameter, either "ascending" or "descending" to determine the direction of the trigger.')
|
3942
|
+
isAsending = ((triggerDirection == 'ascending') or (triggerDirection == 'above') or (triggerDirection == '1'))
|
3941
3943
|
request['triggerDirection'] = 1 if isAsending else 2
|
3942
3944
|
request['triggerPrice'] = self.get_price(symbol, triggerPrice)
|
3943
3945
|
elif (isStopLossTriggerOrder or isTakeProfitTriggerOrder) and not isAlternativeEndpoint:
|
@@ -6214,12 +6216,14 @@ classic accounts only/ spot not supported* fetches information on an order made
|
|
6214
6216
|
marginMode = 'isolated' if (tradeMode == 1) else 'cross'
|
6215
6217
|
collateralString = self.safe_string(position, 'positionBalance')
|
6216
6218
|
entryPrice = self.omit_zero(self.safe_string_n(position, ['entryPrice', 'avgPrice', 'avgEntryPrice']))
|
6219
|
+
markPrice = self.safe_string(position, 'markPrice')
|
6217
6220
|
liquidationPrice = self.omit_zero(self.safe_string(position, 'liqPrice'))
|
6218
6221
|
leverage = self.safe_string(position, 'leverage')
|
6219
6222
|
if liquidationPrice is not None:
|
6220
6223
|
if market['settle'] == 'USDC':
|
6221
6224
|
# (Entry price - Liq price) * Contracts + Maintenance Margin + (unrealised pnl) = Collateral
|
6222
|
-
|
6225
|
+
price = markPrice if self.safe_bool(self.options, 'useMarkPriceForPositionCollateral', False) else entryPrice
|
6226
|
+
difference = Precise.string_abs(Precise.string_sub(price, liquidationPrice))
|
6223
6227
|
collateralString = Precise.string_add(Precise.string_add(Precise.string_mul(difference, size), maintenanceMarginString), unrealisedPnl)
|
6224
6228
|
else:
|
6225
6229
|
bustPrice = self.safe_string(position, 'bustPrice')
|
@@ -6268,7 +6272,7 @@ classic accounts only/ spot not supported* fetches information on an order made
|
|
6268
6272
|
'contractSize': self.safe_number(market, 'contractSize'),
|
6269
6273
|
'marginRatio': self.parse_number(marginRatio),
|
6270
6274
|
'liquidationPrice': self.parse_number(liquidationPrice),
|
6271
|
-
'markPrice': self.
|
6275
|
+
'markPrice': self.parse_number(markPrice),
|
6272
6276
|
'lastPrice': self.safe_number(position, 'avgExitPrice'),
|
6273
6277
|
'collateral': self.parse_number(collateralString),
|
6274
6278
|
'marginMode': marginMode,
|
@@ -7625,6 +7629,75 @@ classic accounts only/ spot not supported* fetches information on an order made
|
|
7625
7629
|
'datetime': self.iso8601(timestamp),
|
7626
7630
|
})
|
7627
7631
|
|
7632
|
+
async def fetch_all_greeks(self, symbols: Strings = None, params={}) -> List[Greeks]:
|
7633
|
+
"""
|
7634
|
+
fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
|
7635
|
+
|
7636
|
+
https://bybit-exchange.github.io/docs/api-explorer/v5/market/tickers
|
7637
|
+
|
7638
|
+
:param str[] [symbols]: unified symbols of the markets to fetch greeks for, all markets are returned if not assigned
|
7639
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7640
|
+
:param str [params.baseCoin]: the baseCoin of the symbol, default is BTC
|
7641
|
+
:returns dict: a `greeks structure <https://docs.ccxt.com/#/?id=greeks-structure>`
|
7642
|
+
"""
|
7643
|
+
await self.load_markets()
|
7644
|
+
symbols = self.market_symbols(symbols, None, True, True, True)
|
7645
|
+
baseCoin = self.safe_string(params, 'baseCoin', 'BTC')
|
7646
|
+
request: dict = {
|
7647
|
+
'category': 'option',
|
7648
|
+
'baseCoin': baseCoin,
|
7649
|
+
}
|
7650
|
+
market = None
|
7651
|
+
if symbols is not None:
|
7652
|
+
symbolsLength = len(symbols)
|
7653
|
+
if symbolsLength == 1:
|
7654
|
+
market = self.market(symbols[0])
|
7655
|
+
request['symbol'] = market['id']
|
7656
|
+
response = await self.publicGetV5MarketTickers(self.extend(request, params))
|
7657
|
+
#
|
7658
|
+
# {
|
7659
|
+
# "retCode": 0,
|
7660
|
+
# "retMsg": "SUCCESS",
|
7661
|
+
# "result": {
|
7662
|
+
# "category": "option",
|
7663
|
+
# "list": [
|
7664
|
+
# {
|
7665
|
+
# "symbol": "BTC-26JAN24-39000-C",
|
7666
|
+
# "bid1Price": "3205",
|
7667
|
+
# "bid1Size": "7.1",
|
7668
|
+
# "bid1Iv": "0.5478",
|
7669
|
+
# "ask1Price": "3315",
|
7670
|
+
# "ask1Size": "1.98",
|
7671
|
+
# "ask1Iv": "0.5638",
|
7672
|
+
# "lastPrice": "3230",
|
7673
|
+
# "highPrice24h": "3255",
|
7674
|
+
# "lowPrice24h": "3200",
|
7675
|
+
# "markPrice": "3273.02263032",
|
7676
|
+
# "indexPrice": "36790.96",
|
7677
|
+
# "markIv": "0.5577",
|
7678
|
+
# "underlyingPrice": "37649.67254894",
|
7679
|
+
# "openInterest": "19.67",
|
7680
|
+
# "turnover24h": "170140.33875912",
|
7681
|
+
# "volume24h": "4.56",
|
7682
|
+
# "totalVolume": "22",
|
7683
|
+
# "totalTurnover": "789305",
|
7684
|
+
# "delta": "0.49640971",
|
7685
|
+
# "gamma": "0.00004131",
|
7686
|
+
# "vega": "69.08651675",
|
7687
|
+
# "theta": "-24.9443226",
|
7688
|
+
# "predictedDeliveryPrice": "0",
|
7689
|
+
# "change24h": "0.18532111"
|
7690
|
+
# }
|
7691
|
+
# ]
|
7692
|
+
# },
|
7693
|
+
# "retExtInfo": {},
|
7694
|
+
# "time": 1699584008326
|
7695
|
+
# }
|
7696
|
+
#
|
7697
|
+
result = self.safe_dict(response, 'result', {})
|
7698
|
+
data = self.safe_list(result, 'list', [])
|
7699
|
+
return self.parse_all_greeks(data, symbols)
|
7700
|
+
|
7628
7701
|
def parse_greeks(self, greeks: dict, market: Market = None) -> Greeks:
|
7629
7702
|
#
|
7630
7703
|
# {
|
@@ -8731,7 +8804,7 @@ classic accounts only/ spot not supported* fetches information on an order made
|
|
8731
8804
|
authFull = auth_base + body
|
8732
8805
|
else:
|
8733
8806
|
authFull = auth_base + queryEncoded
|
8734
|
-
url += '?' +
|
8807
|
+
url += '?' + queryEncoded
|
8735
8808
|
signature = None
|
8736
8809
|
if self.secret.find('PRIVATE KEY') > -1:
|
8737
8810
|
signature = self.rsa(authFull, self.secret, 'sha256')
|
@@ -8745,7 +8818,7 @@ classic accounts only/ spot not supported* fetches information on an order made
|
|
8745
8818
|
'timestamp': timestamp,
|
8746
8819
|
})
|
8747
8820
|
sortedQuery = self.keysort(query)
|
8748
|
-
auth = self.rawencode(sortedQuery)
|
8821
|
+
auth = self.rawencode(sortedQuery, True)
|
8749
8822
|
signature = None
|
8750
8823
|
if self.secret.find('PRIVATE KEY') > -1:
|
8751
8824
|
signature = self.rsa(auth, self.secret, 'sha256')
|
@@ -8767,7 +8840,7 @@ classic accounts only/ spot not supported* fetches information on an order made
|
|
8767
8840
|
'Content-Type': 'application/json',
|
8768
8841
|
}
|
8769
8842
|
else:
|
8770
|
-
url += '?' + self.rawencode(sortedQuery)
|
8843
|
+
url += '?' + self.rawencode(sortedQuery, True)
|
8771
8844
|
url += '&sign=' + signature
|
8772
8845
|
if method == 'POST':
|
8773
8846
|
brokerId = self.safe_string(self.options, 'brokerId')
|
@@ -39,31 +39,73 @@ class coinbaseexchange(Exchange, ImplicitAPI):
|
|
39
39
|
'swap': False,
|
40
40
|
'future': False,
|
41
41
|
'option': False,
|
42
|
+
'addMargin': False,
|
43
|
+
'borrowCrossMargin': False,
|
44
|
+
'borrowIsolatedMargin': False,
|
45
|
+
'borrowMargin': False,
|
42
46
|
'cancelAllOrders': True,
|
43
47
|
'cancelOrder': True,
|
48
|
+
'closeAllPositions': False,
|
49
|
+
'closePosition': False,
|
44
50
|
'createDepositAddress': True,
|
45
51
|
'createOrder': True,
|
52
|
+
'createOrderWithTakeProfitAndStopLoss': False,
|
53
|
+
'createOrderWithTakeProfitAndStopLossWs': False,
|
54
|
+
'createPostOnlyOrder': False,
|
46
55
|
'createReduceOnlyOrder': False,
|
47
56
|
'createStopLimitOrder': True,
|
48
57
|
'createStopMarketOrder': True,
|
49
58
|
'createStopOrder': True,
|
50
59
|
'fetchAccounts': True,
|
51
60
|
'fetchBalance': True,
|
61
|
+
'fetchBorrowInterest': False,
|
62
|
+
'fetchBorrowRate': False,
|
63
|
+
'fetchBorrowRateHistories': False,
|
64
|
+
'fetchBorrowRateHistory': False,
|
65
|
+
'fetchBorrowRates': False,
|
66
|
+
'fetchBorrowRatesPerSymbol': False,
|
52
67
|
'fetchClosedOrders': True,
|
68
|
+
'fetchCrossBorrowRate': False,
|
69
|
+
'fetchCrossBorrowRates': False,
|
53
70
|
'fetchCurrencies': True,
|
54
71
|
'fetchDepositAddress': False, # the exchange does not have self method, only createDepositAddress, see https://github.com/ccxt/ccxt/pull/7405
|
55
72
|
'fetchDeposits': True,
|
56
73
|
'fetchDepositsWithdrawals': True,
|
57
74
|
'fetchFundingHistory': False,
|
75
|
+
'fetchFundingInterval': False,
|
76
|
+
'fetchFundingIntervals': False,
|
58
77
|
'fetchFundingRate': False,
|
59
78
|
'fetchFundingRateHistory': False,
|
60
79
|
'fetchFundingRates': False,
|
80
|
+
'fetchGreeks': False,
|
81
|
+
'fetchIndexOHLCV': False,
|
82
|
+
'fetchIsolatedBorrowRate': False,
|
83
|
+
'fetchIsolatedBorrowRates': False,
|
84
|
+
'fetchIsolatedPositions': False,
|
61
85
|
'fetchLedger': True,
|
86
|
+
'fetchLeverage': False,
|
87
|
+
'fetchLeverages': False,
|
88
|
+
'fetchLeverageTiers': False,
|
89
|
+
'fetchLiquidations': False,
|
90
|
+
'fetchLongShortRatio': False,
|
91
|
+
'fetchLongShortRatioHistory': False,
|
92
|
+
'fetchMarginAdjustmentHistory': False,
|
62
93
|
'fetchMarginMode': False,
|
94
|
+
'fetchMarginModes': False,
|
95
|
+
'fetchMarketLeverageTiers': False,
|
63
96
|
'fetchMarkets': True,
|
97
|
+
'fetchMarkOHLCV': False,
|
98
|
+
'fetchMarkPrices': False,
|
99
|
+
'fetchMyLiquidations': False,
|
100
|
+
'fetchMySettlementHistory': False,
|
64
101
|
'fetchMyTrades': True,
|
65
102
|
'fetchOHLCV': True,
|
103
|
+
'fetchOpenInterest': False,
|
104
|
+
'fetchOpenInterestHistory': False,
|
105
|
+
'fetchOpenInterests': False,
|
66
106
|
'fetchOpenOrders': True,
|
107
|
+
'fetchOption': False,
|
108
|
+
'fetchOptionChain': False,
|
67
109
|
'fetchOrder': True,
|
68
110
|
'fetchOrderBook': True,
|
69
111
|
'fetchOrders': True,
|
@@ -75,6 +117,8 @@ class coinbaseexchange(Exchange, ImplicitAPI):
|
|
75
117
|
'fetchPositionsForSymbol': False,
|
76
118
|
'fetchPositionsHistory': False,
|
77
119
|
'fetchPositionsRisk': False,
|
120
|
+
'fetchPremiumIndexOHLCV': False,
|
121
|
+
'fetchSettlementHistory': False,
|
78
122
|
'fetchTicker': True,
|
79
123
|
'fetchTickers': True,
|
80
124
|
'fetchTime': True,
|
@@ -82,7 +126,16 @@ class coinbaseexchange(Exchange, ImplicitAPI):
|
|
82
126
|
'fetchTradingFee': False,
|
83
127
|
'fetchTradingFees': True,
|
84
128
|
'fetchTransactions': 'emulated',
|
129
|
+
'fetchVolatilityHistory': False,
|
85
130
|
'fetchWithdrawals': True,
|
131
|
+
'reduceMargin': False,
|
132
|
+
'repayCrossMargin': False,
|
133
|
+
'repayIsolatedMargin': False,
|
134
|
+
'repayMargin': False,
|
135
|
+
'setLeverage': False,
|
136
|
+
'setMargin': False,
|
137
|
+
'setMarginMode': False,
|
138
|
+
'setPositionMode': False,
|
86
139
|
'withdraw': True,
|
87
140
|
},
|
88
141
|
'timeframes': {
|
ccxt/async_support/coincheck.py
CHANGED
@@ -10,6 +10,7 @@ from ccxt.base.types import Any, Balances, Currency, Int, Market, Num, Order, Or
|
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
13
|
+
from ccxt.base.errors import ArgumentsRequired
|
13
14
|
from ccxt.base.errors import BadSymbol
|
14
15
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
15
16
|
|
@@ -30,30 +31,59 @@ class coincheck(Exchange, ImplicitAPI):
|
|
30
31
|
'future': False,
|
31
32
|
'option': False,
|
32
33
|
'addMargin': False,
|
34
|
+
'borrowCrossMargin': False,
|
35
|
+
'borrowIsolatedMargin': False,
|
36
|
+
'borrowMargin': False,
|
33
37
|
'cancelOrder': True,
|
34
38
|
'closeAllPositions': False,
|
35
39
|
'closePosition': False,
|
36
40
|
'createOrder': True,
|
41
|
+
'createOrderWithTakeProfitAndStopLoss': False,
|
42
|
+
'createOrderWithTakeProfitAndStopLossWs': False,
|
43
|
+
'createPostOnlyOrder': False,
|
37
44
|
'createReduceOnlyOrder': False,
|
38
45
|
'fetchBalance': True,
|
46
|
+
'fetchBorrowInterest': False,
|
47
|
+
'fetchBorrowRate': False,
|
39
48
|
'fetchBorrowRateHistories': False,
|
40
49
|
'fetchBorrowRateHistory': False,
|
50
|
+
'fetchBorrowRates': False,
|
51
|
+
'fetchBorrowRatesPerSymbol': False,
|
41
52
|
'fetchCrossBorrowRate': False,
|
42
53
|
'fetchCrossBorrowRates': False,
|
43
54
|
'fetchDeposits': True,
|
44
55
|
'fetchFundingHistory': False,
|
56
|
+
'fetchFundingInterval': False,
|
57
|
+
'fetchFundingIntervals': False,
|
45
58
|
'fetchFundingRate': False,
|
46
59
|
'fetchFundingRateHistory': False,
|
47
60
|
'fetchFundingRates': False,
|
61
|
+
'fetchGreeks': False,
|
48
62
|
'fetchIndexOHLCV': False,
|
49
63
|
'fetchIsolatedBorrowRate': False,
|
50
64
|
'fetchIsolatedBorrowRates': False,
|
65
|
+
'fetchIsolatedPositions': False,
|
51
66
|
'fetchLeverage': False,
|
67
|
+
'fetchLeverages': False,
|
68
|
+
'fetchLeverageTiers': False,
|
69
|
+
'fetchLiquidations': False,
|
70
|
+
'fetchLongShortRatio': False,
|
71
|
+
'fetchLongShortRatioHistory': False,
|
72
|
+
'fetchMarginAdjustmentHistory': False,
|
52
73
|
'fetchMarginMode': False,
|
74
|
+
'fetchMarginModes': False,
|
75
|
+
'fetchMarketLeverageTiers': False,
|
53
76
|
'fetchMarkOHLCV': False,
|
77
|
+
'fetchMarkPrices': False,
|
78
|
+
'fetchMyLiquidations': False,
|
79
|
+
'fetchMySettlementHistory': False,
|
54
80
|
'fetchMyTrades': True,
|
81
|
+
'fetchOpenInterest': False,
|
55
82
|
'fetchOpenInterestHistory': False,
|
83
|
+
'fetchOpenInterests': False,
|
56
84
|
'fetchOpenOrders': True,
|
85
|
+
'fetchOption': False,
|
86
|
+
'fetchOptionChain': False,
|
57
87
|
'fetchOrderBook': True,
|
58
88
|
'fetchPosition': False,
|
59
89
|
'fetchPositionHistory': False,
|
@@ -63,13 +93,19 @@ class coincheck(Exchange, ImplicitAPI):
|
|
63
93
|
'fetchPositionsHistory': False,
|
64
94
|
'fetchPositionsRisk': False,
|
65
95
|
'fetchPremiumIndexOHLCV': False,
|
96
|
+
'fetchSettlementHistory': False,
|
66
97
|
'fetchTicker': True,
|
67
98
|
'fetchTrades': True,
|
68
99
|
'fetchTradingFee': False,
|
69
100
|
'fetchTradingFees': True,
|
101
|
+
'fetchVolatilityHistory': False,
|
70
102
|
'fetchWithdrawals': True,
|
71
103
|
'reduceMargin': False,
|
104
|
+
'repayCrossMargin': False,
|
105
|
+
'repayIsolatedMargin': False,
|
106
|
+
'repayMargin': False,
|
72
107
|
'setLeverage': False,
|
108
|
+
'setMargin': False,
|
73
109
|
'setMarginMode': False,
|
74
110
|
'setPositionMode': False,
|
75
111
|
'ws': True,
|
@@ -637,10 +673,15 @@ class coincheck(Exchange, ImplicitAPI):
|
|
637
673
|
'pair': market['id'],
|
638
674
|
}
|
639
675
|
if type == 'market':
|
640
|
-
order_type = type + '_' + side
|
641
|
-
|
642
|
-
|
643
|
-
|
676
|
+
request['order_type'] = type + '_' + side
|
677
|
+
if side == 'sell':
|
678
|
+
request['amount'] = amount
|
679
|
+
else:
|
680
|
+
cost = self.safe_number(params, 'cost')
|
681
|
+
params = self.omit(params, 'cost')
|
682
|
+
if cost is not None:
|
683
|
+
raise ArgumentsRequired(self.id + ' createOrder() : you should use "cost" parameter instead of "amount" argument to create market buy orders')
|
684
|
+
request['market_buy_amount'] = cost
|
644
685
|
else:
|
645
686
|
request['order_type'] = side
|
646
687
|
request['rate'] = price
|