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