ccxt 4.2.64__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/kucoin.py +9 -0
- ccxt/abstract/kucoinfutures.py +9 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +2 -2
- ccxt/async_support/binance.py +26 -4
- ccxt/async_support/bingx.py +11 -4
- ccxt/async_support/bitmex.py +2 -1
- ccxt/async_support/blofin.py +34 -1
- ccxt/async_support/btcmarkets.py +9 -0
- ccxt/async_support/coinbase.py +9 -2
- ccxt/async_support/delta.py +92 -2
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/kucoin.py +84 -61
- ccxt/async_support/okx.py +1 -1
- ccxt/async_support/woo.py +1 -1
- ccxt/base/exchange.py +14 -3
- ccxt/binance.py +26 -4
- ccxt/bingx.py +11 -4
- ccxt/bitmex.py +2 -1
- ccxt/blofin.py +34 -1
- ccxt/btcmarkets.py +9 -0
- ccxt/coinbase.py +9 -2
- ccxt/delta.py +92 -2
- ccxt/gate.py +1 -1
- ccxt/kucoin.py +84 -61
- ccxt/okx.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/currencycom.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/woo.py +1 -1
- {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/METADATA +4 -4
- {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/RECORD +38 -41
- ccxt/static_dependencies/ethereum/utils/__json/eth_networks.json +0 -1
- ccxt/static_dependencies/ethereum/utils/network.py +0 -88
- ccxt-4.2.64.data/data/ccxt/eth_networks.json +0 -1
- {ccxt-4.2.64.dist-info → ccxt-4.2.65.dist-info}/WHEEL +0 -0
- {ccxt-4.2.64.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,7 @@ 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
|
252
254
|
'broker/api/rebase/download': 3,
|
253
255
|
},
|
254
256
|
'post': {
|
@@ -395,6 +397,23 @@ class kucoin(Exchange, ImplicitAPI):
|
|
395
397
|
'currency/currency/chain-info': 1, # self is temporary from webApi
|
396
398
|
},
|
397
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
|
+
},
|
398
417
|
},
|
399
418
|
'timeframes': {
|
400
419
|
'1m': '1min',
|
@@ -908,7 +927,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
908
927
|
# }
|
909
928
|
# }
|
910
929
|
#
|
911
|
-
data = self.
|
930
|
+
data = self.safe_dict(response, 'data', {})
|
912
931
|
status = self.safe_string(data, 'status')
|
913
932
|
return {
|
914
933
|
'status': 'ok' if (status == 'open') else 'maintenance',
|
@@ -952,8 +971,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
952
971
|
# ]
|
953
972
|
# }
|
954
973
|
#
|
955
|
-
data = self.
|
956
|
-
options = self.
|
974
|
+
data = self.safe_list(response, 'data')
|
975
|
+
options = self.safe_dict(self.options, 'fetchMarkets', {})
|
957
976
|
fetchTickersFees = self.safe_bool(options, 'fetchTickersFees', True)
|
958
977
|
tickersResponse = {}
|
959
978
|
if fetchTickersFees:
|
@@ -986,8 +1005,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
986
1005
|
# }
|
987
1006
|
# }
|
988
1007
|
#
|
989
|
-
tickersData = self.
|
990
|
-
tickers = self.
|
1008
|
+
tickersData = self.safe_dict(tickersResponse, 'data', {})
|
1009
|
+
tickers = self.safe_list(tickersData, 'ticker', [])
|
991
1010
|
tickersByMarketId = self.index_by(tickers, 'symbol')
|
992
1011
|
result = []
|
993
1012
|
for i in range(0, len(data)):
|
@@ -997,7 +1016,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
997
1016
|
base = self.safe_currency_code(baseId)
|
998
1017
|
quote = self.safe_currency_code(quoteId)
|
999
1018
|
# quoteIncrement = self.safe_number(market, 'quoteIncrement')
|
1000
|
-
ticker = self.
|
1019
|
+
ticker = self.safe_dict(tickersByMarketId, id, {})
|
1001
1020
|
makerFeeRate = self.safe_string(ticker, 'makerFeeRate')
|
1002
1021
|
takerFeeRate = self.safe_string(ticker, 'takerFeeRate')
|
1003
1022
|
makerCoefficient = self.safe_string(ticker, 'makerCoefficient')
|
@@ -1013,11 +1032,11 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1013
1032
|
'settleId': None,
|
1014
1033
|
'type': 'spot',
|
1015
1034
|
'spot': True,
|
1016
|
-
'margin': self.
|
1035
|
+
'margin': self.safe_bool(market, 'isMarginEnabled'),
|
1017
1036
|
'swap': False,
|
1018
1037
|
'future': False,
|
1019
1038
|
'option': False,
|
1020
|
-
'active': self.
|
1039
|
+
'active': self.safe_bool(market, 'enableTrading'),
|
1021
1040
|
'contract': False,
|
1022
1041
|
'linear': None,
|
1023
1042
|
'inverse': None,
|
@@ -1144,7 +1163,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1144
1163
|
isWithdrawEnabled = None
|
1145
1164
|
isDepositEnabled = None
|
1146
1165
|
networks = {}
|
1147
|
-
chains = self.
|
1166
|
+
chains = self.safe_list(entry, 'chains', [])
|
1148
1167
|
extraChainsData = self.index_by(self.safe_value(additionalDataGrouped, id, []), 'chain')
|
1149
1168
|
rawPrecision = self.safe_string(entry, 'precision')
|
1150
1169
|
precision = self.parse_number(self.parse_precision(rawPrecision))
|
@@ -1167,7 +1186,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1167
1186
|
isDepositEnabled = chainDepositEnabled
|
1168
1187
|
else:
|
1169
1188
|
isDepositEnabled = isDepositEnabled or chainDepositEnabled
|
1170
|
-
chainExtraData = self.
|
1189
|
+
chainExtraData = self.safe_dict(extraChainsData, chainId, {})
|
1171
1190
|
networks[networkCode] = {
|
1172
1191
|
'info': chain,
|
1173
1192
|
'id': chainId,
|
@@ -1238,7 +1257,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1238
1257
|
# ]
|
1239
1258
|
# }
|
1240
1259
|
#
|
1241
|
-
data = self.
|
1260
|
+
data = self.safe_list(response, 'data', [])
|
1242
1261
|
result = []
|
1243
1262
|
for i in range(0, len(data)):
|
1244
1263
|
account = data[i]
|
@@ -1319,7 +1338,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1319
1338
|
# }
|
1320
1339
|
# }
|
1321
1340
|
#
|
1322
|
-
data = self.
|
1341
|
+
data = self.safe_dict(response, 'data')
|
1323
1342
|
return self.parse_deposit_withdraw_fee(data, currency)
|
1324
1343
|
|
1325
1344
|
def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
|
@@ -1350,7 +1369,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1350
1369
|
},
|
1351
1370
|
'networks': {},
|
1352
1371
|
}
|
1353
|
-
isWithdrawEnabled = self.
|
1372
|
+
isWithdrawEnabled = self.safe_bool(fee, 'isWithdrawEnabled')
|
1354
1373
|
if isWithdrawEnabled:
|
1355
1374
|
result['withdraw']['fee'] = self.safe_number_2(fee, 'withdrawalMinFee', 'withdrawMinFee')
|
1356
1375
|
result['withdraw']['percentage'] = False
|
@@ -1375,7 +1394,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1375
1394
|
#
|
1376
1395
|
defaultType = self.safe_string_2(self.options, methodName, 'defaultType', 'trade')
|
1377
1396
|
requestedType = self.safe_string(params, 'type', defaultType)
|
1378
|
-
accountsByType = self.
|
1397
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType')
|
1379
1398
|
type = self.safe_string(accountsByType, requestedType)
|
1380
1399
|
if type is None:
|
1381
1400
|
keys = list(accountsByType.keys())
|
@@ -1512,8 +1531,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1512
1531
|
# }
|
1513
1532
|
# }
|
1514
1533
|
#
|
1515
|
-
data = self.
|
1516
|
-
tickers = self.
|
1534
|
+
data = self.safe_dict(response, 'data', {})
|
1535
|
+
tickers = self.safe_list(data, 'ticker', [])
|
1517
1536
|
time = self.safe_integer(data, 'time')
|
1518
1537
|
result = {}
|
1519
1538
|
for i in range(0, len(tickers)):
|
@@ -1633,7 +1652,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1633
1652
|
# ]
|
1634
1653
|
# }
|
1635
1654
|
#
|
1636
|
-
data = self.
|
1655
|
+
data = self.safe_list(response, 'data', [])
|
1637
1656
|
return self.parse_ohlcvs(data, market, timeframe, since, limit)
|
1638
1657
|
|
1639
1658
|
async def create_deposit_address(self, code: str, params={}):
|
@@ -1658,7 +1677,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1658
1677
|
# {"code":"260000","msg":"Deposit address already exists."}
|
1659
1678
|
# BCH {"code":"200000","data":{"address":"bitcoincash:qza3m4nj9rx7l9r0cdadfqxts6f92shvhvr5ls4q7z","memo":""}}
|
1660
1679
|
# BTC {"code":"200000","data":{"address":"36SjucKqQpQSvsak9A7h6qzFjrVXpRNZhE","memo":""}}
|
1661
|
-
data = self.
|
1680
|
+
data = self.safe_dict(response, 'data', {})
|
1662
1681
|
return self.parse_deposit_address(data, currency)
|
1663
1682
|
|
1664
1683
|
async def fetch_deposit_address(self, code: str, params={}):
|
@@ -1744,7 +1763,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1744
1763
|
# }
|
1745
1764
|
#
|
1746
1765
|
self.options['versions']['private']['GET']['deposit-addresses'] = version
|
1747
|
-
chains = self.
|
1766
|
+
chains = self.safe_list(response, 'data', [])
|
1748
1767
|
parsed = self.parse_deposit_addresses(chains, [currency['code']], False, {
|
1749
1768
|
'currency': currency['id'],
|
1750
1769
|
})
|
@@ -1809,7 +1828,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1809
1828
|
# ]
|
1810
1829
|
# }
|
1811
1830
|
#
|
1812
|
-
data = self.
|
1831
|
+
data = self.safe_dict(response, 'data', {})
|
1813
1832
|
timestamp = self.safe_integer(data, 'time')
|
1814
1833
|
orderbook = self.parse_order_book(data, market['symbol'], timestamp, 'bids', 'asks', level - 2, level - 1)
|
1815
1834
|
orderbook['nonce'] = self.safe_integer(data, 'sequence')
|
@@ -1901,7 +1920,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1901
1920
|
# }
|
1902
1921
|
# }
|
1903
1922
|
#
|
1904
|
-
data = self.
|
1923
|
+
data = self.safe_dict(response, 'data', {})
|
1905
1924
|
return self.parse_order(data, market)
|
1906
1925
|
|
1907
1926
|
async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
|
@@ -2014,8 +2033,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2014
2033
|
# },
|
2015
2034
|
# }
|
2016
2035
|
#
|
2017
|
-
data = self.
|
2018
|
-
data = self.
|
2036
|
+
data = self.safe_dict(response, 'data', {})
|
2037
|
+
data = self.safe_list(data, 'data', [])
|
2019
2038
|
return self.parse_orders(data)
|
2020
2039
|
|
2021
2040
|
def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: float = None, params={}):
|
@@ -2112,7 +2131,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2112
2131
|
# }
|
2113
2132
|
# }
|
2114
2133
|
#
|
2115
|
-
data = self.
|
2134
|
+
data = self.safe_dict(response, 'data', {})
|
2116
2135
|
return self.parse_order(data, market)
|
2117
2136
|
|
2118
2137
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
@@ -2134,7 +2153,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2134
2153
|
await self.load_markets()
|
2135
2154
|
request = {}
|
2136
2155
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
2137
|
-
stop = self.
|
2156
|
+
stop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
2138
2157
|
hf = self.safe_bool(params, 'hf', False)
|
2139
2158
|
if hf:
|
2140
2159
|
if symbol is None:
|
@@ -2301,7 +2320,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2301
2320
|
# ]
|
2302
2321
|
# }
|
2303
2322
|
# }
|
2304
|
-
responseData = self.
|
2323
|
+
responseData = self.safe_dict(response, 'data', {})
|
2305
2324
|
orders = self.safe_value(responseData, 'items', responseData)
|
2306
2325
|
return self.parse_orders(orders, market, since, limit)
|
2307
2326
|
|
@@ -2416,7 +2435,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2416
2435
|
response = await self.privateGetHfOrdersOrderId(self.extend(request, params))
|
2417
2436
|
else:
|
2418
2437
|
response = await self.privateGetOrdersOrderId(self.extend(request, params))
|
2419
|
-
responseData = self.
|
2438
|
+
responseData = self.safe_dict(response, 'data', {})
|
2420
2439
|
if isinstance(responseData, list):
|
2421
2440
|
responseData = self.safe_value(responseData, 0)
|
2422
2441
|
return self.parse_order(responseData, market)
|
@@ -2550,7 +2569,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2550
2569
|
responseStop = self.safe_string(order, 'stop')
|
2551
2570
|
stop = responseStop is not None
|
2552
2571
|
stopTriggered = self.safe_bool(order, 'stopTriggered', False)
|
2553
|
-
isActive = self.
|
2572
|
+
isActive = self.safe_bool_2(order, 'isActive', 'active')
|
2554
2573
|
responseStatus = self.safe_string(order, 'status')
|
2555
2574
|
status = None
|
2556
2575
|
if isActive is not None:
|
@@ -2575,7 +2594,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2575
2594
|
'symbol': self.safe_symbol(marketId, market, '-'),
|
2576
2595
|
'type': self.safe_string(order, 'type'),
|
2577
2596
|
'timeInForce': self.safe_string(order, 'timeInForce'),
|
2578
|
-
'postOnly': self.
|
2597
|
+
'postOnly': self.safe_bool(order, 'postOnly'),
|
2579
2598
|
'side': self.safe_string(order, 'side'),
|
2580
2599
|
'amount': self.safe_string(order, 'size'),
|
2581
2600
|
'price': self.safe_string(order, 'price'), # price is zero for market order, omitZero is called in safeOrder2
|
@@ -2702,12 +2721,12 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2702
2721
|
# ]
|
2703
2722
|
# }
|
2704
2723
|
#
|
2705
|
-
data = self.
|
2724
|
+
data = self.safe_dict(response, 'data', {})
|
2706
2725
|
trades = None
|
2707
2726
|
if parseResponseData:
|
2708
2727
|
trades = data
|
2709
2728
|
else:
|
2710
|
-
trades = self.
|
2729
|
+
trades = self.safe_list(data, 'items', [])
|
2711
2730
|
return self.parse_trades(trades, market, since, limit)
|
2712
2731
|
|
2713
2732
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
@@ -2747,7 +2766,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2747
2766
|
# ]
|
2748
2767
|
# }
|
2749
2768
|
#
|
2750
|
-
trades = self.
|
2769
|
+
trades = self.safe_list(response, 'data', [])
|
2751
2770
|
return self.parse_trades(trades, market, since, limit)
|
2752
2771
|
|
2753
2772
|
def parse_trade(self, trade, market: Market = None) -> Trade:
|
@@ -2901,8 +2920,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2901
2920
|
# ]
|
2902
2921
|
# }
|
2903
2922
|
#
|
2904
|
-
data = self.
|
2905
|
-
first = self.
|
2923
|
+
data = self.safe_list(response, 'data', [])
|
2924
|
+
first = self.safe_dict(data, 0)
|
2906
2925
|
marketId = self.safe_string(first, 'symbol')
|
2907
2926
|
return {
|
2908
2927
|
'info': response,
|
@@ -2958,7 +2977,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2958
2977
|
# }
|
2959
2978
|
# }
|
2960
2979
|
#
|
2961
|
-
data = self.
|
2980
|
+
data = self.safe_dict(response, 'data', {})
|
2962
2981
|
return self.parse_transaction(data, currency)
|
2963
2982
|
|
2964
2983
|
def parse_transaction_status(self, status):
|
@@ -3049,7 +3068,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3049
3068
|
timestamp = timestamp * 1000
|
3050
3069
|
if updated is not None:
|
3051
3070
|
updated = updated * 1000
|
3052
|
-
internal = self.
|
3071
|
+
internal = self.safe_bool(transaction, 'isInner')
|
3053
3072
|
tag = self.safe_string(transaction, 'memo')
|
3054
3073
|
return {
|
3055
3074
|
'info': transaction,
|
@@ -3256,7 +3275,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3256
3275
|
currency = self.currency(code)
|
3257
3276
|
defaultType = self.safe_string_2(self.options, 'fetchBalance', 'defaultType', 'spot')
|
3258
3277
|
requestedType = self.safe_string(params, 'type', defaultType)
|
3259
|
-
accountsByType = self.
|
3278
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType')
|
3260
3279
|
type = self.safe_string(accountsByType, requestedType, requestedType)
|
3261
3280
|
params = self.omit(params, 'type')
|
3262
3281
|
isHf = self.safe_bool(params, 'hf', False)
|
@@ -3332,7 +3351,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3332
3351
|
# }
|
3333
3352
|
# }
|
3334
3353
|
#
|
3335
|
-
data = self.
|
3354
|
+
data = self.safe_list(response, 'data', [])
|
3336
3355
|
result = {
|
3337
3356
|
'info': response,
|
3338
3357
|
'timestamp': None,
|
@@ -3344,8 +3363,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3344
3363
|
entry = assets[i]
|
3345
3364
|
marketId = self.safe_string(entry, 'symbol')
|
3346
3365
|
symbol = self.safe_symbol(marketId, None, '_')
|
3347
|
-
base = self.
|
3348
|
-
quote = self.
|
3366
|
+
base = self.safe_dict(entry, 'baseAsset', {})
|
3367
|
+
quote = self.safe_dict(entry, 'quoteAsset', {})
|
3349
3368
|
baseCode = self.safe_currency_code(self.safe_string(base, 'currency'))
|
3350
3369
|
quoteCode = self.safe_currency_code(self.safe_string(quote, 'currency'))
|
3351
3370
|
subResult = {}
|
@@ -3353,7 +3372,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3353
3372
|
subResult[quoteCode] = self.parse_balance_helper(quote)
|
3354
3373
|
result[symbol] = self.safe_balance(subResult)
|
3355
3374
|
elif cross:
|
3356
|
-
accounts = self.
|
3375
|
+
accounts = self.safe_list(data, 'accounts', [])
|
3357
3376
|
for i in range(0, len(accounts)):
|
3358
3377
|
balance = accounts[i]
|
3359
3378
|
currencyId = self.safe_string(balance, 'currency')
|
@@ -3429,7 +3448,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3429
3448
|
# }
|
3430
3449
|
# }
|
3431
3450
|
#
|
3432
|
-
data = self.
|
3451
|
+
data = self.safe_dict(response, 'data')
|
3433
3452
|
return self.parse_transfer(data, currency)
|
3434
3453
|
else:
|
3435
3454
|
request = {
|
@@ -3456,7 +3475,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3456
3475
|
# }
|
3457
3476
|
# }
|
3458
3477
|
#
|
3459
|
-
data = self.
|
3478
|
+
data = self.safe_dict(response, 'data')
|
3460
3479
|
return self.parse_transfer(data, currency)
|
3461
3480
|
|
3462
3481
|
def parse_transfer(self, transfer, currency: Currency = None):
|
@@ -3499,7 +3518,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3499
3518
|
rawStatus = self.safe_string(transfer, 'status')
|
3500
3519
|
accountFromRaw = self.safe_string_lower(transfer, 'payAccountType')
|
3501
3520
|
accountToRaw = self.safe_string_lower(transfer, 'recAccountType')
|
3502
|
-
accountsByType = self.
|
3521
|
+
accountsByType = self.safe_dict(self.options, 'accountsByType')
|
3503
3522
|
accountFrom = self.safe_string(accountsByType, accountFromRaw, accountFromRaw)
|
3504
3523
|
accountTo = self.safe_string(accountsByType, accountToRaw, accountToRaw)
|
3505
3524
|
return {
|
@@ -3661,7 +3680,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3661
3680
|
await self.load_accounts()
|
3662
3681
|
paginate = False
|
3663
3682
|
paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
|
3664
|
-
isHf = self.
|
3683
|
+
isHf = self.safe_bool(params, 'hf')
|
3665
3684
|
params = self.omit(params, 'hf')
|
3666
3685
|
if paginate:
|
3667
3686
|
return await self.fetch_paginated_call_dynamic('fetchLedger', code, since, limit, params)
|
@@ -3735,9 +3754,9 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3735
3754
|
return self.parse_ledger(items, currency, since, limit)
|
3736
3755
|
|
3737
3756
|
def calculate_rate_limiter_cost(self, api, method, path, params, config={}):
|
3738
|
-
versions = self.
|
3739
|
-
apiVersions = self.
|
3740
|
-
methodVersions = self.
|
3757
|
+
versions = self.safe_dict(self.options, 'versions', {})
|
3758
|
+
apiVersions = self.safe_dict(versions, api, {})
|
3759
|
+
methodVersions = self.safe_dict(apiVersions, method, {})
|
3741
3760
|
defaultVersion = self.safe_string(methodVersions, path, self.options['version'])
|
3742
3761
|
version = self.safe_string(params, 'version', defaultVersion)
|
3743
3762
|
if version == 'v3' and ('v3' in config):
|
@@ -3871,8 +3890,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3871
3890
|
# }
|
3872
3891
|
# }
|
3873
3892
|
#
|
3874
|
-
data = self.
|
3875
|
-
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', [])
|
3876
3895
|
return self.parse_borrow_interests(assets, None)
|
3877
3896
|
|
3878
3897
|
def parse_borrow_interest(self, info, market: Market = None):
|
@@ -3925,7 +3944,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3925
3944
|
market = self.safe_market(marketId, market)
|
3926
3945
|
symbol = self.safe_string(market, 'symbol')
|
3927
3946
|
timestamp = self.safe_integer(info, 'createdAt')
|
3928
|
-
isolatedBase = self.
|
3947
|
+
isolatedBase = self.safe_dict(info, 'baseAsset', {})
|
3929
3948
|
amountBorrowed = None
|
3930
3949
|
interest = None
|
3931
3950
|
currencyId = None
|
@@ -3979,7 +3998,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3979
3998
|
# }
|
3980
3999
|
# }
|
3981
4000
|
#
|
3982
|
-
data = self.
|
4001
|
+
data = self.safe_dict(response, 'data', {})
|
3983
4002
|
return self.parse_margin_loan(data, currency)
|
3984
4003
|
|
3985
4004
|
async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
@@ -4016,7 +4035,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4016
4035
|
# }
|
4017
4036
|
# }
|
4018
4037
|
#
|
4019
|
-
data = self.
|
4038
|
+
data = self.safe_dict(response, 'data', {})
|
4020
4039
|
return self.parse_margin_loan(data, currency)
|
4021
4040
|
|
4022
4041
|
async def repay_cross_margin(self, code: str, amount, params={}):
|
@@ -4047,7 +4066,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4047
4066
|
# }
|
4048
4067
|
# }
|
4049
4068
|
#
|
4050
|
-
data = self.
|
4069
|
+
data = self.safe_dict(response, 'data', {})
|
4051
4070
|
return self.parse_margin_loan(data, currency)
|
4052
4071
|
|
4053
4072
|
async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
@@ -4082,7 +4101,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4082
4101
|
# }
|
4083
4102
|
# }
|
4084
4103
|
#
|
4085
|
-
data = self.
|
4104
|
+
data = self.safe_dict(response, 'data', {})
|
4086
4105
|
return self.parse_margin_loan(data, currency)
|
4087
4106
|
|
4088
4107
|
def parse_margin_loan(self, info, currency: Currency = None):
|
@@ -4132,7 +4151,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4132
4151
|
# },
|
4133
4152
|
# ]
|
4134
4153
|
#
|
4135
|
-
data = self.
|
4154
|
+
data = self.safe_list(response, 'data', [])
|
4136
4155
|
return self.parse_deposit_withdraw_fees(data, codes, 'currency')
|
4137
4156
|
|
4138
4157
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
@@ -4141,9 +4160,9 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4141
4160
|
# ↑ ↑
|
4142
4161
|
# ↑ ↑
|
4143
4162
|
#
|
4144
|
-
versions = self.
|
4145
|
-
apiVersions = self.
|
4146
|
-
methodVersions = self.
|
4163
|
+
versions = self.safe_dict(self.options, 'versions', {})
|
4164
|
+
apiVersions = self.safe_dict(versions, api, {})
|
4165
|
+
methodVersions = self.safe_dict(apiVersions, method, {})
|
4147
4166
|
defaultVersion = self.safe_string(methodVersions, path, self.options['version'])
|
4148
4167
|
version = self.safe_string(params, 'version', defaultVersion)
|
4149
4168
|
params = self.omit(params, 'version')
|
@@ -4164,7 +4183,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4164
4183
|
url = url + endpoint
|
4165
4184
|
isFuturePrivate = (api == 'futuresPrivate')
|
4166
4185
|
isPrivate = (api == 'private')
|
4167
|
-
|
4186
|
+
isBroker = (api == 'private')
|
4187
|
+
if isPrivate or isFuturePrivate or isBroker:
|
4168
4188
|
self.check_required_credentials()
|
4169
4189
|
timestamp = str(self.nonce())
|
4170
4190
|
headers = self.extend({
|
@@ -4181,7 +4201,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4181
4201
|
payload = timestamp + method + endpoint + endpart
|
4182
4202
|
signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
|
4183
4203
|
headers['KC-API-SIGN'] = signature
|
4184
|
-
partner = self.
|
4204
|
+
partner = self.safe_dict(self.options, 'partner', {})
|
4185
4205
|
partner = self.safe_value(partner, 'future', partner) if isFuturePrivate else self.safe_value(partner, 'spot', partner)
|
4186
4206
|
partnerId = self.safe_string(partner, 'id')
|
4187
4207
|
partnerSecret = self.safe_string_2(partner, 'secret', 'key')
|
@@ -4190,6 +4210,9 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4190
4210
|
partnerSignature = self.hmac(self.encode(partnerPayload), self.encode(partnerSecret), hashlib.sha256, 'base64')
|
4191
4211
|
headers['KC-API-PARTNER-SIGN'] = partnerSignature
|
4192
4212
|
headers['KC-API-PARTNER'] = partnerId
|
4213
|
+
if isBroker:
|
4214
|
+
brokerName = self.safe_string(partner, 'name')
|
4215
|
+
headers['KC-BROKER-NAME'] = brokerName
|
4193
4216
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
4194
4217
|
|
4195
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/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.2.
|
7
|
+
__version__ = '4.2.65'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -2818,6 +2818,17 @@ class Exchange(object):
|
|
2818
2818
|
return self.filter_by_symbol_since_limit(results, symbol, since, limit)
|
2819
2819
|
|
2820
2820
|
def calculate_fee(self, symbol: str, type: str, side: str, amount: float, price: float, takerOrMaker='taker', params={}):
|
2821
|
+
"""
|
2822
|
+
calculates the presumptive fee that would be charged for an order
|
2823
|
+
:param str symbol: unified market symbol
|
2824
|
+
:param str type: 'market' or 'limit'
|
2825
|
+
:param str side: 'buy' or 'sell'
|
2826
|
+
:param float amount: how much you want to trade, in units of the base currency on most exchanges, or number of contracts
|
2827
|
+
:param float price: the price for the order to be filled at, in units of the quote currency
|
2828
|
+
:param str takerOrMaker: 'taker' or 'maker'
|
2829
|
+
:param dict params:
|
2830
|
+
:returns dict: contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
|
2831
|
+
"""
|
2821
2832
|
if type == 'market' and takerOrMaker == 'maker':
|
2822
2833
|
raise ArgumentsRequired(self.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.')
|
2823
2834
|
market = self.markets[symbol]
|
@@ -3834,7 +3845,7 @@ class Exchange(object):
|
|
3834
3845
|
self.load_markets()
|
3835
3846
|
if not self.has['fetchBorrowRates']:
|
3836
3847
|
raise NotSupported(self.id + ' fetchIsolatedBorrowRate() is not supported yet')
|
3837
|
-
borrowRates = self.
|
3848
|
+
borrowRates = self.fetch_isolated_borrow_rates(params)
|
3838
3849
|
rate = self.safe_dict(borrowRates, symbol)
|
3839
3850
|
if rate is None:
|
3840
3851
|
raise ExchangeError(self.id + ' fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ' + symbol)
|
@@ -3849,7 +3860,7 @@ class Exchange(object):
|
|
3849
3860
|
params = self.omit(params, [optionName, defaultOptionName])
|
3850
3861
|
else:
|
3851
3862
|
# handle routed methods like "watchTrades > watchTradesForSymbols"(or "watchTicker > watchTickers")
|
3852
|
-
methodName, params = self.
|
3863
|
+
methodName, params = self.handle_param_string(params, 'callerMethodName', methodName)
|
3853
3864
|
# check if exchange has properties for self method
|
3854
3865
|
exchangeWideMethodOptions = self.safe_value(self.options, methodName)
|
3855
3866
|
if exchangeWideMethodOptions is not None:
|