ccxt 4.3.12__py2.py3-none-any.whl → 4.3.14__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/bybit.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +99 -3
- ccxt/async_support/bybit.py +100 -99
- ccxt/async_support/coinbase.py +96 -1
- ccxt/async_support/coinex.py +392 -375
- ccxt/async_support/okx.py +1 -1
- ccxt/base/exchange.py +5 -1
- ccxt/binance.py +99 -3
- ccxt/bybit.py +100 -99
- ccxt/coinbase.py +96 -1
- ccxt/coinex.py +392 -375
- ccxt/okx.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/woo.py +137 -9
- {ccxt-4.3.12.dist-info → ccxt-4.3.14.dist-info}/METADATA +4 -4
- {ccxt-4.3.12.dist-info → ccxt-4.3.14.dist-info}/RECORD +21 -21
- {ccxt-4.3.12.dist-info → ccxt-4.3.14.dist-info}/WHEEL +0 -0
- {ccxt-4.3.12.dist-info → ccxt-4.3.14.dist-info}/top_level.txt +0 -0
ccxt/async_support/bybit.py
CHANGED
@@ -337,6 +337,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
337
337
|
'v5/account/fee-rate': 10, # 5/s = 1000 / (20 * 10)
|
338
338
|
'v5/account/info': 5,
|
339
339
|
'v5/account/transaction-log': 1,
|
340
|
+
'v5/account/contract-transaction-log': 1,
|
340
341
|
'v5/account/smp-group': 1,
|
341
342
|
'v5/account/mmp-state': 5,
|
342
343
|
# asset
|
@@ -1111,7 +1112,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
1111
1112
|
return self.milliseconds() - self.options['timeDifference']
|
1112
1113
|
|
1113
1114
|
def add_pagination_cursor_to_result(self, response):
|
1114
|
-
result = self.
|
1115
|
+
result = self.safe_dict(response, 'result', {})
|
1115
1116
|
data = self.safe_value_n(result, ['list', 'rows', 'data', 'dataList'], [])
|
1116
1117
|
paginationCursor = self.safe_string_2(result, 'nextPageCursor', 'cursor')
|
1117
1118
|
dataLength = len(data)
|
@@ -1128,8 +1129,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
1128
1129
|
# The API key of user id must own one of permissions will be allowed to call following API endpoints.
|
1129
1130
|
# SUB UID: "Account Transfer"
|
1130
1131
|
# MASTER UID: "Account Transfer", "Subaccount Transfer", "Withdrawal"
|
1131
|
-
enableUnifiedMargin = self.
|
1132
|
-
enableUnifiedAccount = self.
|
1132
|
+
enableUnifiedMargin = self.safe_bool(self.options, 'enableUnifiedMargin')
|
1133
|
+
enableUnifiedAccount = self.safe_bool(self.options, 'enableUnifiedAccount')
|
1133
1134
|
if enableUnifiedMargin is None or enableUnifiedAccount is None:
|
1134
1135
|
if self.options['enableDemoTrading']:
|
1135
1136
|
# info endpoint is not available in demo trading
|
@@ -1178,7 +1179,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
1178
1179
|
# "time": 1676891757649
|
1179
1180
|
# }
|
1180
1181
|
#
|
1181
|
-
result = self.
|
1182
|
+
result = self.safe_dict(response, 'result', {})
|
1182
1183
|
self.options['enableUnifiedMargin'] = self.safe_integer(result, 'unified') == 1
|
1183
1184
|
self.options['enableUnifiedAccount'] = self.safe_integer(result, 'uta') == 1
|
1184
1185
|
return [self.options['enableUnifiedMargin'], self.options['enableUnifiedAccount']]
|
@@ -1329,15 +1330,15 @@ class bybit(Exchange, ImplicitAPI):
|
|
1329
1330
|
# "time": 1672194582264
|
1330
1331
|
# }
|
1331
1332
|
#
|
1332
|
-
data = self.
|
1333
|
-
rows = self.
|
1333
|
+
data = self.safe_dict(response, 'result', {})
|
1334
|
+
rows = self.safe_list(data, 'rows', [])
|
1334
1335
|
result = {}
|
1335
1336
|
for i in range(0, len(rows)):
|
1336
1337
|
currency = rows[i]
|
1337
1338
|
currencyId = self.safe_string(currency, 'coin')
|
1338
1339
|
code = self.safe_currency_code(currencyId)
|
1339
1340
|
name = self.safe_string(currency, 'name')
|
1340
|
-
chains = self.
|
1341
|
+
chains = self.safe_list(currency, 'chains', [])
|
1341
1342
|
networks = {}
|
1342
1343
|
minPrecision = None
|
1343
1344
|
minWithdrawFeeString = None
|
@@ -1422,7 +1423,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
1422
1423
|
if self.options['adjustForTimeDifference']:
|
1423
1424
|
await self.load_time_difference()
|
1424
1425
|
promisesUnresolved = []
|
1425
|
-
fetchMarkets = self.
|
1426
|
+
fetchMarkets = self.safe_list(self.options, 'fetchMarkets', ['spot', 'linear', 'inverse'])
|
1426
1427
|
for i in range(0, len(fetchMarkets)):
|
1427
1428
|
marketType = fetchMarkets[i]
|
1428
1429
|
if marketType == 'spot':
|
@@ -1438,12 +1439,12 @@ class bybit(Exchange, ImplicitAPI):
|
|
1438
1439
|
else:
|
1439
1440
|
raise ExchangeError(self.id + ' fetchMarkets() self.options fetchMarkets "' + marketType + '" is not a supported market type')
|
1440
1441
|
promises = await asyncio.gather(*promisesUnresolved)
|
1441
|
-
spotMarkets = self.
|
1442
|
-
linearMarkets = self.
|
1443
|
-
inverseMarkets = self.
|
1444
|
-
btcOptionMarkets = self.
|
1445
|
-
ethOptionMarkets = self.
|
1446
|
-
solOptionMarkets = self.
|
1442
|
+
spotMarkets = self.safe_list(promises, 0, [])
|
1443
|
+
linearMarkets = self.safe_list(promises, 1, [])
|
1444
|
+
inverseMarkets = self.safe_list(promises, 2, [])
|
1445
|
+
btcOptionMarkets = self.safe_list(promises, 3, [])
|
1446
|
+
ethOptionMarkets = self.safe_list(promises, 4, [])
|
1447
|
+
solOptionMarkets = self.safe_list(promises, 5, [])
|
1447
1448
|
futureMarkets = self.array_concat(linearMarkets, inverseMarkets)
|
1448
1449
|
optionMarkets = self.array_concat(btcOptionMarkets, ethOptionMarkets)
|
1449
1450
|
optionMarkets = self.array_concat(optionMarkets, solOptionMarkets)
|
@@ -1486,8 +1487,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
1486
1487
|
# "time": 1672712468011
|
1487
1488
|
# }
|
1488
1489
|
#
|
1489
|
-
responseResult = self.
|
1490
|
-
markets = self.
|
1490
|
+
responseResult = self.safe_dict(response, 'result', {})
|
1491
|
+
markets = self.safe_list(responseResult, 'list', [])
|
1491
1492
|
result = []
|
1492
1493
|
takerFee = self.parse_number('0.001')
|
1493
1494
|
makerFee = self.parse_number('0.001')
|
@@ -1501,8 +1502,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
1501
1502
|
symbol = base + '/' + quote
|
1502
1503
|
status = self.safe_string(market, 'status')
|
1503
1504
|
active = (status == 'Trading')
|
1504
|
-
lotSizeFilter = self.
|
1505
|
-
priceFilter = self.
|
1505
|
+
lotSizeFilter = self.safe_dict(market, 'lotSizeFilter')
|
1506
|
+
priceFilter = self.safe_dict(market, 'priceFilter')
|
1506
1507
|
quotePrecision = self.safe_number(lotSizeFilter, 'quotePrecision')
|
1507
1508
|
result.append({
|
1508
1509
|
'id': id,
|
@@ -1561,15 +1562,15 @@ class bybit(Exchange, ImplicitAPI):
|
|
1561
1562
|
params = self.extend(params)
|
1562
1563
|
params['limit'] = 1000 # minimize number of requests
|
1563
1564
|
response = await self.publicGetV5MarketInstrumentsInfo(params)
|
1564
|
-
data = self.
|
1565
|
-
markets = self.
|
1565
|
+
data = self.safe_dict(response, 'result', {})
|
1566
|
+
markets = self.safe_list(data, 'list', [])
|
1566
1567
|
paginationCursor = self.safe_string(data, 'nextPageCursor')
|
1567
1568
|
if paginationCursor is not None:
|
1568
1569
|
while(paginationCursor is not None):
|
1569
1570
|
params['cursor'] = paginationCursor
|
1570
1571
|
responseInner = await self.publicGetV5MarketInstrumentsInfo(params)
|
1571
|
-
dataNew = self.
|
1572
|
-
rawMarkets = self.
|
1572
|
+
dataNew = self.safe_dict(responseInner, 'result', {})
|
1573
|
+
rawMarkets = self.safe_list(dataNew, 'list', [])
|
1573
1574
|
rawMarketsLength = len(rawMarkets)
|
1574
1575
|
if rawMarketsLength == 0:
|
1575
1576
|
break
|
@@ -1645,9 +1646,9 @@ class bybit(Exchange, ImplicitAPI):
|
|
1645
1646
|
else:
|
1646
1647
|
settle = self.safe_currency_code(settleId)
|
1647
1648
|
symbol = base + '/' + quote
|
1648
|
-
lotSizeFilter = self.
|
1649
|
-
priceFilter = self.
|
1650
|
-
leverage = self.
|
1649
|
+
lotSizeFilter = self.safe_dict(market, 'lotSizeFilter', {})
|
1650
|
+
priceFilter = self.safe_dict(market, 'priceFilter', {})
|
1651
|
+
leverage = self.safe_dict(market, 'leverageFilter', {})
|
1651
1652
|
status = self.safe_string(market, 'status')
|
1652
1653
|
swap = linearPerpetual or inversePerpetual
|
1653
1654
|
future = inverseFutures or linearFutures
|
@@ -1725,8 +1726,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
1725
1726
|
'category': 'option',
|
1726
1727
|
}
|
1727
1728
|
response = await self.publicGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1728
|
-
data = self.
|
1729
|
-
markets = self.
|
1729
|
+
data = self.safe_dict(response, 'result', {})
|
1730
|
+
markets = self.safe_list(data, 'list', [])
|
1730
1731
|
if self.options['loadAllOptions']:
|
1731
1732
|
request['limit'] = 1000
|
1732
1733
|
paginationCursor = self.safe_string(data, 'nextPageCursor')
|
@@ -1734,8 +1735,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
1734
1735
|
while(paginationCursor is not None):
|
1735
1736
|
request['cursor'] = paginationCursor
|
1736
1737
|
responseInner = await self.publicGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1737
|
-
dataNew = self.
|
1738
|
-
rawMarkets = self.
|
1738
|
+
dataNew = self.safe_dict(responseInner, 'result', {})
|
1739
|
+
rawMarkets = self.safe_list(dataNew, 'list', [])
|
1739
1740
|
rawMarketsLength = len(rawMarkets)
|
1740
1741
|
if rawMarketsLength == 0:
|
1741
1742
|
break
|
@@ -1786,8 +1787,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
1786
1787
|
base = self.safe_currency_code(baseId)
|
1787
1788
|
quote = self.safe_currency_code(quoteId)
|
1788
1789
|
settle = self.safe_currency_code(settleId)
|
1789
|
-
lotSizeFilter = self.
|
1790
|
-
priceFilter = self.
|
1790
|
+
lotSizeFilter = self.safe_dict(market, 'lotSizeFilter', {})
|
1791
|
+
priceFilter = self.safe_dict(market, 'priceFilter', {})
|
1791
1792
|
status = self.safe_string(market, 'status')
|
1792
1793
|
expiry = self.safe_integer(market, 'deliveryTime')
|
1793
1794
|
splitId = id.split('-')
|
@@ -2030,8 +2031,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
2030
2031
|
# "time": 1672376496682
|
2031
2032
|
# }
|
2032
2033
|
#
|
2033
|
-
result = self.
|
2034
|
-
tickers = self.
|
2034
|
+
result = self.safe_dict(response, 'result', {})
|
2035
|
+
tickers = self.safe_list(result, 'list', [])
|
2035
2036
|
rawTicker = self.safe_dict(tickers, 0)
|
2036
2037
|
return self.parse_ticker(rawTicker, market)
|
2037
2038
|
|
@@ -2126,7 +2127,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2126
2127
|
# "time": 1672376496682
|
2127
2128
|
# }
|
2128
2129
|
#
|
2129
|
-
result = self.
|
2130
|
+
result = self.safe_dict(response, 'result', {})
|
2130
2131
|
tickerList = self.safe_list(result, 'list', [])
|
2131
2132
|
return self.parse_tickers(tickerList, parsedSymbols)
|
2132
2133
|
|
@@ -2249,7 +2250,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2249
2250
|
# "time": 1672025956592
|
2250
2251
|
# }
|
2251
2252
|
#
|
2252
|
-
result = self.
|
2253
|
+
result = self.safe_dict(response, 'result', {})
|
2253
2254
|
ohlcvs = self.safe_list(result, 'list', [])
|
2254
2255
|
return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
|
2255
2256
|
|
@@ -2448,8 +2449,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
2448
2449
|
# }
|
2449
2450
|
#
|
2450
2451
|
rates = []
|
2451
|
-
result = self.
|
2452
|
-
resultList = self.
|
2452
|
+
result = self.safe_dict(response, 'result')
|
2453
|
+
resultList = self.safe_list(result, 'list')
|
2453
2454
|
for i in range(0, len(resultList)):
|
2454
2455
|
entry = resultList[i]
|
2455
2456
|
timestamp = self.safe_integer(entry, 'fundingRateTimestamp')
|
@@ -2577,7 +2578,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2577
2578
|
isBuyer = self.safe_integer(trade, 'isBuyer')
|
2578
2579
|
if isBuyer is not None:
|
2579
2580
|
side = 'buy' if isBuyer else 'sell'
|
2580
|
-
isMaker = self.
|
2581
|
+
isMaker = self.safe_bool(trade, 'isMaker')
|
2581
2582
|
takerOrMaker = None
|
2582
2583
|
if isMaker is not None:
|
2583
2584
|
takerOrMaker = 'maker' if isMaker else 'taker'
|
@@ -2683,7 +2684,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2683
2684
|
# "time": 1672053054358
|
2684
2685
|
# }
|
2685
2686
|
#
|
2686
|
-
result = self.
|
2687
|
+
result = self.safe_dict(response, 'result', {})
|
2687
2688
|
trades = self.safe_list(result, 'list', [])
|
2688
2689
|
return self.parse_trades(trades, market, since, limit)
|
2689
2690
|
|
@@ -2745,7 +2746,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2745
2746
|
# "time": 1672765737734
|
2746
2747
|
# }
|
2747
2748
|
#
|
2748
|
-
result = self.
|
2749
|
+
result = self.safe_dict(response, 'result', {})
|
2749
2750
|
timestamp = self.safe_integer(result, 'ts')
|
2750
2751
|
return self.parse_order_book(result, symbol, timestamp, 'b', 'a')
|
2751
2752
|
|
@@ -2858,7 +2859,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2858
2859
|
'timestamp': timestamp,
|
2859
2860
|
'datetime': self.iso8601(timestamp),
|
2860
2861
|
}
|
2861
|
-
responseResult = self.
|
2862
|
+
responseResult = self.safe_dict(response, 'result', {})
|
2862
2863
|
currencyList = self.safe_value_n(responseResult, ['loanAccountList', 'list', 'balance'])
|
2863
2864
|
if currencyList is None:
|
2864
2865
|
# usdc wallet
|
@@ -2872,7 +2873,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2872
2873
|
entry = currencyList[i]
|
2873
2874
|
accountType = self.safe_string(entry, 'accountType')
|
2874
2875
|
if accountType == 'UNIFIED' or accountType == 'CONTRACT' or accountType == 'SPOT':
|
2875
|
-
coins = self.
|
2876
|
+
coins = self.safe_list(entry, 'coin')
|
2876
2877
|
for j in range(0, len(coins)):
|
2877
2878
|
account = self.account()
|
2878
2879
|
coinEntry = coins[j]
|
@@ -2924,7 +2925,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2924
2925
|
else:
|
2925
2926
|
if isSwap:
|
2926
2927
|
type = 'contract'
|
2927
|
-
accountTypes = self.
|
2928
|
+
accountTypes = self.safe_dict(self.options, 'accountsByType', {})
|
2928
2929
|
unifiedType = self.safe_string_upper(accountTypes, type, type)
|
2929
2930
|
marginMode = None
|
2930
2931
|
marginMode, params = self.handle_margin_mode_and_params('fetchBalance', params)
|
@@ -3235,7 +3236,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3235
3236
|
rawTimeInForce = self.safe_string(order, 'timeInForce')
|
3236
3237
|
timeInForce = self.parse_time_in_force(rawTimeInForce)
|
3237
3238
|
stopPrice = self.omit_zero(self.safe_string(order, 'triggerPrice'))
|
3238
|
-
reduceOnly = self.
|
3239
|
+
reduceOnly = self.safe_bool(order, 'reduceOnly')
|
3239
3240
|
takeProfitPrice = self.omit_zero(self.safe_string(order, 'takeProfit'))
|
3240
3241
|
stopLossPrice = self.omit_zero(self.safe_string(order, 'stopLoss'))
|
3241
3242
|
triggerDirection = self.safe_string(order, 'triggerDirection')
|
@@ -3269,7 +3270,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3269
3270
|
'type': type,
|
3270
3271
|
'timeInForce': timeInForce,
|
3271
3272
|
'postOnly': None,
|
3272
|
-
'reduceOnly': self.
|
3273
|
+
'reduceOnly': self.safe_bool(order, 'reduceOnly'),
|
3273
3274
|
'side': side,
|
3274
3275
|
'price': price,
|
3275
3276
|
'stopPrice': stopPrice,
|
@@ -3360,7 +3361,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3360
3361
|
trailingAmount = self.safe_string_2(params, 'trailingAmount', 'trailingStop')
|
3361
3362
|
isTrailingAmountOrder = trailingAmount is not None
|
3362
3363
|
orderRequest = self.create_order_request(symbol, type, side, amount, price, params, enableUnifiedAccount)
|
3363
|
-
options = self.
|
3364
|
+
options = self.safe_dict(self.options, 'createOrder', {})
|
3364
3365
|
defaultMethod = self.safe_string(options, 'method', 'privatePostV5OrderCreate')
|
3365
3366
|
response = None
|
3366
3367
|
if isTrailingAmountOrder or (defaultMethod == 'privatePostV5PositionTradingStop'):
|
@@ -3603,10 +3604,10 @@ class bybit(Exchange, ImplicitAPI):
|
|
3603
3604
|
'request': ordersRequests,
|
3604
3605
|
}
|
3605
3606
|
response = await self.privatePostV5OrderCreateBatch(self.extend(request, params))
|
3606
|
-
result = self.
|
3607
|
-
data = self.
|
3608
|
-
retInfo = self.
|
3609
|
-
codes = self.
|
3607
|
+
result = self.safe_dict(response, 'result', {})
|
3608
|
+
data = self.safe_list(result, 'list', [])
|
3609
|
+
retInfo = self.safe_dict(response, 'retExtInfo', {})
|
3610
|
+
codes = self.safe_list(retInfo, 'list', [])
|
3610
3611
|
# self.extend the error with the unsuccessful orders
|
3611
3612
|
for i in range(0, len(codes)):
|
3612
3613
|
code = codes[i]
|
@@ -3778,7 +3779,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3778
3779
|
if market['option']:
|
3779
3780
|
response = await self.privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder(self.extend(request, params))
|
3780
3781
|
else:
|
3781
|
-
isStop = self.
|
3782
|
+
isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
3782
3783
|
triggerPrice = self.safe_value_2(params, 'stopPrice', 'triggerPrice')
|
3783
3784
|
stopLossPrice = self.safe_value(params, 'stopLossPrice')
|
3784
3785
|
isStopLossOrder = stopLossPrice is not None
|
@@ -3923,7 +3924,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3923
3924
|
# "time": 1672217093461
|
3924
3925
|
# }
|
3925
3926
|
#
|
3926
|
-
result = self.
|
3927
|
+
result = self.safe_dict(response, 'result', {})
|
3927
3928
|
return self.safe_order({
|
3928
3929
|
'info': response,
|
3929
3930
|
'id': self.safe_string(result, 'orderId'),
|
@@ -3939,7 +3940,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3939
3940
|
# 'orderLinkId': 'string', # one of order_id, stop_order_id or order_link_id is required
|
3940
3941
|
# 'orderId': id,
|
3941
3942
|
}
|
3942
|
-
isStop = self.
|
3943
|
+
isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
3943
3944
|
params = self.omit(params, ['stop', 'trigger'])
|
3944
3945
|
if id is not None: # The user can also use argument params["order_link_id"]
|
3945
3946
|
request['orderId'] = id
|
@@ -4193,7 +4194,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
4193
4194
|
if market['option']:
|
4194
4195
|
response = await self.privatePostOptionUsdcOpenapiPrivateV1CancelAll(self.extend(request, params))
|
4195
4196
|
else:
|
4196
|
-
isStop = self.
|
4197
|
+
isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
4197
4198
|
if isStop:
|
4198
4199
|
request['orderFilter'] = 'StopOrder'
|
4199
4200
|
else:
|
@@ -4256,7 +4257,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
4256
4257
|
if symbol is None and baseCoin is None:
|
4257
4258
|
defaultSettle = self.safe_string(self.options, 'defaultSettle', 'USDT')
|
4258
4259
|
request['settleCoin'] = self.safe_string(params, 'settleCoin', defaultSettle)
|
4259
|
-
isStop = self.
|
4260
|
+
isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
4260
4261
|
params = self.omit(params, ['stop', 'trigger'])
|
4261
4262
|
if isStop:
|
4262
4263
|
request['orderFilter'] = 'StopOrder'
|
@@ -4289,8 +4290,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
4289
4290
|
# "time": 1676962409398
|
4290
4291
|
# }
|
4291
4292
|
#
|
4292
|
-
result = self.
|
4293
|
-
orders = self.
|
4293
|
+
result = self.safe_dict(response, 'result', {})
|
4294
|
+
orders = self.safe_list(result, 'list')
|
4294
4295
|
if not isinstance(orders, list):
|
4295
4296
|
return response
|
4296
4297
|
return self.parse_orders(orders, market)
|
@@ -4319,7 +4320,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
4319
4320
|
request['category'] = 'PERPETUAL'
|
4320
4321
|
else:
|
4321
4322
|
request['category'] = 'OPTION'
|
4322
|
-
isStop = self.
|
4323
|
+
isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
4323
4324
|
params = self.omit(params, ['stop', 'trigger'])
|
4324
4325
|
if isStop:
|
4325
4326
|
request['orderFilter'] = 'StopOrder'
|
@@ -4373,7 +4374,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
4373
4374
|
# "retMsg": "Success."
|
4374
4375
|
# }
|
4375
4376
|
#
|
4376
|
-
result = self.
|
4377
|
+
result = self.safe_dict(response, 'result', {})
|
4377
4378
|
data = self.safe_list(result, 'dataList', [])
|
4378
4379
|
return self.parse_orders(data, market, since, limit)
|
4379
4380
|
|
@@ -4757,8 +4758,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
4757
4758
|
type, params = self.handle_market_type_and_params('fetchUsdcOpenOrders', market, params)
|
4758
4759
|
request['category'] = 'perpetual' if (type == 'swap') else 'option'
|
4759
4760
|
response = await self.privatePostOptionUsdcOpenapiPrivateV1QueryActiveOrders(self.extend(request, params))
|
4760
|
-
result = self.
|
4761
|
-
orders = self.
|
4761
|
+
result = self.safe_dict(response, 'result', {})
|
4762
|
+
orders = self.safe_list(result, 'dataList', [])
|
4762
4763
|
#
|
4763
4764
|
# {
|
4764
4765
|
# "retCode": 0,
|
@@ -4825,7 +4826,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
4825
4826
|
if ((type == 'option') or isUsdcSettled) and not isUnifiedAccount:
|
4826
4827
|
return await self.fetch_usdc_open_orders(symbol, since, limit, params)
|
4827
4828
|
request['category'] = type
|
4828
|
-
isStop = self.
|
4829
|
+
isStop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
4829
4830
|
params = self.omit(params, ['stop', 'trigger'])
|
4830
4831
|
if isStop:
|
4831
4832
|
request['orderFilter'] = 'StopOrder'
|
@@ -4943,7 +4944,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
4943
4944
|
# "retMsg": "Success."
|
4944
4945
|
# }
|
4945
4946
|
#
|
4946
|
-
result = self.
|
4947
|
+
result = self.safe_dict(response, 'result', {})
|
4947
4948
|
dataList = self.safe_list(result, 'dataList', [])
|
4948
4949
|
return self.parse_trades(dataList, market, since, limit)
|
4949
4950
|
|
@@ -5085,8 +5086,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
5085
5086
|
# "time": 1672192792860
|
5086
5087
|
# }
|
5087
5088
|
#
|
5088
|
-
result = self.
|
5089
|
-
chains = self.
|
5089
|
+
result = self.safe_dict(response, 'result', {})
|
5090
|
+
chains = self.safe_list(result, 'chains', [])
|
5090
5091
|
coin = self.safe_string(result, 'coin')
|
5091
5092
|
currency = self.currency(coin)
|
5092
5093
|
parsed = self.parse_deposit_addresses(chains, [currency['code']], False, {
|
@@ -5131,8 +5132,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
5131
5132
|
# "time": 1672192792860
|
5132
5133
|
# }
|
5133
5134
|
#
|
5134
|
-
result = self.
|
5135
|
-
chains = self.
|
5135
|
+
result = self.safe_dict(response, 'result', {})
|
5136
|
+
chains = self.safe_list(result, 'chains', [])
|
5136
5137
|
chainsIndexedById = self.index_by(chains, 'chain')
|
5137
5138
|
selectedNetworkId = self.select_network_id_from_raw_networks(code, networkCode, chainsIndexedById)
|
5138
5139
|
addressObject = self.safe_dict(chainsIndexedById, selectedNetworkId, {})
|
@@ -5803,14 +5804,14 @@ class bybit(Exchange, ImplicitAPI):
|
|
5803
5804
|
# "retMsg": "Success."
|
5804
5805
|
# }
|
5805
5806
|
#
|
5806
|
-
result = self.
|
5807
|
-
positions = self.
|
5807
|
+
result = self.safe_dict(response, 'result', {})
|
5808
|
+
positions = self.safe_list(result, 'dataList', [])
|
5808
5809
|
results = []
|
5809
5810
|
for i in range(0, len(positions)):
|
5810
5811
|
rawPosition = positions[i]
|
5811
5812
|
if ('data' in rawPosition) and ('is_valid' in rawPosition):
|
5812
5813
|
# futures only
|
5813
|
-
rawPosition = self.
|
5814
|
+
rawPosition = self.safe_dict(rawPosition, 'data')
|
5814
5815
|
results.append(self.parse_position(rawPosition, market))
|
5815
5816
|
return self.filter_by_array_positions(results, 'symbol', symbols, False)
|
5816
5817
|
|
@@ -5908,7 +5909,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
5908
5909
|
rawPosition = positions[i]
|
5909
5910
|
if ('data' in rawPosition) and ('is_valid' in rawPosition):
|
5910
5911
|
# futures only
|
5911
|
-
rawPosition = self.
|
5912
|
+
rawPosition = self.safe_dict(rawPosition, 'data')
|
5912
5913
|
results.append(self.parse_position(rawPosition))
|
5913
5914
|
return self.filter_by_array_positions(results, 'symbol', symbols, False)
|
5914
5915
|
|
@@ -6338,7 +6339,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6338
6339
|
market = self.market(symbol)
|
6339
6340
|
subType = 'linear' if market['linear'] else 'inverse'
|
6340
6341
|
category = self.safe_string(params, 'category', subType)
|
6341
|
-
intervals = self.
|
6342
|
+
intervals = self.safe_dict(self.options, 'intervals')
|
6342
6343
|
interval = self.safe_string(intervals, timeframe) # 5min,15min,30min,1h,4h,1d
|
6343
6344
|
if interval is None:
|
6344
6345
|
raise BadRequest(self.id + ' fetchOpenInterestHistory() cannot use the ' + timeframe + ' timeframe')
|
@@ -6379,7 +6380,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6379
6380
|
# "time": 1672053548579
|
6380
6381
|
# }
|
6381
6382
|
#
|
6382
|
-
result = self.
|
6383
|
+
result = self.safe_dict(response, 'result', {})
|
6383
6384
|
data = self.add_pagination_cursor_to_result(response)
|
6384
6385
|
id = self.safe_string(result, 'symbol')
|
6385
6386
|
market = self.safe_market(id, market, None, 'contract')
|
@@ -6400,7 +6401,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6400
6401
|
if not market['contract']:
|
6401
6402
|
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
|
6402
6403
|
timeframe = self.safe_string(params, 'interval', '1h')
|
6403
|
-
intervals = self.
|
6404
|
+
intervals = self.safe_dict(self.options, 'intervals')
|
6404
6405
|
interval = self.safe_string(intervals, timeframe) # 5min,15min,30min,1h,4h,1d
|
6405
6406
|
if interval is None:
|
6406
6407
|
raise BadRequest(self.id + ' fetchOpenInterest() cannot use the ' + timeframe + ' timeframe')
|
@@ -6435,7 +6436,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6435
6436
|
# "time": 1672053548579
|
6436
6437
|
# }
|
6437
6438
|
#
|
6438
|
-
result = self.
|
6439
|
+
result = self.safe_dict(response, 'result', {})
|
6439
6440
|
id = self.safe_string(result, 'symbol')
|
6440
6441
|
market = self.safe_market(id, market, None, 'contract')
|
6441
6442
|
data = self.add_pagination_cursor_to_result(response)
|
@@ -6517,7 +6518,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6517
6518
|
# }
|
6518
6519
|
#
|
6519
6520
|
timestamp = self.safe_integer(response, 'time')
|
6520
|
-
data = self.
|
6521
|
+
data = self.safe_dict(response, 'result', {})
|
6521
6522
|
data['timestamp'] = timestamp
|
6522
6523
|
return self.parse_borrow_rate(data, currency)
|
6523
6524
|
|
@@ -6581,8 +6582,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
6581
6582
|
# }
|
6582
6583
|
# }
|
6583
6584
|
#
|
6584
|
-
data = self.
|
6585
|
-
rows = self.
|
6585
|
+
data = self.safe_dict(response, 'result', {})
|
6586
|
+
rows = self.safe_list(data, 'loanAccountList', [])
|
6586
6587
|
interest = self.parse_borrow_interests(rows, None)
|
6587
6588
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
6588
6589
|
|
@@ -6623,7 +6624,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6623
6624
|
"""
|
6624
6625
|
await self.load_markets()
|
6625
6626
|
transferId = self.safe_string(params, 'transferId', self.uuid())
|
6626
|
-
accountTypes = self.
|
6627
|
+
accountTypes = self.safe_dict(self.options, 'accountsByType', {})
|
6627
6628
|
fromId = self.safe_string(accountTypes, fromAccount, fromAccount)
|
6628
6629
|
toId = self.safe_string(accountTypes, toAccount, toAccount)
|
6629
6630
|
currency = self.currency(code)
|
@@ -6648,7 +6649,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6648
6649
|
# }
|
6649
6650
|
#
|
6650
6651
|
timestamp = self.safe_integer(response, 'time')
|
6651
|
-
transfer = self.
|
6652
|
+
transfer = self.safe_dict(response, 'result', {})
|
6652
6653
|
statusRaw = self.safe_string_n(response, ['retCode', 'retMsg'])
|
6653
6654
|
status = self.parse_transfer_status(statusRaw)
|
6654
6655
|
return self.extend(self.parse_transfer(transfer, currency), {
|
@@ -6740,7 +6741,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6740
6741
|
# "time": 1662617848970
|
6741
6742
|
# }
|
6742
6743
|
#
|
6743
|
-
result = self.
|
6744
|
+
result = self.safe_dict(response, 'result', {})
|
6744
6745
|
transaction = self.parse_margin_loan(result, currency)
|
6745
6746
|
return self.extend(transaction, {
|
6746
6747
|
'symbol': None,
|
@@ -6774,7 +6775,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6774
6775
|
# "time": 1662618298452
|
6775
6776
|
# }
|
6776
6777
|
#
|
6777
|
-
result = self.
|
6778
|
+
result = self.safe_dict(response, 'result', {})
|
6778
6779
|
transaction = self.parse_margin_loan(result, currency)
|
6779
6780
|
return self.extend(transaction, {
|
6780
6781
|
'symbol': None,
|
@@ -6837,7 +6838,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6837
6838
|
timestamp = self.safe_integer(transfer, 'timestamp')
|
6838
6839
|
fromAccountId = self.safe_string(transfer, 'fromAccountType')
|
6839
6840
|
toAccountId = self.safe_string(transfer, 'toAccountType')
|
6840
|
-
accountIds = self.
|
6841
|
+
accountIds = self.safe_dict(self.options, 'accountsById', {})
|
6841
6842
|
fromAccount = self.safe_string(accountIds, fromAccountId, fromAccountId)
|
6842
6843
|
toAccount = self.safe_string(accountIds, toAccountId, toAccountId)
|
6843
6844
|
return {
|
@@ -6886,8 +6887,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
6886
6887
|
# "time": 1672054488010
|
6887
6888
|
# }
|
6888
6889
|
#
|
6889
|
-
result = self.
|
6890
|
-
tiers = self.
|
6890
|
+
result = self.safe_dict(response, 'result')
|
6891
|
+
tiers = self.safe_list(result, 'list')
|
6891
6892
|
return self.parse_market_leverage_tiers(tiers, market)
|
6892
6893
|
|
6893
6894
|
async def fetch_market_leverage_tiers(self, symbol: str, params={}):
|
@@ -6968,9 +6969,9 @@ class bybit(Exchange, ImplicitAPI):
|
|
6968
6969
|
# "time": 1676360412576
|
6969
6970
|
# }
|
6970
6971
|
#
|
6971
|
-
result = self.
|
6972
|
-
fees = self.
|
6973
|
-
first = self.
|
6972
|
+
result = self.safe_dict(response, 'result', {})
|
6973
|
+
fees = self.safe_list(result, 'list', [])
|
6974
|
+
first = self.safe_dict(fees, 0, {})
|
6974
6975
|
return self.parse_trading_fee(first, market)
|
6975
6976
|
|
6976
6977
|
async def fetch_trading_fees(self, params={}) -> TradingFees:
|
@@ -7004,8 +7005,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
7004
7005
|
# "time": 1676360412576
|
7005
7006
|
# }
|
7006
7007
|
#
|
7007
|
-
fees = self.
|
7008
|
-
fees = self.
|
7008
|
+
fees = self.safe_dict(response, 'result', {})
|
7009
|
+
fees = self.safe_list(fees, 'list', [])
|
7009
7010
|
result = {}
|
7010
7011
|
for i in range(0, len(fees)):
|
7011
7012
|
fee = self.parse_trading_fee(fees[i])
|
@@ -7034,7 +7035,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
7034
7035
|
# ]
|
7035
7036
|
# }
|
7036
7037
|
#
|
7037
|
-
chains = self.
|
7038
|
+
chains = self.safe_list(fee, 'chains', [])
|
7038
7039
|
chainsLength = len(chains)
|
7039
7040
|
result = {
|
7040
7041
|
'info': fee,
|
@@ -7104,7 +7105,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
7104
7105
|
# "time": 1672194582264
|
7105
7106
|
# }
|
7106
7107
|
#
|
7107
|
-
data = self.
|
7108
|
+
data = self.safe_dict(response, 'result', {})
|
7108
7109
|
rows = self.safe_list(data, 'rows', [])
|
7109
7110
|
return self.parse_deposit_withdraw_fees(rows, codes, 'coin')
|
7110
7111
|
|
@@ -7153,8 +7154,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
7153
7154
|
# "time": 1689043527231
|
7154
7155
|
# }
|
7155
7156
|
#
|
7156
|
-
result = self.
|
7157
|
-
data = self.
|
7157
|
+
result = self.safe_dict(response, 'result', {})
|
7158
|
+
data = self.safe_list(result, 'list', [])
|
7158
7159
|
settlements = self.parse_settlements(data, market)
|
7159
7160
|
sorted = self.sort_by(settlements, 'timestamp')
|
7160
7161
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
@@ -7209,8 +7210,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
7209
7210
|
# "time": 1689043527231
|
7210
7211
|
# }
|
7211
7212
|
#
|
7212
|
-
result = self.
|
7213
|
-
data = self.
|
7213
|
+
result = self.safe_dict(response, 'result', {})
|
7214
|
+
data = self.safe_list(result, 'list', [])
|
7214
7215
|
settlements = self.parse_settlements(data, market)
|
7215
7216
|
sorted = self.sort_by(settlements, 'timestamp')
|
7216
7217
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
@@ -7310,7 +7311,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
7310
7311
|
# ]
|
7311
7312
|
# }
|
7312
7313
|
#
|
7313
|
-
volatility = self.
|
7314
|
+
volatility = self.safe_list(response, 'result', [])
|
7314
7315
|
return self.parse_volatility_history(volatility)
|
7315
7316
|
|
7316
7317
|
def parse_volatility_history(self, volatility):
|
@@ -7389,8 +7390,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
7389
7390
|
# }
|
7390
7391
|
#
|
7391
7392
|
timestamp = self.safe_integer(response, 'time')
|
7392
|
-
result = self.
|
7393
|
-
data = self.
|
7393
|
+
result = self.safe_dict(response, 'result', {})
|
7394
|
+
data = self.safe_list(result, 'list', [])
|
7394
7395
|
greeks = self.parse_greeks(data[0], market)
|
7395
7396
|
return self.extend(greeks, {
|
7396
7397
|
'timestamp': timestamp,
|