ccxt 4.3.95__py2.py3-none-any.whl → 4.3.97__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +1 -5
- ccxt/async_support/__init__.py +1 -5
- ccxt/async_support/base/exchange.py +1 -4
- ccxt/async_support/binance.py +2 -0
- ccxt/async_support/bingx.py +1 -0
- ccxt/async_support/blofin.py +0 -1
- ccxt/async_support/bybit.py +7 -2
- ccxt/async_support/coinex.py +15 -3
- ccxt/async_support/hyperliquid.py +243 -29
- ccxt/async_support/kucoin.py +12 -12
- ccxt/async_support/mexc.py +6 -0
- ccxt/async_support/okx.py +0 -1
- ccxt/async_support/p2b.py +0 -1
- ccxt/async_support/tradeogre.py +0 -1
- ccxt/base/exchange.py +1 -5
- ccxt/binance.py +2 -0
- ccxt/bingx.py +1 -0
- ccxt/blofin.py +0 -1
- ccxt/bybit.py +7 -2
- ccxt/coinex.py +15 -3
- ccxt/hyperliquid.py +243 -29
- ccxt/kucoin.py +2 -2
- ccxt/mexc.py +6 -0
- ccxt/okx.py +0 -1
- ccxt/p2b.py +0 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +90 -2
- ccxt/pro/bybit.py +58 -4
- ccxt/pro/cryptocom.py +195 -0
- ccxt/pro/gate.py +155 -0
- ccxt/pro/kucoin.py +107 -0
- ccxt/pro/okx.py +238 -31
- ccxt/tradeogre.py +0 -1
- {ccxt-4.3.95.dist-info → ccxt-4.3.97.dist-info}/METADATA +5 -5
- {ccxt-4.3.95.dist-info → ccxt-4.3.97.dist-info}/RECORD +38 -40
- ccxt/abstract/bitbay.py +0 -53
- ccxt/abstract/hitbtc3.py +0 -115
- {ccxt-4.3.95.dist-info → ccxt-4.3.97.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.95.dist-info → ccxt-4.3.97.dist-info}/WHEEL +0 -0
- {ccxt-4.3.95.dist-info → ccxt-4.3.97.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
# ----------------------------------------------------------------------------
|
24
24
|
|
25
|
-
__version__ = '4.3.
|
25
|
+
__version__ = '4.3.97'
|
26
26
|
|
27
27
|
# ----------------------------------------------------------------------------
|
28
28
|
|
@@ -95,7 +95,6 @@ from ccxt.binanceusdm import binanceusdm # noqa: F4
|
|
95
95
|
from ccxt.bingx import bingx # noqa: F401
|
96
96
|
from ccxt.bit2c import bit2c # noqa: F401
|
97
97
|
from ccxt.bitbank import bitbank # noqa: F401
|
98
|
-
from ccxt.bitbay import bitbay # noqa: F401
|
99
98
|
from ccxt.bitbns import bitbns # noqa: F401
|
100
99
|
from ccxt.bitcoincom import bitcoincom # noqa: F401
|
101
100
|
from ccxt.bitfinex import bitfinex # noqa: F401
|
@@ -145,7 +144,6 @@ from ccxt.gateio import gateio # noqa: F4
|
|
145
144
|
from ccxt.gemini import gemini # noqa: F401
|
146
145
|
from ccxt.hashkey import hashkey # noqa: F401
|
147
146
|
from ccxt.hitbtc import hitbtc # noqa: F401
|
148
|
-
from ccxt.hitbtc3 import hitbtc3 # noqa: F401
|
149
147
|
from ccxt.hollaex import hollaex # noqa: F401
|
150
148
|
from ccxt.htx import htx # noqa: F401
|
151
149
|
from ccxt.huobi import huobi # noqa: F401
|
@@ -207,7 +205,6 @@ exchanges = [
|
|
207
205
|
'bingx',
|
208
206
|
'bit2c',
|
209
207
|
'bitbank',
|
210
|
-
'bitbay',
|
211
208
|
'bitbns',
|
212
209
|
'bitcoincom',
|
213
210
|
'bitfinex',
|
@@ -257,7 +254,6 @@ exchanges = [
|
|
257
254
|
'gemini',
|
258
255
|
'hashkey',
|
259
256
|
'hitbtc',
|
260
|
-
'hitbtc3',
|
261
257
|
'hollaex',
|
262
258
|
'htx',
|
263
259
|
'huobi',
|
ccxt/async_support/__init__.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.3.
|
7
|
+
__version__ = '4.3.97'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -75,7 +75,6 @@ from ccxt.async_support.binanceusdm import binanceusdm
|
|
75
75
|
from ccxt.async_support.bingx import bingx # noqa: F401
|
76
76
|
from ccxt.async_support.bit2c import bit2c # noqa: F401
|
77
77
|
from ccxt.async_support.bitbank import bitbank # noqa: F401
|
78
|
-
from ccxt.async_support.bitbay import bitbay # noqa: F401
|
79
78
|
from ccxt.async_support.bitbns import bitbns # noqa: F401
|
80
79
|
from ccxt.async_support.bitcoincom import bitcoincom # noqa: F401
|
81
80
|
from ccxt.async_support.bitfinex import bitfinex # noqa: F401
|
@@ -125,7 +124,6 @@ from ccxt.async_support.gateio import gateio
|
|
125
124
|
from ccxt.async_support.gemini import gemini # noqa: F401
|
126
125
|
from ccxt.async_support.hashkey import hashkey # noqa: F401
|
127
126
|
from ccxt.async_support.hitbtc import hitbtc # noqa: F401
|
128
|
-
from ccxt.async_support.hitbtc3 import hitbtc3 # noqa: F401
|
129
127
|
from ccxt.async_support.hollaex import hollaex # noqa: F401
|
130
128
|
from ccxt.async_support.htx import htx # noqa: F401
|
131
129
|
from ccxt.async_support.huobi import huobi # noqa: F401
|
@@ -187,7 +185,6 @@ exchanges = [
|
|
187
185
|
'bingx',
|
188
186
|
'bit2c',
|
189
187
|
'bitbank',
|
190
|
-
'bitbay',
|
191
188
|
'bitbns',
|
192
189
|
'bitcoincom',
|
193
190
|
'bitfinex',
|
@@ -237,7 +234,6 @@ exchanges = [
|
|
237
234
|
'gemini',
|
238
235
|
'hashkey',
|
239
236
|
'hitbtc',
|
240
|
-
'hitbtc3',
|
241
237
|
'hollaex',
|
242
238
|
'htx',
|
243
239
|
'huobi',
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.3.
|
5
|
+
__version__ = '4.3.97'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -875,9 +875,6 @@ class Exchange(BaseExchange):
|
|
875
875
|
await self.cancel_order_ws(id, symbol)
|
876
876
|
return await self.create_order_ws(symbol, type, side, amount, price, params)
|
877
877
|
|
878
|
-
async def fetch_permissions(self, params={}):
|
879
|
-
raise NotSupported(self.id + ' fetchPermissions() is not supported yet')
|
880
|
-
|
881
878
|
async def fetch_position(self, symbol: str, params={}):
|
882
879
|
raise NotSupported(self.id + ' fetchPosition() is not supported yet')
|
883
880
|
|
ccxt/async_support/binance.py
CHANGED
@@ -4121,6 +4121,8 @@ class binance(Exchange, ImplicitAPI):
|
|
4121
4121
|
price = self.safe_string(params, 'price')
|
4122
4122
|
until = self.safe_integer(params, 'until')
|
4123
4123
|
params = self.omit(params, ['price', 'until'])
|
4124
|
+
if since is not None and until is not None and limit is None:
|
4125
|
+
limit = maxLimit
|
4124
4126
|
limit = defaultLimit if (limit is None) else min(limit, maxLimit)
|
4125
4127
|
request: dict = {
|
4126
4128
|
'interval': self.safe_string(self.timeframes, timeframe, timeframe),
|
ccxt/async_support/bingx.py
CHANGED
ccxt/async_support/blofin.py
CHANGED
ccxt/async_support/bybit.py
CHANGED
@@ -5503,11 +5503,16 @@ class bybit(Exchange, ImplicitAPI):
|
|
5503
5503
|
:param str code: unified currency code, default is None
|
5504
5504
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
5505
5505
|
:param int [limit]: max number of ledger entrys to return, default is None
|
5506
|
-
:param
|
5506
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
5507
5507
|
:param str [params.subType]: if inverse will use v5/account/contract-transaction-log
|
5508
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5508
5509
|
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
5509
5510
|
"""
|
5510
5511
|
await self.load_markets()
|
5512
|
+
paginate = False
|
5513
|
+
paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
|
5514
|
+
if paginate:
|
5515
|
+
return await self.fetch_paginated_call_cursor('fetchLedger', code, since, limit, params, 'nextPageCursor', 'cursor', None, 50)
|
5511
5516
|
request: dict = {
|
5512
5517
|
# 'coin': currency['id'],
|
5513
5518
|
# 'currency': currency['id'], # alias
|
@@ -5551,7 +5556,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
5551
5556
|
else:
|
5552
5557
|
response = await self.privateGetV5AccountTransactionLog(self.extend(request, params))
|
5553
5558
|
else:
|
5554
|
-
response = await self.
|
5559
|
+
response = await self.privateGetV5AccountContractTransactionLog(self.extend(request, params))
|
5555
5560
|
#
|
5556
5561
|
# {
|
5557
5562
|
# "ret_code": 0,
|
ccxt/async_support/coinex.py
CHANGED
@@ -1199,7 +1199,10 @@ class coinex(Exchange, ImplicitAPI):
|
|
1199
1199
|
# "side": "buy",
|
1200
1200
|
# "order_id": 136915589622,
|
1201
1201
|
# "price": "64376",
|
1202
|
-
# "amount": "0.0001"
|
1202
|
+
# "amount": "0.0001",
|
1203
|
+
# "role": "taker",
|
1204
|
+
# "fee": "0.0299",
|
1205
|
+
# "fee_ccy": "USDT"
|
1203
1206
|
# }
|
1204
1207
|
#
|
1205
1208
|
timestamp = self.safe_integer(trade, 'created_at')
|
@@ -1208,6 +1211,15 @@ class coinex(Exchange, ImplicitAPI):
|
|
1208
1211
|
defaultType = market['type']
|
1209
1212
|
marketId = self.safe_string(trade, 'market')
|
1210
1213
|
market = self.safe_market(marketId, market, None, defaultType)
|
1214
|
+
feeCostString = self.safe_string(trade, 'fee')
|
1215
|
+
fee = None
|
1216
|
+
if feeCostString is not None:
|
1217
|
+
feeCurrencyId = self.safe_string(trade, 'fee_ccy')
|
1218
|
+
feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
|
1219
|
+
fee = {
|
1220
|
+
'cost': feeCostString,
|
1221
|
+
'currency': feeCurrencyCode,
|
1222
|
+
}
|
1211
1223
|
return self.safe_trade({
|
1212
1224
|
'info': trade,
|
1213
1225
|
'timestamp': timestamp,
|
@@ -1217,11 +1229,11 @@ class coinex(Exchange, ImplicitAPI):
|
|
1217
1229
|
'order': self.safe_string(trade, 'order_id'),
|
1218
1230
|
'type': None,
|
1219
1231
|
'side': self.safe_string(trade, 'side'),
|
1220
|
-
'takerOrMaker':
|
1232
|
+
'takerOrMaker': self.safe_string(trade, 'role'),
|
1221
1233
|
'price': self.safe_string(trade, 'price'),
|
1222
1234
|
'amount': self.safe_string(trade, 'amount'),
|
1223
1235
|
'cost': self.safe_string(trade, 'deal_money'),
|
1224
|
-
'fee':
|
1236
|
+
'fee': fee,
|
1225
1237
|
}, market)
|
1226
1238
|
|
1227
1239
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
@@ -70,7 +70,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
70
70
|
'fetchCurrencies': True,
|
71
71
|
'fetchDepositAddress': False,
|
72
72
|
'fetchDepositAddresses': False,
|
73
|
-
'fetchDeposits':
|
73
|
+
'fetchDeposits': True,
|
74
74
|
'fetchDepositWithdrawFee': 'emulated',
|
75
75
|
'fetchDepositWithdrawFees': False,
|
76
76
|
'fetchFundingHistory': False,
|
@@ -80,7 +80,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
80
80
|
'fetchIndexOHLCV': False,
|
81
81
|
'fetchIsolatedBorrowRate': False,
|
82
82
|
'fetchIsolatedBorrowRates': False,
|
83
|
-
'fetchLedger':
|
83
|
+
'fetchLedger': True,
|
84
84
|
'fetchLeverage': False,
|
85
85
|
'fetchLeverageTiers': False,
|
86
86
|
'fetchLiquidations': False,
|
@@ -112,7 +112,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
112
112
|
'fetchTransfer': False,
|
113
113
|
'fetchTransfers': False,
|
114
114
|
'fetchWithdrawal': False,
|
115
|
-
'fetchWithdrawals':
|
115
|
+
'fetchWithdrawals': True,
|
116
116
|
'reduceMargin': True,
|
117
117
|
'repayCrossMargin': False,
|
118
118
|
'repayIsolatedMargin': False,
|
@@ -1883,10 +1883,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1883
1883
|
coin = self.safe_string(entry, 'coin')
|
1884
1884
|
marketId = None
|
1885
1885
|
if coin is not None:
|
1886
|
-
|
1887
|
-
marketId = coin
|
1888
|
-
else:
|
1889
|
-
marketId = coin + '/USDC:USDC'
|
1886
|
+
marketId = self.coin_to_market_id(coin)
|
1890
1887
|
if self.safe_string(entry, 'id') is None:
|
1891
1888
|
market = self.safe_market(marketId, None)
|
1892
1889
|
else:
|
@@ -2014,7 +2011,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2014
2011
|
price = self.safe_string(trade, 'px')
|
2015
2012
|
amount = self.safe_string(trade, 'sz')
|
2016
2013
|
coin = self.safe_string(trade, 'coin')
|
2017
|
-
marketId = coin
|
2014
|
+
marketId = self.coin_to_market_id(coin)
|
2018
2015
|
market = self.safe_market(marketId, None)
|
2019
2016
|
symbol = market['symbol']
|
2020
2017
|
id = self.safe_string(trade, 'tid')
|
@@ -2148,7 +2145,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2148
2145
|
#
|
2149
2146
|
entry = self.safe_dict(position, 'position', {})
|
2150
2147
|
coin = self.safe_string(entry, 'coin')
|
2151
|
-
marketId = coin
|
2148
|
+
marketId = self.coin_to_market_id(coin)
|
2152
2149
|
market = self.safe_market(marketId, None)
|
2153
2150
|
symbol = market['symbol']
|
2154
2151
|
leverage = self.safe_dict(entry, 'leverage', {})
|
@@ -2434,11 +2431,13 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2434
2431
|
"""
|
2435
2432
|
make a withdrawal(only support USDC)
|
2436
2433
|
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request
|
2434
|
+
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault
|
2437
2435
|
:param str code: unified currency code
|
2438
2436
|
:param float amount: the amount to withdraw
|
2439
2437
|
:param str address: the address to withdraw to
|
2440
2438
|
:param str tag:
|
2441
2439
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2440
|
+
:param str [params.vaultAddress]: vault address withdraw from
|
2442
2441
|
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2443
2442
|
"""
|
2444
2443
|
self.check_required_credentials()
|
@@ -2448,24 +2447,38 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2448
2447
|
code = code.upper()
|
2449
2448
|
if code != 'USDC':
|
2450
2449
|
raise NotSupported(self.id + 'withdraw() only support USDC')
|
2451
|
-
|
2450
|
+
vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
|
2451
|
+
params = self.omit(params, 'vaultAddress')
|
2452
2452
|
nonce = self.milliseconds()
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2453
|
+
action: dict = {}
|
2454
|
+
sig = None
|
2455
|
+
if vaultAddress is not None:
|
2456
|
+
action = {
|
2457
|
+
'type': 'vaultTransfer',
|
2458
|
+
'vaultAddress': '0x' + vaultAddress,
|
2459
|
+
'isDeposit': False,
|
2460
|
+
'usd': amount,
|
2461
|
+
}
|
2462
|
+
sig = self.sign_l1_action(action, nonce)
|
2463
|
+
else:
|
2464
|
+
isSandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
2465
|
+
payload: dict = {
|
2466
|
+
'hyperliquidChain': 'Testnet' if isSandboxMode else 'Mainnet',
|
2467
|
+
'destination': address,
|
2468
|
+
'amount': str(amount),
|
2469
|
+
'time': nonce,
|
2470
|
+
}
|
2471
|
+
sig = self.build_withdraw_sig(payload)
|
2472
|
+
action = {
|
2462
2473
|
'hyperliquidChain': payload['hyperliquidChain'],
|
2463
2474
|
'signatureChainId': '0x66eee', # check self out
|
2464
2475
|
'destination': address,
|
2465
2476
|
'amount': str(amount),
|
2466
2477
|
'time': nonce,
|
2467
2478
|
'type': 'withdraw3',
|
2468
|
-
}
|
2479
|
+
}
|
2480
|
+
request: dict = {
|
2481
|
+
'action': action,
|
2469
2482
|
'nonce': nonce,
|
2470
2483
|
'signature': sig,
|
2471
2484
|
}
|
@@ -2476,27 +2489,51 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2476
2489
|
#
|
2477
2490
|
# {status: 'ok', response: {type: 'default'}}
|
2478
2491
|
#
|
2492
|
+
# fetchDeposits / fetchWithdrawals
|
2493
|
+
# {
|
2494
|
+
# "time":1724762307531,
|
2495
|
+
# "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
|
2496
|
+
# "delta":{
|
2497
|
+
# "type":"accountClassTransfer",
|
2498
|
+
# "usdc":"50.0",
|
2499
|
+
# "toPerp":false
|
2500
|
+
# }
|
2501
|
+
# }
|
2502
|
+
#
|
2503
|
+
timestamp = self.safe_integer(transaction, 'time')
|
2504
|
+
delta = self.safe_dict(transaction, 'delta', {})
|
2505
|
+
fee = None
|
2506
|
+
feeCost = self.safe_integer(delta, 'fee')
|
2507
|
+
if feeCost is not None:
|
2508
|
+
fee = {
|
2509
|
+
'currency': 'USDC',
|
2510
|
+
'cost': feeCost,
|
2511
|
+
}
|
2512
|
+
internal = None
|
2513
|
+
type = self.safe_string(delta, 'type')
|
2514
|
+
if type is not None:
|
2515
|
+
internal = (type == 'internalTransfer')
|
2479
2516
|
return {
|
2480
2517
|
'info': transaction,
|
2481
2518
|
'id': None,
|
2482
|
-
'txid':
|
2483
|
-
'timestamp':
|
2484
|
-
'datetime':
|
2519
|
+
'txid': self.safe_string(transaction, 'hash'),
|
2520
|
+
'timestamp': timestamp,
|
2521
|
+
'datetime': self.iso8601(timestamp),
|
2485
2522
|
'network': None,
|
2486
2523
|
'address': None,
|
2487
|
-
'addressTo':
|
2488
|
-
'addressFrom':
|
2524
|
+
'addressTo': self.safe_string(delta, 'destination'),
|
2525
|
+
'addressFrom': self.safe_string(delta, 'user'),
|
2489
2526
|
'tag': None,
|
2490
2527
|
'tagTo': None,
|
2491
2528
|
'tagFrom': None,
|
2492
2529
|
'type': None,
|
2493
|
-
'amount':
|
2530
|
+
'amount': self.safe_integer(delta, 'usdc'),
|
2494
2531
|
'currency': None,
|
2495
2532
|
'status': self.safe_string(transaction, 'status'),
|
2496
2533
|
'updated': None,
|
2497
2534
|
'comment': None,
|
2498
|
-
'internal':
|
2499
|
-
'fee':
|
2535
|
+
'internal': internal,
|
2536
|
+
'fee': fee,
|
2500
2537
|
}
|
2501
2538
|
|
2502
2539
|
async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
@@ -2603,6 +2640,183 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2603
2640
|
'tierBased': None,
|
2604
2641
|
}
|
2605
2642
|
|
2643
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2644
|
+
"""
|
2645
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
2646
|
+
:param str code: unified currency code
|
2647
|
+
:param int [since]: timestamp in ms of the earliest ledger entry
|
2648
|
+
:param int [limit]: max number of ledger entrys to return
|
2649
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2650
|
+
:param int [params.until]: timestamp in ms of the latest ledger entry
|
2651
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
|
2652
|
+
"""
|
2653
|
+
await self.load_markets()
|
2654
|
+
userAddress = None
|
2655
|
+
userAddress, params = self.handle_public_address('fetchLedger', params)
|
2656
|
+
request: dict = {
|
2657
|
+
'type': 'userNonFundingLedgerUpdates',
|
2658
|
+
'user': userAddress,
|
2659
|
+
}
|
2660
|
+
if since is not None:
|
2661
|
+
request['startTime'] = since
|
2662
|
+
until = self.safe_integer(params, 'until')
|
2663
|
+
if until is not None:
|
2664
|
+
request['endTime'] = until
|
2665
|
+
params = self.omit(params, ['until'])
|
2666
|
+
response = await self.publicPostInfo(self.extend(request, params))
|
2667
|
+
#
|
2668
|
+
# [
|
2669
|
+
# {
|
2670
|
+
# "time":1724762307531,
|
2671
|
+
# "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
|
2672
|
+
# "delta":{
|
2673
|
+
# "type":"accountClassTransfer",
|
2674
|
+
# "usdc":"50.0",
|
2675
|
+
# "toPerp":false
|
2676
|
+
# }
|
2677
|
+
# }
|
2678
|
+
# ]
|
2679
|
+
#
|
2680
|
+
return self.parse_ledger(response, None, since, limit)
|
2681
|
+
|
2682
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
2683
|
+
#
|
2684
|
+
# {
|
2685
|
+
# "time":1724762307531,
|
2686
|
+
# "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
|
2687
|
+
# "delta":{
|
2688
|
+
# "type":"accountClassTransfer",
|
2689
|
+
# "usdc":"50.0",
|
2690
|
+
# "toPerp":false
|
2691
|
+
# }
|
2692
|
+
# }
|
2693
|
+
#
|
2694
|
+
timestamp = self.safe_integer(item, 'time')
|
2695
|
+
delta = self.safe_dict(item, 'delta', {})
|
2696
|
+
fee = None
|
2697
|
+
feeCost = self.safe_integer(delta, 'fee')
|
2698
|
+
if feeCost is not None:
|
2699
|
+
fee = {
|
2700
|
+
'currency': 'USDC',
|
2701
|
+
'cost': feeCost,
|
2702
|
+
}
|
2703
|
+
type = self.safe_string(delta, 'type')
|
2704
|
+
amount = self.safe_string(delta, 'usdc')
|
2705
|
+
return {
|
2706
|
+
'id': self.safe_string(item, 'hash'),
|
2707
|
+
'direction': None,
|
2708
|
+
'account': None,
|
2709
|
+
'referenceAccount': self.safe_string(delta, 'user'),
|
2710
|
+
'referenceId': self.safe_string(item, 'hash'),
|
2711
|
+
'type': self.parse_ledger_entry_type(type),
|
2712
|
+
'currency': None,
|
2713
|
+
'amount': self.parse_number(amount),
|
2714
|
+
'timestamp': timestamp,
|
2715
|
+
'datetime': self.iso8601(timestamp),
|
2716
|
+
'before': None,
|
2717
|
+
'after': None,
|
2718
|
+
'status': None,
|
2719
|
+
'fee': fee,
|
2720
|
+
'info': item,
|
2721
|
+
}
|
2722
|
+
|
2723
|
+
def parse_ledger_entry_type(self, type):
|
2724
|
+
ledgerType: dict = {
|
2725
|
+
'internalTransfer': 'transfer',
|
2726
|
+
'accountClassTransfer': 'transfer',
|
2727
|
+
}
|
2728
|
+
return self.safe_string(ledgerType, type, type)
|
2729
|
+
|
2730
|
+
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2731
|
+
"""
|
2732
|
+
fetch all deposits made to an account
|
2733
|
+
:param str code: unified currency code
|
2734
|
+
:param int [since]: the earliest time in ms to fetch deposits for
|
2735
|
+
:param int [limit]: the maximum number of deposits structures to retrieve
|
2736
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2737
|
+
:param int [params.until]: the latest time in ms to fetch withdrawals for
|
2738
|
+
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2739
|
+
"""
|
2740
|
+
await self.load_markets()
|
2741
|
+
userAddress = None
|
2742
|
+
userAddress, params = self.handle_public_address('fetchDepositsWithdrawals', params)
|
2743
|
+
request: dict = {
|
2744
|
+
'type': 'userNonFundingLedgerUpdates',
|
2745
|
+
'user': userAddress,
|
2746
|
+
}
|
2747
|
+
if since is not None:
|
2748
|
+
request['startTime'] = since
|
2749
|
+
until = self.safe_integer(params, 'until')
|
2750
|
+
if until is not None:
|
2751
|
+
request['endTime'] = until
|
2752
|
+
params = self.omit(params, ['until'])
|
2753
|
+
response = await self.publicPostInfo(self.extend(request, params))
|
2754
|
+
#
|
2755
|
+
# [
|
2756
|
+
# {
|
2757
|
+
# "time":1724762307531,
|
2758
|
+
# "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
|
2759
|
+
# "delta":{
|
2760
|
+
# "type":"accountClassTransfer",
|
2761
|
+
# "usdc":"50.0",
|
2762
|
+
# "toPerp":false
|
2763
|
+
# }
|
2764
|
+
# }
|
2765
|
+
# ]
|
2766
|
+
#
|
2767
|
+
records = self.extract_type_from_delta(response)
|
2768
|
+
deposits = self.filter_by_array(records, 'type', ['deposit'], False)
|
2769
|
+
return self.parse_transactions(deposits, None, since, limit)
|
2770
|
+
|
2771
|
+
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2772
|
+
"""
|
2773
|
+
fetch all withdrawals made from an account
|
2774
|
+
:param str code: unified currency code
|
2775
|
+
:param int [since]: the earliest time in ms to fetch withdrawals for
|
2776
|
+
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
2777
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2778
|
+
:param int [params.until]: the latest time in ms to fetch withdrawals for
|
2779
|
+
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2780
|
+
"""
|
2781
|
+
await self.load_markets()
|
2782
|
+
userAddress = None
|
2783
|
+
userAddress, params = self.handle_public_address('fetchDepositsWithdrawals', params)
|
2784
|
+
request: dict = {
|
2785
|
+
'type': 'userNonFundingLedgerUpdates',
|
2786
|
+
'user': userAddress,
|
2787
|
+
}
|
2788
|
+
if since is not None:
|
2789
|
+
request['startTime'] = since
|
2790
|
+
until = self.safe_integer(params, 'until')
|
2791
|
+
if until is not None:
|
2792
|
+
request['endTime'] = until
|
2793
|
+
params = self.omit(params, ['until'])
|
2794
|
+
response = await self.publicPostInfo(self.extend(request, params))
|
2795
|
+
#
|
2796
|
+
# [
|
2797
|
+
# {
|
2798
|
+
# "time":1724762307531,
|
2799
|
+
# "hash":"0x620a234a7e0eb7930575040f59482a01050058b0802163b4767bfd9033e77781",
|
2800
|
+
# "delta":{
|
2801
|
+
# "type":"accountClassTransfer",
|
2802
|
+
# "usdc":"50.0",
|
2803
|
+
# "toPerp":false
|
2804
|
+
# }
|
2805
|
+
# }
|
2806
|
+
# ]
|
2807
|
+
#
|
2808
|
+
records = self.extract_type_from_delta(response)
|
2809
|
+
withdrawals = self.filter_by_array(records, 'type', ['withdraw'], False)
|
2810
|
+
return self.parse_transactions(withdrawals, None, since, limit)
|
2811
|
+
|
2812
|
+
def extract_type_from_delta(self, data=[]):
|
2813
|
+
records = []
|
2814
|
+
for i in range(0, len(data)):
|
2815
|
+
record = data[i]
|
2816
|
+
record['type'] = record['delta']['type']
|
2817
|
+
records.append(record)
|
2818
|
+
return records
|
2819
|
+
|
2606
2820
|
def format_vault_address(self, address: Str = None):
|
2607
2821
|
if address is None:
|
2608
2822
|
return None
|
@@ -2622,7 +2836,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2622
2836
|
raise ArgumentsRequired(self.id + ' ' + methodName + '() requires a user parameter inside \'params\' or the wallet address set')
|
2623
2837
|
|
2624
2838
|
def coin_to_market_id(self, coin: Str):
|
2625
|
-
if coin.find('/') > -1:
|
2839
|
+
if coin.find('/') > -1 or coin.find('@') > -1:
|
2626
2840
|
return coin # spot
|
2627
2841
|
return coin + '/USDC:USDC'
|
2628
2842
|
|
ccxt/async_support/kucoin.py
CHANGED
@@ -645,6 +645,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
645
645
|
'KALT': 'ALT', # ALTLAYER
|
646
646
|
},
|
647
647
|
'options': {
|
648
|
+
'hf': False,
|
648
649
|
'version': 'v1',
|
649
650
|
'symbolSeparator': '-',
|
650
651
|
'fetchMyTradesMethod': 'private_get_fills',
|
@@ -1228,9 +1229,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1228
1229
|
status: Int = self.safe_integer(data, 'status')
|
1229
1230
|
self.options['hfMigrated'] = (status == 2)
|
1230
1231
|
|
1231
|
-
|
1232
|
-
|
1233
|
-
migrated: Bool = self.safe_bool(self.options, 'hfMigrated')
|
1232
|
+
def handle_hf_and_params(self, params={}):
|
1233
|
+
migrated: Bool = self.safe_bool_2(self.options, 'hfMigrated', 'hf', False)
|
1234
1234
|
loadedHf: Bool = None
|
1235
1235
|
if migrated is not None:
|
1236
1236
|
if migrated:
|
@@ -2068,7 +2068,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2068
2068
|
testOrder = self.safe_bool(params, 'test', False)
|
2069
2069
|
params = self.omit(params, 'test')
|
2070
2070
|
hf = None
|
2071
|
-
hf, params =
|
2071
|
+
hf, params = self.handle_hf_and_params(params)
|
2072
2072
|
useSync = False
|
2073
2073
|
useSync, params = self.handle_option_and_params(params, 'createOrder', 'sync', False)
|
2074
2074
|
triggerPrice, stopLossPrice, takeProfitPrice = self.handle_trigger_prices(params)
|
@@ -2184,7 +2184,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2184
2184
|
'orderList': ordersRequests,
|
2185
2185
|
}
|
2186
2186
|
hf = None
|
2187
|
-
hf, params =
|
2187
|
+
hf, params = self.handle_hf_and_params(params)
|
2188
2188
|
useSync = False
|
2189
2189
|
useSync, params = self.handle_option_and_params(params, 'createOrders', 'sync', False)
|
2190
2190
|
response = None
|
@@ -2356,7 +2356,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2356
2356
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
2357
2357
|
stop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
2358
2358
|
hf = None
|
2359
|
-
hf, params =
|
2359
|
+
hf, params = self.handle_hf_and_params(params)
|
2360
2360
|
useSync = False
|
2361
2361
|
useSync, params = self.handle_option_and_params(params, 'cancelOrder', 'sync', False)
|
2362
2362
|
if hf or useSync:
|
@@ -2464,7 +2464,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2464
2464
|
request: dict = {}
|
2465
2465
|
stop = self.safe_bool(params, 'stop', False)
|
2466
2466
|
hf = None
|
2467
|
-
hf, params =
|
2467
|
+
hf, params = self.handle_hf_and_params(params)
|
2468
2468
|
params = self.omit(params, 'stop')
|
2469
2469
|
marginMode, query = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
2470
2470
|
if symbol is not None:
|
@@ -2513,7 +2513,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2513
2513
|
until = self.safe_integer(params, 'until')
|
2514
2514
|
stop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
2515
2515
|
hf = None
|
2516
|
-
hf, params =
|
2516
|
+
hf, params = self.handle_hf_and_params(params)
|
2517
2517
|
if hf and (symbol is None):
|
2518
2518
|
raise ArgumentsRequired(self.id + ' fetchOrdersByStatus() requires a symbol parameter for hf orders')
|
2519
2519
|
params = self.omit(params, ['stop', 'trigger', 'till', 'until'])
|
@@ -2675,7 +2675,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2675
2675
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
2676
2676
|
stop = self.safe_bool_2(params, 'stop', 'trigger', False)
|
2677
2677
|
hf = None
|
2678
|
-
hf, params =
|
2678
|
+
hf, params = self.handle_hf_and_params(params)
|
2679
2679
|
market = None
|
2680
2680
|
if symbol is not None:
|
2681
2681
|
market = self.market(symbol)
|
@@ -2926,7 +2926,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
2926
2926
|
return await self.fetch_paginated_call_dynamic('fetchMyTrades', symbol, since, limit, params)
|
2927
2927
|
request: dict = {}
|
2928
2928
|
hf = None
|
2929
|
-
hf, params =
|
2929
|
+
hf, params = self.handle_hf_and_params(params)
|
2930
2930
|
if hf and symbol is None:
|
2931
2931
|
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol parameter for hf orders')
|
2932
2932
|
market = None
|
@@ -3601,7 +3601,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
3601
3601
|
type = self.safe_string(accountsByType, requestedType, requestedType)
|
3602
3602
|
params = self.omit(params, 'type')
|
3603
3603
|
hf = None
|
3604
|
-
hf, params =
|
3604
|
+
hf, params = self.handle_hf_and_params(params)
|
3605
3605
|
if hf:
|
3606
3606
|
type = 'trade_hf'
|
3607
3607
|
marginMode, query = self.handle_margin_mode_and_params('fetchBalance', params)
|
@@ -4030,7 +4030,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4030
4030
|
paginate = False
|
4031
4031
|
paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
|
4032
4032
|
hf = None
|
4033
|
-
hf, params =
|
4033
|
+
hf, params = self.handle_hf_and_params(params)
|
4034
4034
|
if paginate:
|
4035
4035
|
return await self.fetch_paginated_call_dynamic('fetchLedger', code, since, limit, params)
|
4036
4036
|
request: dict = {
|