ccxt 4.2.63__py2.py3-none-any.whl → 4.2.65__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.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/abstract/blofin.py +1 -0
- ccxt/abstract/krakenfutures.py +1 -0
- ccxt/abstract/kucoin.py +10 -0
- ccxt/abstract/kucoinfutures.py +10 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +2 -2
- ccxt/async_support/binance.py +32 -13
- ccxt/async_support/bingx.py +56 -49
- ccxt/async_support/bitget.py +66 -2
- ccxt/async_support/bitmex.py +2 -1
- ccxt/async_support/blofin.py +45 -12
- ccxt/async_support/btcmarkets.py +9 -0
- ccxt/async_support/bybit.py +90 -6
- ccxt/async_support/coinbase.py +9 -2
- ccxt/async_support/delta.py +92 -2
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/gemini.py +9 -5
- ccxt/async_support/hitbtc.py +1 -1
- ccxt/async_support/krakenfutures.py +1 -0
- ccxt/async_support/kucoin.py +85 -61
- ccxt/async_support/okx.py +1 -1
- ccxt/async_support/woo.py +1 -1
- ccxt/async_support/yobit.py +15 -15
- ccxt/base/exchange.py +14 -3
- ccxt/binance.py +32 -13
- ccxt/bingx.py +56 -49
- ccxt/bitget.py +66 -2
- ccxt/bitmex.py +2 -1
- ccxt/blofin.py +45 -12
- ccxt/btcmarkets.py +9 -0
- ccxt/bybit.py +90 -6
- ccxt/coinbase.py +9 -2
- ccxt/delta.py +92 -2
- ccxt/gate.py +1 -1
- ccxt/gemini.py +9 -5
- ccxt/hitbtc.py +1 -1
- ccxt/krakenfutures.py +1 -0
- ccxt/kucoin.py +85 -61
- ccxt/okx.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitget.py +4 -3
- ccxt/pro/coinex.py +4 -4
- ccxt/pro/currencycom.py +1 -1
- ccxt/pro/lbank.py +1 -1
- ccxt/static_dependencies/ethereum/utils/__init__.py +0 -6
- ccxt/static_dependencies/ethereum/utils/curried/__init__.py +0 -4
- ccxt/test/base/test_shared_methods.py +1 -1
- ccxt/test/test_async.py +13 -1
- ccxt/test/test_sync.py +13 -1
- ccxt/woo.py +1 -1
- ccxt/yobit.py +15 -15
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/METADATA +4 -4
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/RECORD +56 -59
- ccxt/static_dependencies/ethereum/utils/__json/eth_networks.json +0 -1
- ccxt/static_dependencies/ethereum/utils/network.py +0 -88
- ccxt-4.2.63.data/data/ccxt/eth_networks.json +0 -1
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/WHEEL +0 -0
- {ccxt-4.2.63.dist-info → ccxt-4.2.65.dist-info}/top_level.txt +0 -0
ccxt/async_support/kucoin.py
CHANGED
@@ -136,6 +136,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
136
136
|
'futuresPrivate': 'https://api-futures.kucoin.com',
|
137
137
|
'futuresPublic': 'https://api-futures.kucoin.com',
|
138
138
|
'webExchange': 'https://kucoin.com/_api',
|
139
|
+
'broker': 'https://api-broker.kucoin.com',
|
139
140
|
},
|
140
141
|
'www': 'https://www.kucoin.com',
|
141
142
|
'doc': [
|
@@ -249,6 +250,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
249
250
|
'project/marketInterestRate': 7.5, # 5PW
|
250
251
|
'redeem/orders': 10, # 10SW
|
251
252
|
'purchase/orders': 10, # 10SW
|
253
|
+
# broker
|
254
|
+
'broker/api/rebase/download': 3,
|
252
255
|
},
|
253
256
|
'post': {
|
254
257
|
# account
|
@@ -394,6 +397,23 @@ class kucoin(Exchange, ImplicitAPI):
|
|
394
397
|
'currency/currency/chain-info': 1, # self is temporary from webApi
|
395
398
|
},
|
396
399
|
},
|
400
|
+
'broker': {
|
401
|
+
'get': {
|
402
|
+
'broker/nd/info': 2,
|
403
|
+
'broker/nd/account': 2,
|
404
|
+
'broker/nd/account/apikey': 2,
|
405
|
+
'broker/nd/rebase/download': 3,
|
406
|
+
},
|
407
|
+
'post': {
|
408
|
+
'broker/nd/transfer': 1,
|
409
|
+
'broker/nd/account': 3,
|
410
|
+
'broker/nd/account/apikey': 3,
|
411
|
+
'broker/nd/account/update-apikey': 3,
|
412
|
+
},
|
413
|
+
'delete': {
|
414
|
+
'broker/nd/account/apikey': 3,
|
415
|
+
},
|
416
|
+
},
|
397
417
|
},
|
398
418
|
'timeframes': {
|
399
419
|
'1m': '1min',
|
@@ -907,7 +927,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
907
927
|
# }
|
908
928
|
# }
|
909
929
|
#
|
910
|
-
data = self.
|
930
|
+
data = self.safe_dict(response, 'data', {})
|
911
931
|
status = self.safe_string(data, 'status')
|
912
932
|
return {
|
913
933
|
'status': 'ok' if (status == 'open') else 'maintenance',
|
@@ -951,8 +971,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
951
971
|
# ]
|
952
972
|
# }
|
953
973
|
#
|
954
|
-
data = self.
|
955
|
-
options = self.
|
974
|
+
data = self.safe_list(response, 'data')
|
975
|
+
options = self.safe_dict(self.options, 'fetchMarkets', {})
|
956
976
|
fetchTickersFees = self.safe_bool(options, 'fetchTickersFees', True)
|
957
977
|
tickersResponse = {}
|
958
978
|
if fetchTickersFees:
|
@@ -985,8 +1005,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
985
1005
|
# }
|
986
1006
|
# }
|
987
1007
|
#
|
988
|
-
tickersData = self.
|
989
|
-
tickers = self.
|
1008
|
+
tickersData = self.safe_dict(tickersResponse, 'data', {})
|
1009
|
+
tickers = self.safe_list(tickersData, 'ticker', [])
|
990
1010
|
tickersByMarketId = self.index_by(tickers, 'symbol')
|
991
1011
|
result = []
|
992
1012
|
for i in range(0, len(data)):
|
@@ -996,7 +1016,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
996
1016
|
base = self.safe_currency_code(baseId)
|
997
1017
|
quote = self.safe_currency_code(quoteId)
|
998
1018
|
# quoteIncrement = self.safe_number(market, 'quoteIncrement')
|
999
|
-
ticker = self.
|
1019
|
+
ticker = self.safe_dict(tickersByMarketId, id, {})
|
1000
1020
|
makerFeeRate = self.safe_string(ticker, 'makerFeeRate')
|
1001
1021
|
takerFeeRate = self.safe_string(ticker, 'takerFeeRate')
|
1002
1022
|
makerCoefficient = self.safe_string(ticker, 'makerCoefficient')
|
@@ -1012,11 +1032,11 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1012
1032
|
'settleId': None,
|
1013
1033
|
'type': 'spot',
|
1014
1034
|
'spot': True,
|
1015
|
-
'margin': self.
|
1035
|
+
'margin': self.safe_bool(market, 'isMarginEnabled'),
|
1016
1036
|
'swap': False,
|
1017
1037
|
'future': False,
|
1018
1038
|
'option': False,
|
1019
|
-
'active': self.
|
1039
|
+
'active': self.safe_bool(market, 'enableTrading'),
|
1020
1040
|
'contract': False,
|
1021
1041
|
'linear': None,
|
1022
1042
|
'inverse': None,
|
@@ -1143,7 +1163,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1143
1163
|
isWithdrawEnabled = None
|
1144
1164
|
isDepositEnabled = None
|
1145
1165
|
networks = {}
|
1146
|
-
chains = self.
|
1166
|
+
chains = self.safe_list(entry, 'chains', [])
|
1147
1167
|
extraChainsData = self.index_by(self.safe_value(additionalDataGrouped, id, []), 'chain')
|
1148
1168
|
rawPrecision = self.safe_string(entry, 'precision')
|
1149
1169
|
precision = self.parse_number(self.parse_precision(rawPrecision))
|
@@ -1166,7 +1186,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1166
1186
|
isDepositEnabled = chainDepositEnabled
|
1167
1187
|
else:
|
1168
1188
|
isDepositEnabled = isDepositEnabled or chainDepositEnabled
|
1169
|
-
chainExtraData = self.
|
1189
|
+
chainExtraData = self.safe_dict(extraChainsData, chainId, {})
|
1170
1190
|
networks[networkCode] = {
|
1171
1191
|
'info': chain,
|
1172
1192
|
'id': chainId,
|
@@ -1237,7 +1257,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1237
1257
|
# ]
|
1238
1258
|
# }
|
1239
1259
|
#
|
1240
|
-
data = self.
|
1260
|
+
data = self.safe_list(response, 'data', [])
|
1241
1261
|
result = []
|
1242
1262
|
for i in range(0, len(data)):
|
1243
1263
|
account = data[i]
|
@@ -1318,7 +1338,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1318
1338
|
# }
|
1319
1339
|
# }
|
1320
1340
|
#
|
1321
|
-
data = self.
|
1341
|
+
data = self.safe_dict(response, 'data')
|
1322
1342
|
return self.parse_deposit_withdraw_fee(data, currency)
|
1323
1343
|
|
1324
1344
|
def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
|
@@ -1349,7 +1369,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1349
1369
|
},
|
1350
1370
|
'networks': {},
|
1351
1371
|
}
|
1352
|
-
isWithdrawEnabled = self.
|
1372
|
+
isWithdrawEnabled = self.safe_bool(fee, 'isWithdrawEnabled')
|
1353
1373
|
if isWithdrawEnabled:
|
1354
1374
|
result['withdraw']['fee'] = self.safe_number_2(fee, 'withdrawalMinFee', 'withdrawMinFee')
|
1355
1375
|
result['withdraw']['percentage'] = False
|
@@ -1374,7 +1394,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1374
1394
|
#
|
1375
1395
|
defaultType = self.safe_string_2(self.options, methodName, 'defaultType', 'trade')
|
1376
1396
|
requestedType = self.safe_string(params, 'type', defaultType)
|
1377
|
-
accountsByType = self.
|
1397
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType')
|
1378
1398
|
type = self.safe_string(accountsByType, requestedType)
|
1379
1399
|
if type is None:
|
1380
1400
|
keys = list(accountsByType.keys())
|
@@ -1511,8 +1531,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1511
1531
|
# }
|
1512
1532
|
# }
|
1513
1533
|
#
|
1514
|
-
data = self.
|
1515
|
-
tickers = self.
|
1534
|
+
data = self.safe_dict(response, 'data', {})
|
1535
|
+
tickers = self.safe_list(data, 'ticker', [])
|
1516
1536
|
time = self.safe_integer(data, 'time')
|
1517
1537
|
result = {}
|
1518
1538
|
for i in range(0, len(tickers)):
|
@@ -1632,7 +1652,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1632
1652
|
# ]
|
1633
1653
|
# }
|
1634
1654
|
#
|
1635
|
-
data = self.
|
1655
|
+
data = self.safe_list(response, 'data', [])
|
1636
1656
|
return self.parse_ohlcvs(data, market, timeframe, since, limit)
|
1637
1657
|
|
1638
1658
|
async def create_deposit_address(self, code: str, params={}):
|
@@ -1657,7 +1677,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1657
1677
|
# {"code":"260000","msg":"Deposit address already exists."}
|
1658
1678
|
# BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}}
|
1659
1679
|
# BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}}
|
1660
|
-
data = self.
|
1680
|
+
data = self.safe_dict(response, 'data', {})
|
1661
1681
|
return self.parse_deposit_address(data, currency)
|
1662
1682
|
|
1663
1683
|
async def fetch_deposit_address(self, code: str, params={}):
|
@@ -1743,7 +1763,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1743
1763
|
# }
|
1744
1764
|
#
|
1745
1765
|
self.options['versions']['private']['GET']['deposit-addresses'] = version
|
1746
|
-
chains = self.
|
1766
|
+
chains = self.safe_list(response, 'data', [])
|
1747
1767
|
parsed = self.parse_deposit_addresses(chains, [currency['code']], False, {
|
1748
1768
|
'currency': currency['id'],
|
1749
1769
|
})
|
@@ -1808,7 +1828,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1808
1828
|
# ]
|
1809
1829
|
# }
|
1810
1830
|
#
|
1811
|
-
data = self.
|
1831
|
+
data = self.safe_dict(response, 'data', {})
|
1812
1832
|
timestamp = self.safe_integer(data, 'time')
|
1813
1833
|
orderbook = self.parse_order_book(data, market['symbol'], timestamp, 'bids', 'asks', level - 2, level - 1)
|
1814
1834
|
orderbook['nonce'] = self.safe_integer(data, 'sequence')
|
@@ -1900,7 +1920,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1900
1920
|
# }
|
1901
1921
|
# }
|
1902
1922
|
#
|
1903
|
-
data = self.
|
1923
|
+
data = self.safe_dict(response, 'data', {})
|
1904
1924
|
return self.parse_order(data, market)
|
1905
1925
|
|
1906
1926
|
async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
|
@@ -2013,8 +2033,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2013
2033
|
# },
|
2014
2034
|
# }
|
2015
2035
|
#
|
2016
|
-
data = self.
|
2017
|
-
data = self.
|
2036
|
+
data = self.safe_dict(response, 'data', {})
|
2037
|
+
data = self.safe_list(data, 'data', [])
|
2018
2038
|
return self.parse_orders(data)
|
2019
2039
|
|
2020
2040
|
def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: float = None, params={}):
|
@@ -2111,7 +2131,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2111
2131
|
# }
|
2112
2132
|
# }
|
2113
2133
|
#
|
2114
|
-
data = self.
|
2134
|
+
data = self.safe_dict(response, 'data', {})
|
2115
2135
|
return self.parse_order(data, market)
|
2116
2136
|
|
2117
2137
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
@@ -2133,7 +2153,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2133
2153
|
await self.load_markets()
|
2134
2154
|
request = {}
|
2135
2155
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
2136
|
-
stop = self.
|
2156
|
+
stop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
2137
2157
|
hf = self.safe_bool(params, 'hf', False)
|
2138
2158
|
if hf:
|
2139
2159
|
if symbol is None:
|
@@ -2300,7 +2320,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2300
2320
|
# ]
|
2301
2321
|
# }
|
2302
2322
|
# }
|
2303
|
-
responseData = self.
|
2323
|
+
responseData = self.safe_dict(response, 'data', {})
|
2304
2324
|
orders = self.safe_value(responseData, 'items', responseData)
|
2305
2325
|
return self.parse_orders(orders, market, since, limit)
|
2306
2326
|
|
@@ -2415,7 +2435,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2415
2435
|
response = await self.privateGetHfOrdersOrderId(self.extend(request, params))
|
2416
2436
|
else:
|
2417
2437
|
response = await self.privateGetOrdersOrderId(self.extend(request, params))
|
2418
|
-
responseData = self.
|
2438
|
+
responseData = self.safe_dict(response, 'data', {})
|
2419
2439
|
if isinstance(responseData, list):
|
2420
2440
|
responseData = self.safe_value(responseData, 0)
|
2421
2441
|
return self.parse_order(responseData, market)
|
@@ -2549,7 +2569,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2549
2569
|
responseStop = self.safe_string(order, 'stop')
|
2550
2570
|
stop = responseStop is not None
|
2551
2571
|
stopTriggered = self.safe_bool(order, 'stopTriggered', False)
|
2552
|
-
isActive = self.
|
2572
|
+
isActive = self.safe_bool_2(order, 'isActive', 'active')
|
2553
2573
|
responseStatus = self.safe_string(order, 'status')
|
2554
2574
|
status = None
|
2555
2575
|
if isActive is not None:
|
@@ -2574,7 +2594,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2574
2594
|
'symbol': self.safe_symbol(marketId, market, '-'),
|
2575
2595
|
'type': self.safe_string(order, 'type'),
|
2576
2596
|
'timeInForce': self.safe_string(order, 'timeInForce'),
|
2577
|
-
'postOnly': self.
|
2597
|
+
'postOnly': self.safe_bool(order, 'postOnly'),
|
2578
2598
|
'side': self.safe_string(order, 'side'),
|
2579
2599
|
'amount': self.safe_string(order, 'size'),
|
2580
2600
|
'price': self.safe_string(order, 'price'), # price is zero for market order, omitZero is called in safeOrder2
|
@@ -2701,12 +2721,12 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2701
2721
|
# ]
|
2702
2722
|
# }
|
2703
2723
|
#
|
2704
|
-
data = self.
|
2724
|
+
data = self.safe_dict(response, 'data', {})
|
2705
2725
|
trades = None
|
2706
2726
|
if parseResponseData:
|
2707
2727
|
trades = data
|
2708
2728
|
else:
|
2709
|
-
trades = self.
|
2729
|
+
trades = self.safe_list(data, 'items', [])
|
2710
2730
|
return self.parse_trades(trades, market, since, limit)
|
2711
2731
|
|
2712
2732
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
@@ -2746,7 +2766,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2746
2766
|
# ]
|
2747
2767
|
# }
|
2748
2768
|
#
|
2749
|
-
trades = self.
|
2769
|
+
trades = self.safe_list(response, 'data', [])
|
2750
2770
|
return self.parse_trades(trades, market, since, limit)
|
2751
2771
|
|
2752
2772
|
def parse_trade(self, trade, market: Market = None) -> Trade:
|
@@ -2900,8 +2920,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2900
2920
|
# ]
|
2901
2921
|
# }
|
2902
2922
|
#
|
2903
|
-
data = self.
|
2904
|
-
first = self.
|
2923
|
+
data = self.safe_list(response, 'data', [])
|
2924
|
+
first = self.safe_dict(data, 0)
|
2905
2925
|
marketId = self.safe_string(first, 'symbol')
|
2906
2926
|
return {
|
2907
2927
|
'info': response,
|
@@ -2957,7 +2977,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2957
2977
|
# }
|
2958
2978
|
# }
|
2959
2979
|
#
|
2960
|
-
data = self.
|
2980
|
+
data = self.safe_dict(response, 'data', {})
|
2961
2981
|
return self.parse_transaction(data, currency)
|
2962
2982
|
|
2963
2983
|
def parse_transaction_status(self, status):
|
@@ -3048,7 +3068,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3048
3068
|
timestamp = timestamp * 1000
|
3049
3069
|
if updated is not None:
|
3050
3070
|
updated = updated * 1000
|
3051
|
-
internal = self.
|
3071
|
+
internal = self.safe_bool(transaction, 'isInner')
|
3052
3072
|
tag = self.safe_string(transaction, 'memo')
|
3053
3073
|
return {
|
3054
3074
|
'info': transaction,
|
@@ -3255,7 +3275,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3255
3275
|
currency = self.currency(code)
|
3256
3276
|
defaultType = self.safe_string_2(self.options, 'fetchBalance', 'defaultType', 'spot')
|
3257
3277
|
requestedType = self.safe_string(params, 'type', defaultType)
|
3258
|
-
accountsByType = self.
|
3278
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType')
|
3259
3279
|
type = self.safe_string(accountsByType, requestedType, requestedType)
|
3260
3280
|
params = self.omit(params, 'type')
|
3261
3281
|
isHf = self.safe_bool(params, 'hf', False)
|
@@ -3331,7 +3351,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3331
3351
|
# }
|
3332
3352
|
# }
|
3333
3353
|
#
|
3334
|
-
data = self.
|
3354
|
+
data = self.safe_list(response, 'data', [])
|
3335
3355
|
result = {
|
3336
3356
|
'info': response,
|
3337
3357
|
'timestamp': None,
|
@@ -3343,8 +3363,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3343
3363
|
entry = assets[i]
|
3344
3364
|
marketId = self.safe_string(entry, 'symbol')
|
3345
3365
|
symbol = self.safe_symbol(marketId, None, '_')
|
3346
|
-
base = self.
|
3347
|
-
quote = self.
|
3366
|
+
base = self.safe_dict(entry, 'baseAsset', {})
|
3367
|
+
quote = self.safe_dict(entry, 'quoteAsset', {})
|
3348
3368
|
baseCode = self.safe_currency_code(self.safe_string(base, 'currency'))
|
3349
3369
|
quoteCode = self.safe_currency_code(self.safe_string(quote, 'currency'))
|
3350
3370
|
subResult = {}
|
@@ -3352,7 +3372,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3352
3372
|
subResult[quoteCode] = self.parse_balance_helper(quote)
|
3353
3373
|
result[symbol] = self.safe_balance(subResult)
|
3354
3374
|
elif cross:
|
3355
|
-
accounts = self.
|
3375
|
+
accounts = self.safe_list(data, 'accounts', [])
|
3356
3376
|
for i in range(0, len(accounts)):
|
3357
3377
|
balance = accounts[i]
|
3358
3378
|
currencyId = self.safe_string(balance, 'currency')
|
@@ -3428,7 +3448,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3428
3448
|
# }
|
3429
3449
|
# }
|
3430
3450
|
#
|
3431
|
-
data = self.
|
3451
|
+
data = self.safe_dict(response, 'data')
|
3432
3452
|
return self.parse_transfer(data, currency)
|
3433
3453
|
else:
|
3434
3454
|
request = {
|
@@ -3455,7 +3475,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3455
3475
|
# }
|
3456
3476
|
# }
|
3457
3477
|
#
|
3458
|
-
data = self.
|
3478
|
+
data = self.safe_dict(response, 'data')
|
3459
3479
|
return self.parse_transfer(data, currency)
|
3460
3480
|
|
3461
3481
|
def parse_transfer(self, transfer, currency: Currency = None):
|
@@ -3498,7 +3518,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3498
3518
|
rawStatus = self.safe_string(transfer, 'status')
|
3499
3519
|
accountFromRaw = self.safe_string_lower(transfer, 'payAccountType')
|
3500
3520
|
accountToRaw = self.safe_string_lower(transfer, 'recAccountType')
|
3501
|
-
accountsByType = self.
|
3521
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType')
|
3502
3522
|
accountFrom = self.safe_string(accountsByType, accountFromRaw, accountFromRaw)
|
3503
3523
|
accountTo = self.safe_string(accountsByType, accountToRaw, accountToRaw)
|
3504
3524
|
return {
|
@@ -3660,7 +3680,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3660
3680
|
await self.load_accounts()
|
3661
3681
|
paginate = False
|
3662
3682
|
paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
|
3663
|
-
isHf = self.
|
3683
|
+
isHf = self.safe_bool(params, 'hf')
|
3664
3684
|
params = self.omit(params, 'hf')
|
3665
3685
|
if paginate:
|
3666
3686
|
return await self.fetch_paginated_call_dynamic('fetchLedger', code, since, limit, params)
|
@@ -3734,9 +3754,9 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3734
3754
|
return self.parse_ledger(items, currency, since, limit)
|
3735
3755
|
|
3736
3756
|
def calculate_rate_limiter_cost(self, api, method, path, params, config={}):
|
3737
|
-
versions = self.
|
3738
|
-
apiVersions = self.
|
3739
|
-
methodVersions = self.
|
3757
|
+
versions = self.safe_dict(self.options, 'versions', {})
|
3758
|
+
apiVersions = self.safe_dict(versions, api, {})
|
3759
|
+
methodVersions = self.safe_dict(apiVersions, method, {})
|
3740
3760
|
defaultVersion = self.safe_string(methodVersions, path, self.options['version'])
|
3741
3761
|
version = self.safe_string(params, 'version', defaultVersion)
|
3742
3762
|
if version == 'v3' and ('v3' in config):
|
@@ -3870,8 +3890,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3870
3890
|
# }
|
3871
3891
|
# }
|
3872
3892
|
#
|
3873
|
-
data = self.
|
3874
|
-
assets = self.
|
3893
|
+
data = self.safe_dict(response, 'data', {})
|
3894
|
+
assets = self.safe_list(data, 'assets', []) if (marginMode == 'isolated') else self.safe_list(data, 'accounts', [])
|
3875
3895
|
return self.parse_borrow_interests(assets, None)
|
3876
3896
|
|
3877
3897
|
def parse_borrow_interest(self, info, market: Market = None):
|
@@ -3924,7 +3944,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3924
3944
|
market = self.safe_market(marketId, market)
|
3925
3945
|
symbol = self.safe_string(market, 'symbol')
|
3926
3946
|
timestamp = self.safe_integer(info, 'createdAt')
|
3927
|
-
isolatedBase = self.
|
3947
|
+
isolatedBase = self.safe_dict(info, 'baseAsset', {})
|
3928
3948
|
amountBorrowed = None
|
3929
3949
|
interest = None
|
3930
3950
|
currencyId = None
|
@@ -3978,7 +3998,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3978
3998
|
# }
|
3979
3999
|
# }
|
3980
4000
|
#
|
3981
|
-
data = self.
|
4001
|
+
data = self.safe_dict(response, 'data', {})
|
3982
4002
|
return self.parse_margin_loan(data, currency)
|
3983
4003
|
|
3984
4004
|
async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
@@ -4015,7 +4035,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4015
4035
|
# }
|
4016
4036
|
# }
|
4017
4037
|
#
|
4018
|
-
data = self.
|
4038
|
+
data = self.safe_dict(response, 'data', {})
|
4019
4039
|
return self.parse_margin_loan(data, currency)
|
4020
4040
|
|
4021
4041
|
async def repay_cross_margin(self, code: str, amount, params={}):
|
@@ -4046,7 +4066,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4046
4066
|
# }
|
4047
4067
|
# }
|
4048
4068
|
#
|
4049
|
-
data = self.
|
4069
|
+
data = self.safe_dict(response, 'data', {})
|
4050
4070
|
return self.parse_margin_loan(data, currency)
|
4051
4071
|
|
4052
4072
|
async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
@@ -4081,7 +4101,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4081
4101
|
# }
|
4082
4102
|
# }
|
4083
4103
|
#
|
4084
|
-
data = self.
|
4104
|
+
data = self.safe_dict(response, 'data', {})
|
4085
4105
|
return self.parse_margin_loan(data, currency)
|
4086
4106
|
|
4087
4107
|
def parse_margin_loan(self, info, currency: Currency = None):
|
@@ -4131,7 +4151,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4131
4151
|
# },
|
4132
4152
|
# ]
|
4133
4153
|
#
|
4134
|
-
data = self.
|
4154
|
+
data = self.safe_list(response, 'data', [])
|
4135
4155
|
return self.parse_deposit_withdraw_fees(data, codes, 'currency')
|
4136
4156
|
|
4137
4157
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
@@ -4140,9 +4160,9 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4140
4160
|
# ↑ ↑
|
4141
4161
|
# ↑ ↑
|
4142
4162
|
#
|
4143
|
-
versions = self.
|
4144
|
-
apiVersions = self.
|
4145
|
-
methodVersions = self.
|
4163
|
+
versions = self.safe_dict(self.options, 'versions', {})
|
4164
|
+
apiVersions = self.safe_dict(versions, api, {})
|
4165
|
+
methodVersions = self.safe_dict(apiVersions, method, {})
|
4146
4166
|
defaultVersion = self.safe_string(methodVersions, path, self.options['version'])
|
4147
4167
|
version = self.safe_string(params, 'version', defaultVersion)
|
4148
4168
|
params = self.omit(params, 'version')
|
@@ -4163,7 +4183,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4163
4183
|
url = url + endpoint
|
4164
4184
|
isFuturePrivate = (api == 'futuresPrivate')
|
4165
4185
|
isPrivate = (api == 'private')
|
4166
|
-
|
4186
|
+
isBroker = (api == 'private')
|
4187
|
+
if isPrivate or isFuturePrivate or isBroker:
|
4167
4188
|
self.check_required_credentials()
|
4168
4189
|
timestamp = str(self.nonce())
|
4169
4190
|
headers = self.extend({
|
@@ -4180,7 +4201,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4180
4201
|
payload = timestamp + method + endpoint + endpart
|
4181
4202
|
signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
|
4182
4203
|
headers['KC-API-SIGN'] = signature
|
4183
|
-
partner = self.
|
4204
|
+
partner = self.safe_dict(self.options, 'partner', {})
|
4184
4205
|
partner = self.safe_value(partner, 'future', partner) if isFuturePrivate else self.safe_value(partner, 'spot', partner)
|
4185
4206
|
partnerId = self.safe_string(partner, 'id')
|
4186
4207
|
partnerSecret = self.safe_string_2(partner, 'secret', 'key')
|
@@ -4189,6 +4210,9 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4189
4210
|
partnerSignature = self.hmac(self.encode(partnerPayload), self.encode(partnerSecret), hashlib.sha256, 'base64')
|
4190
4211
|
headers['KC-API-PARTNER-SIGN'] = partnerSignature
|
4191
4212
|
headers['KC-API-PARTNER'] = partnerId
|
4213
|
+
if isBroker:
|
4214
|
+
brokerName = self.safe_string(partner, 'name')
|
4215
|
+
headers['KC-BROKER-NAME'] = brokerName
|
4192
4216
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
4193
4217
|
|
4194
4218
|
def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
ccxt/async_support/okx.py
CHANGED
@@ -6497,7 +6497,7 @@ class okx(Exchange, ImplicitAPI):
|
|
6497
6497
|
'info': interest,
|
6498
6498
|
}, market)
|
6499
6499
|
|
6500
|
-
def set_sandbox_mode(self, enable):
|
6500
|
+
def set_sandbox_mode(self, enable: bool):
|
6501
6501
|
super(okx, self).set_sandbox_mode(enable)
|
6502
6502
|
self.options['sandboxMode'] = enable
|
6503
6503
|
if enable:
|
ccxt/async_support/woo.py
CHANGED
@@ -2732,6 +2732,6 @@ class woo(Exchange, ImplicitAPI):
|
|
2732
2732
|
# if it was not returned according to above options, then return the first network of currency
|
2733
2733
|
return self.safe_value(networkKeys, 0)
|
2734
2734
|
|
2735
|
-
def set_sandbox_mode(self, enable):
|
2735
|
+
def set_sandbox_mode(self, enable: bool):
|
2736
2736
|
super(woo, self).set_sandbox_mode(enable)
|
2737
2737
|
self.options['sandboxMode'] = enable
|
ccxt/async_support/yobit.py
CHANGED
@@ -292,15 +292,15 @@ class yobit(Exchange, ImplicitAPI):
|
|
292
292
|
})
|
293
293
|
|
294
294
|
def parse_balance(self, response) -> Balances:
|
295
|
-
balances = self.
|
295
|
+
balances = self.safe_dict(response, 'return', {})
|
296
296
|
timestamp = self.safe_integer(balances, 'server_time')
|
297
297
|
result = {
|
298
298
|
'info': response,
|
299
299
|
'timestamp': timestamp,
|
300
300
|
'datetime': self.iso8601(timestamp),
|
301
301
|
}
|
302
|
-
free = self.
|
303
|
-
total = self.
|
302
|
+
free = self.safe_dict(balances, 'funds', {})
|
303
|
+
total = self.safe_dict(balances, 'funds_incl_orders', {})
|
304
304
|
currencyIds = list(self.extend(free, total).keys())
|
305
305
|
for i in range(0, len(currencyIds)):
|
306
306
|
currencyId = currencyIds[i]
|
@@ -373,7 +373,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
373
373
|
# },
|
374
374
|
# }
|
375
375
|
#
|
376
|
-
markets = self.
|
376
|
+
markets = self.safe_dict(response, 'pairs', {})
|
377
377
|
keys = list(markets.keys())
|
378
378
|
result = []
|
379
379
|
for i in range(0, len(keys)):
|
@@ -637,7 +637,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
637
637
|
'cost': feeCostString,
|
638
638
|
'currency': feeCurrencyCode,
|
639
639
|
}
|
640
|
-
isYourOrder = self.
|
640
|
+
isYourOrder = self.safe_string(trade, 'is_your_order')
|
641
641
|
if isYourOrder is not None:
|
642
642
|
if fee is None:
|
643
643
|
feeInNumbers = self.calculate_fee(symbol, type, side, amount, price, 'taker')
|
@@ -697,7 +697,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
697
697
|
numElements = len(response)
|
698
698
|
if numElements == 0:
|
699
699
|
return []
|
700
|
-
result = self.
|
700
|
+
result = self.safe_list(response, market['id'], [])
|
701
701
|
return self.parse_trades(result, market, since, limit)
|
702
702
|
|
703
703
|
async def fetch_trading_fees(self, params={}):
|
@@ -728,12 +728,12 @@ class yobit(Exchange, ImplicitAPI):
|
|
728
728
|
# },
|
729
729
|
# }
|
730
730
|
#
|
731
|
-
pairs = self.
|
731
|
+
pairs = self.safe_dict(response, 'pairs', {})
|
732
732
|
marketIds = list(pairs.keys())
|
733
733
|
result = {}
|
734
734
|
for i in range(0, len(marketIds)):
|
735
735
|
marketId = marketIds[i]
|
736
|
-
pair = self.
|
736
|
+
pair = self.safe_dict(pairs, marketId, {})
|
737
737
|
symbol = self.safe_symbol(marketId, None, '_')
|
738
738
|
takerString = self.safe_string(pair, 'fee_buyer')
|
739
739
|
makerString = self.safe_string(pair, 'fee_seller')
|
@@ -793,7 +793,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
793
793
|
# }
|
794
794
|
# }
|
795
795
|
#
|
796
|
-
result = self.
|
796
|
+
result = self.safe_dict(response, 'return')
|
797
797
|
return self.parse_order(result, market)
|
798
798
|
|
799
799
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
@@ -829,7 +829,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
829
829
|
# }
|
830
830
|
# }
|
831
831
|
#
|
832
|
-
result = self.
|
832
|
+
result = self.safe_dict(response, 'return', {})
|
833
833
|
return self.parse_order(result)
|
834
834
|
|
835
835
|
def parse_order_status(self, status):
|
@@ -957,7 +957,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
957
957
|
}
|
958
958
|
response = await self.privatePostOrderInfo(self.extend(request, params))
|
959
959
|
id = str(id)
|
960
|
-
orders = self.
|
960
|
+
orders = self.safe_dict(response, 'return', {})
|
961
961
|
#
|
962
962
|
# {
|
963
963
|
# "success":1,
|
@@ -1018,7 +1018,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
1018
1018
|
# }
|
1019
1019
|
# }
|
1020
1020
|
#
|
1021
|
-
result = self.
|
1021
|
+
result = self.safe_dict(response, 'return', {})
|
1022
1022
|
return self.parse_orders(result, market, since, limit)
|
1023
1023
|
|
1024
1024
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
@@ -1067,7 +1067,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
1067
1067
|
# }
|
1068
1068
|
# }
|
1069
1069
|
#
|
1070
|
-
trades = self.
|
1070
|
+
trades = self.safe_dict(response, 'return', {})
|
1071
1071
|
ids = list(trades.keys())
|
1072
1072
|
result = []
|
1073
1073
|
for i in range(0, len(ids)):
|
@@ -1110,7 +1110,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
1110
1110
|
await self.load_markets()
|
1111
1111
|
currency = self.currency(code)
|
1112
1112
|
currencyId = currency['id']
|
1113
|
-
networks = self.
|
1113
|
+
networks = self.safe_dict(self.options, 'networks', {})
|
1114
1114
|
network = self.safe_string_upper(params, 'network') # self line allows the user to specify either ERC20 or ETH
|
1115
1115
|
network = self.safe_string(networks, network, network) # handle ERC20>ETH alias
|
1116
1116
|
if network is not None:
|
@@ -1263,7 +1263,7 @@ class yobit(Exchange, ImplicitAPI):
|
|
1263
1263
|
#
|
1264
1264
|
# To cover points 1, 2, 3 and 4 combined self handler should work like self:
|
1265
1265
|
#
|
1266
|
-
success = self.
|
1266
|
+
success = self.safe_value(response, 'success') # don't replace with safeBool here
|
1267
1267
|
if isinstance(success, str):
|
1268
1268
|
if (success == 'true') or (success == '1'):
|
1269
1269
|
success = True
|