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