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