ccxt 4.3.29__py2.py3-none-any.whl → 4.3.31__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 -1
- ccxt/abstract/binance.py +2 -0
- ccxt/abstract/binancecoinm.py +2 -0
- ccxt/abstract/binanceus.py +2 -0
- ccxt/abstract/binanceusdm.py +2 -0
- ccxt/ace.py +14 -14
- ccxt/alpaca.py +16 -16
- ccxt/ascendex.py +46 -46
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ace.py +14 -14
- ccxt/async_support/alpaca.py +16 -16
- ccxt/async_support/ascendex.py +46 -46
- ccxt/async_support/base/exchange.py +23 -23
- ccxt/async_support/base/ws/aiohttp_client.py +1 -0
- ccxt/async_support/base/ws/future.py +27 -29
- ccxt/async_support/bigone.py +32 -32
- ccxt/async_support/binance.py +105 -96
- ccxt/async_support/bingx.py +22 -22
- ccxt/async_support/bit2c.py +13 -13
- ccxt/async_support/bitbank.py +19 -19
- ccxt/async_support/bitbns.py +17 -17
- ccxt/async_support/bitfinex.py +24 -24
- ccxt/async_support/bitfinex2.py +142 -109
- ccxt/async_support/bitflyer.py +23 -23
- ccxt/async_support/bitget.py +76 -76
- ccxt/async_support/bithumb.py +20 -20
- ccxt/async_support/bitmart.py +55 -55
- ccxt/async_support/bitmex.py +41 -41
- ccxt/async_support/bitopro.py +30 -30
- ccxt/async_support/bitrue.py +37 -37
- ccxt/async_support/bitso.py +30 -30
- ccxt/async_support/bitstamp.py +31 -31
- ccxt/async_support/bitteam.py +26 -26
- ccxt/async_support/bitvavo.py +27 -27
- ccxt/async_support/bl3p.py +8 -8
- ccxt/async_support/blockchaincom.py +24 -24
- ccxt/async_support/blofin.py +37 -37
- ccxt/async_support/btcalpha.py +19 -19
- ccxt/async_support/btcbox.py +11 -11
- ccxt/async_support/btcmarkets.py +22 -22
- ccxt/async_support/btcturk.py +13 -13
- ccxt/async_support/bybit.py +96 -96
- ccxt/async_support/cex.py +21 -21
- ccxt/async_support/coinbase.py +53 -53
- ccxt/async_support/coinbaseexchange.py +29 -29
- ccxt/async_support/coinbaseinternational.py +32 -32
- ccxt/async_support/coincheck.py +14 -14
- ccxt/async_support/coinex.py +424 -448
- ccxt/async_support/coinlist.py +35 -35
- ccxt/async_support/coinmate.py +22 -22
- ccxt/async_support/coinmetro.py +22 -22
- ccxt/async_support/coinone.py +18 -18
- ccxt/async_support/coinsph.py +32 -32
- ccxt/async_support/coinspot.py +8 -8
- ccxt/async_support/cryptocom.py +43 -43
- ccxt/async_support/currencycom.py +33 -33
- ccxt/async_support/delta.py +35 -35
- ccxt/async_support/deribit.py +54 -54
- ccxt/async_support/digifinex.py +56 -56
- ccxt/async_support/exmo.py +34 -34
- ccxt/async_support/gate.py +60 -60
- ccxt/async_support/gemini.py +24 -24
- ccxt/async_support/hitbtc.py +51 -51
- ccxt/async_support/hollaex.py +29 -29
- ccxt/async_support/htx.py +73 -73
- ccxt/async_support/huobijp.py +30 -30
- ccxt/async_support/hyperliquid.py +58 -58
- ccxt/async_support/idex.py +33 -33
- ccxt/async_support/independentreserve.py +12 -12
- ccxt/async_support/indodax.py +21 -21
- ccxt/async_support/kraken.py +46 -51
- ccxt/async_support/krakenfutures.py +29 -29
- ccxt/async_support/kucoin.py +51 -51
- ccxt/async_support/kucoinfutures.py +33 -33
- ccxt/async_support/kuna.py +27 -27
- ccxt/async_support/latoken.py +27 -27
- ccxt/async_support/lbank.py +35 -35
- ccxt/async_support/luno.py +19 -19
- ccxt/async_support/lykke.py +20 -20
- ccxt/async_support/mercado.py +17 -17
- ccxt/async_support/mexc.py +64 -64
- ccxt/async_support/ndax.py +38 -38
- ccxt/async_support/novadax.py +26 -26
- ccxt/async_support/oceanex.py +21 -21
- ccxt/async_support/okcoin.py +35 -35
- ccxt/async_support/okx.py +85 -85
- ccxt/async_support/onetrading.py +32 -32
- ccxt/async_support/p2b.py +14 -14
- ccxt/async_support/paymium.py +12 -12
- ccxt/async_support/phemex.py +50 -50
- ccxt/async_support/poloniex.py +35 -35
- ccxt/async_support/poloniexfutures.py +25 -21
- ccxt/async_support/probit.py +30 -30
- ccxt/async_support/timex.py +22 -22
- ccxt/async_support/tokocrypto.py +26 -26
- ccxt/async_support/tradeogre.py +12 -12
- ccxt/async_support/upbit.py +28 -28
- ccxt/async_support/wavesexchange.py +33 -33
- ccxt/async_support/wazirx.py +21 -21
- ccxt/async_support/whitebit.py +80 -40
- ccxt/async_support/woo.py +51 -51
- ccxt/async_support/woofipro.py +46 -46
- ccxt/async_support/yobit.py +20 -20
- ccxt/async_support/zaif.py +12 -12
- ccxt/async_support/zonda.py +22 -22
- ccxt/base/exchange.py +39 -35
- ccxt/base/types.py +13 -0
- ccxt/bigone.py +32 -32
- ccxt/binance.py +105 -96
- ccxt/bingx.py +22 -22
- ccxt/bit2c.py +13 -13
- ccxt/bitbank.py +19 -19
- ccxt/bitbns.py +17 -17
- ccxt/bitfinex.py +24 -24
- ccxt/bitfinex2.py +142 -109
- ccxt/bitflyer.py +23 -23
- ccxt/bitget.py +76 -76
- ccxt/bithumb.py +20 -20
- ccxt/bitmart.py +55 -55
- ccxt/bitmex.py +41 -41
- ccxt/bitopro.py +30 -30
- ccxt/bitrue.py +37 -37
- ccxt/bitso.py +30 -30
- ccxt/bitstamp.py +31 -31
- ccxt/bitteam.py +26 -26
- ccxt/bitvavo.py +27 -27
- ccxt/bl3p.py +8 -8
- ccxt/blockchaincom.py +24 -24
- ccxt/blofin.py +37 -37
- ccxt/btcalpha.py +19 -19
- ccxt/btcbox.py +11 -11
- ccxt/btcmarkets.py +22 -22
- ccxt/btcturk.py +13 -13
- ccxt/bybit.py +96 -96
- ccxt/cex.py +21 -21
- ccxt/coinbase.py +53 -53
- ccxt/coinbaseexchange.py +29 -29
- ccxt/coinbaseinternational.py +32 -32
- ccxt/coincheck.py +14 -14
- ccxt/coinex.py +424 -448
- ccxt/coinlist.py +35 -35
- ccxt/coinmate.py +22 -22
- ccxt/coinmetro.py +22 -22
- ccxt/coinone.py +18 -18
- ccxt/coinsph.py +32 -32
- ccxt/coinspot.py +8 -8
- ccxt/cryptocom.py +43 -43
- ccxt/currencycom.py +33 -33
- ccxt/delta.py +35 -35
- ccxt/deribit.py +54 -54
- ccxt/digifinex.py +56 -56
- ccxt/exmo.py +34 -34
- ccxt/gate.py +60 -60
- ccxt/gemini.py +24 -24
- ccxt/hitbtc.py +51 -51
- ccxt/hollaex.py +29 -29
- ccxt/htx.py +73 -73
- ccxt/huobijp.py +30 -30
- ccxt/hyperliquid.py +58 -58
- ccxt/idex.py +33 -33
- ccxt/independentreserve.py +12 -12
- ccxt/indodax.py +21 -21
- ccxt/kraken.py +46 -51
- ccxt/krakenfutures.py +29 -29
- ccxt/kucoin.py +51 -51
- ccxt/kucoinfutures.py +33 -33
- ccxt/kuna.py +27 -27
- ccxt/latoken.py +27 -27
- ccxt/lbank.py +35 -35
- ccxt/luno.py +19 -19
- ccxt/lykke.py +20 -20
- ccxt/mercado.py +17 -17
- ccxt/mexc.py +64 -64
- ccxt/ndax.py +38 -38
- ccxt/novadax.py +26 -26
- ccxt/oceanex.py +21 -21
- ccxt/okcoin.py +35 -35
- ccxt/okx.py +85 -85
- ccxt/onetrading.py +32 -32
- ccxt/p2b.py +14 -14
- ccxt/paymium.py +12 -12
- ccxt/phemex.py +50 -50
- ccxt/poloniex.py +35 -35
- ccxt/poloniexfutures.py +25 -21
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/alpaca.py +8 -8
- ccxt/pro/ascendex.py +4 -4
- ccxt/pro/binance.py +56 -56
- ccxt/pro/bingx.py +5 -5
- ccxt/pro/bitfinex.py +6 -6
- ccxt/pro/bitfinex2.py +10 -10
- ccxt/pro/bitget.py +17 -17
- ccxt/pro/bithumb.py +6 -6
- ccxt/pro/bitmart.py +8 -8
- ccxt/pro/bitmex.py +16 -16
- ccxt/pro/bitopro.py +4 -4
- ccxt/pro/bitrue.py +8 -8
- ccxt/pro/bitstamp.py +5 -5
- ccxt/pro/bitvavo.py +14 -14
- ccxt/pro/blockchaincom.py +7 -7
- ccxt/pro/bybit.py +12 -12
- ccxt/pro/cex.py +19 -19
- ccxt/pro/coinbase.py +2 -2
- ccxt/pro/coinbaseexchange.py +10 -10
- ccxt/pro/coinbaseinternational.py +4 -4
- ccxt/pro/coincheck.py +2 -2
- ccxt/pro/coinex.py +15 -15
- ccxt/pro/coinone.py +4 -4
- ccxt/pro/cryptocom.py +11 -11
- ccxt/pro/currencycom.py +4 -4
- ccxt/pro/deribit.py +9 -9
- ccxt/pro/exmo.py +9 -9
- ccxt/pro/gate.py +12 -12
- ccxt/pro/gemini.py +11 -11
- ccxt/pro/hitbtc.py +13 -13
- ccxt/pro/hollaex.py +6 -6
- ccxt/pro/htx.py +15 -15
- ccxt/pro/huobijp.py +16 -16
- ccxt/pro/hyperliquid.py +9 -9
- ccxt/pro/idex.py +12 -12
- ccxt/pro/independentreserve.py +2 -2
- ccxt/pro/kraken.py +14 -14
- ccxt/pro/krakenfutures.py +12 -12
- ccxt/pro/kucoin.py +12 -12
- ccxt/pro/kucoinfutures.py +16 -16
- ccxt/pro/lbank.py +12 -12
- ccxt/pro/luno.py +4 -4
- ccxt/pro/mexc.py +14 -14
- ccxt/pro/ndax.py +12 -12
- ccxt/pro/okcoin.py +6 -6
- ccxt/pro/okx.py +30 -30
- ccxt/pro/onetrading.py +13 -13
- ccxt/pro/p2b.py +2 -2
- ccxt/pro/phemex.py +9 -9
- ccxt/pro/poloniex.py +9 -9
- ccxt/pro/poloniexfutures.py +10 -10
- ccxt/pro/probit.py +8 -8
- ccxt/pro/upbit.py +1 -1
- ccxt/pro/wazirx.py +10 -10
- ccxt/pro/whitebit.py +8 -8
- ccxt/pro/woo.py +14 -14
- ccxt/pro/woofipro.py +14 -14
- ccxt/probit.py +30 -30
- ccxt/test/base/test_shared_methods.py +1 -0
- ccxt/timex.py +22 -22
- ccxt/tokocrypto.py +26 -26
- ccxt/tradeogre.py +12 -12
- ccxt/upbit.py +28 -28
- ccxt/wavesexchange.py +33 -33
- ccxt/wazirx.py +21 -21
- ccxt/whitebit.py +80 -40
- ccxt/woo.py +51 -51
- ccxt/woofipro.py +46 -46
- ccxt/yobit.py +20 -20
- ccxt/zaif.py +12 -12
- ccxt/zonda.py +22 -22
- {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/METADATA +4 -4
- {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/RECORD +260 -260
- {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/WHEEL +0 -0
- {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/top_level.txt +0 -0
ccxt/async_support/coinex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinex import ImplicitAPI
|
8
8
|
import asyncio
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate,
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -82,15 +82,15 @@ class coinex(Exchange, ImplicitAPI):
|
|
82
82
|
'fetchDepositAddressByNetwork': False,
|
83
83
|
'fetchDepositAddresses': False,
|
84
84
|
'fetchDeposits': True,
|
85
|
-
'fetchDepositWithdrawFee':
|
86
|
-
'fetchDepositWithdrawFees':
|
85
|
+
'fetchDepositWithdrawFee': True,
|
86
|
+
'fetchDepositWithdrawFees': False,
|
87
87
|
'fetchFundingHistory': True,
|
88
88
|
'fetchFundingRate': True,
|
89
89
|
'fetchFundingRateHistory': True,
|
90
90
|
'fetchFundingRates': True,
|
91
91
|
'fetchIndexOHLCV': False,
|
92
92
|
'fetchIsolatedBorrowRate': True,
|
93
|
-
'fetchIsolatedBorrowRates':
|
93
|
+
'fetchIsolatedBorrowRates': False,
|
94
94
|
'fetchLeverage': 'emulated',
|
95
95
|
'fetchLeverages': True,
|
96
96
|
'fetchLeverageTiers': True,
|
@@ -567,7 +567,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
567
567
|
#
|
568
568
|
data = self.safe_value(response, 'data', [])
|
569
569
|
coins = list(data.keys())
|
570
|
-
result = {}
|
570
|
+
result: dict = {}
|
571
571
|
for i in range(0, len(coins)):
|
572
572
|
coin = coins[i]
|
573
573
|
currency = data[coin]
|
@@ -628,7 +628,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
628
628
|
if precisionString is not None:
|
629
629
|
minPrecisionString = precisionString if (minPrecisionString is None) else Precise.string_min(precisionString, minPrecisionString)
|
630
630
|
networks = self.safe_value(result[code], 'networks', {})
|
631
|
-
network = {
|
631
|
+
network: dict = {
|
632
632
|
'info': currency,
|
633
633
|
'id': networkId,
|
634
634
|
'network': networkId,
|
@@ -936,7 +936,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
936
936
|
"""
|
937
937
|
await self.load_markets()
|
938
938
|
market = self.market(symbol)
|
939
|
-
request = {
|
939
|
+
request: dict = {
|
940
940
|
'market': market['id'],
|
941
941
|
}
|
942
942
|
response = None
|
@@ -1100,7 +1100,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1100
1100
|
market = self.market(symbol)
|
1101
1101
|
if limit is None:
|
1102
1102
|
limit = 20 # default
|
1103
|
-
request = {
|
1103
|
+
request: dict = {
|
1104
1104
|
'market': market['id'],
|
1105
1105
|
'limit': limit,
|
1106
1106
|
'interval': '0',
|
@@ -1165,7 +1165,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1165
1165
|
timestamp = self.safe_integer(depth, 'updated_at')
|
1166
1166
|
return self.parse_order_book(depth, symbol, timestamp)
|
1167
1167
|
|
1168
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
1168
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1169
1169
|
#
|
1170
1170
|
# Spot and Swap fetchTrades(public)
|
1171
1171
|
#
|
@@ -1237,7 +1237,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1237
1237
|
"""
|
1238
1238
|
await self.load_markets()
|
1239
1239
|
market = self.market(symbol)
|
1240
|
-
request = {
|
1240
|
+
request: dict = {
|
1241
1241
|
'market': market['id'],
|
1242
1242
|
# 'last_id': 0,
|
1243
1243
|
}
|
@@ -1278,7 +1278,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1278
1278
|
"""
|
1279
1279
|
await self.load_markets()
|
1280
1280
|
market = self.market(symbol)
|
1281
|
-
request = {
|
1281
|
+
request: dict = {
|
1282
1282
|
'market': market['id'],
|
1283
1283
|
}
|
1284
1284
|
response = None
|
@@ -1389,7 +1389,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1389
1389
|
# }
|
1390
1390
|
#
|
1391
1391
|
data = self.safe_list(response, 'data', [])
|
1392
|
-
result = {}
|
1392
|
+
result: dict = {}
|
1393
1393
|
for i in range(0, len(data)):
|
1394
1394
|
entry = data[i]
|
1395
1395
|
marketId = self.safe_string(entry, 'market')
|
@@ -1398,7 +1398,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1398
1398
|
result[symbol] = self.parse_trading_fee(entry, market)
|
1399
1399
|
return result
|
1400
1400
|
|
1401
|
-
def parse_trading_fee(self, fee, market: Market = None) -> TradingFeeInterface:
|
1401
|
+
def parse_trading_fee(self, fee: dict, market: Market = None) -> TradingFeeInterface:
|
1402
1402
|
marketId = self.safe_value(fee, 'market')
|
1403
1403
|
symbol = self.safe_symbol(marketId, market)
|
1404
1404
|
return {
|
@@ -1446,7 +1446,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1446
1446
|
"""
|
1447
1447
|
await self.load_markets()
|
1448
1448
|
market = self.market(symbol)
|
1449
|
-
request = {
|
1449
|
+
request: dict = {
|
1450
1450
|
'market': market['id'],
|
1451
1451
|
'period': self.safe_string(self.timeframes, timeframe, timeframe),
|
1452
1452
|
}
|
@@ -1514,7 +1514,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1514
1514
|
# "message": "OK"
|
1515
1515
|
# }
|
1516
1516
|
#
|
1517
|
-
result = {'info': response}
|
1517
|
+
result: dict = {'info': response}
|
1518
1518
|
balances = self.safe_list(response, 'data', [])
|
1519
1519
|
for i in range(0, len(balances)):
|
1520
1520
|
entry = balances[i]
|
@@ -1549,7 +1549,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1549
1549
|
# "message": "OK"
|
1550
1550
|
# }
|
1551
1551
|
#
|
1552
|
-
result = {'info': response}
|
1552
|
+
result: dict = {'info': response}
|
1553
1553
|
balances = self.safe_list(response, 'data', [])
|
1554
1554
|
for i in range(0, len(balances)):
|
1555
1555
|
entry = balances[i]
|
@@ -1580,7 +1580,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1580
1580
|
# "message": "OK"
|
1581
1581
|
# }
|
1582
1582
|
#
|
1583
|
-
result = {'info': response}
|
1583
|
+
result: dict = {'info': response}
|
1584
1584
|
balances = self.safe_list(response, 'data', [])
|
1585
1585
|
for i in range(0, len(balances)):
|
1586
1586
|
entry = balances[i]
|
@@ -1608,7 +1608,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1608
1608
|
# "message": "OK"
|
1609
1609
|
# }
|
1610
1610
|
#
|
1611
|
-
result = {'info': response}
|
1611
|
+
result: dict = {'info': response}
|
1612
1612
|
balances = self.safe_list(response, 'data', [])
|
1613
1613
|
for i in range(0, len(balances)):
|
1614
1614
|
entry = balances[i]
|
@@ -1646,8 +1646,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
1646
1646
|
else:
|
1647
1647
|
return await self.fetch_spot_balance(params)
|
1648
1648
|
|
1649
|
-
def parse_order_status(self, status):
|
1650
|
-
statuses = {
|
1649
|
+
def parse_order_status(self, status: Str):
|
1650
|
+
statuses: dict = {
|
1651
1651
|
'rejected': 'rejected',
|
1652
1652
|
'open': 'open',
|
1653
1653
|
'not_deal': 'open',
|
@@ -1657,7 +1657,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1657
1657
|
}
|
1658
1658
|
return self.safe_string(statuses, status, status)
|
1659
1659
|
|
1660
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
1660
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1661
1661
|
#
|
1662
1662
|
# Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders
|
1663
1663
|
#
|
@@ -1952,7 +1952,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1952
1952
|
if reduceOnly:
|
1953
1953
|
if not market['swap']:
|
1954
1954
|
raise InvalidOrder(self.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only')
|
1955
|
-
request = {
|
1955
|
+
request: dict = {
|
1956
1956
|
'market': market['id'],
|
1957
1957
|
}
|
1958
1958
|
if clientOrderId is None:
|
@@ -2298,7 +2298,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
2298
2298
|
orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
|
2299
2299
|
ordersRequests.append(orderRequest)
|
2300
2300
|
market = self.market(symbol)
|
2301
|
-
request = {
|
2301
|
+
request: dict = {
|
2302
2302
|
'market': market['id'],
|
2303
2303
|
'orders': ordersRequests,
|
2304
2304
|
}
|
@@ -2457,7 +2457,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
2457
2457
|
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
|
2458
2458
|
await self.load_markets()
|
2459
2459
|
market = self.market(symbol)
|
2460
|
-
request = {
|
2460
|
+
request: dict = {
|
2461
2461
|
'market': market['id'],
|
2462
2462
|
}
|
2463
2463
|
stop = self.safe_bool_2(params, 'stop', 'trigger')
|
@@ -2632,7 +2632,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
2632
2632
|
raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
|
2633
2633
|
await self.load_markets()
|
2634
2634
|
market = self.market(symbol)
|
2635
|
-
request = {
|
2635
|
+
request: dict = {
|
2636
2636
|
'market': market['id'],
|
2637
2637
|
}
|
2638
2638
|
if amount is not None:
|
@@ -2768,7 +2768,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
2768
2768
|
market = self.market(symbol)
|
2769
2769
|
isTriggerOrder = self.safe_bool_2(params, 'stop', 'trigger')
|
2770
2770
|
swap = market['swap']
|
2771
|
-
request = {
|
2771
|
+
request: dict = {
|
2772
2772
|
'market': market['id'],
|
2773
2773
|
}
|
2774
2774
|
marginMode = None
|
@@ -3039,7 +3039,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3039
3039
|
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
3040
3040
|
await self.load_markets()
|
3041
3041
|
market = self.market(symbol)
|
3042
|
-
request = {
|
3042
|
+
request: dict = {
|
3043
3043
|
'market': market['id'],
|
3044
3044
|
}
|
3045
3045
|
response = None
|
@@ -3075,7 +3075,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3075
3075
|
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
3076
3076
|
await self.load_markets()
|
3077
3077
|
market = self.market(symbol)
|
3078
|
-
request = {
|
3078
|
+
request: dict = {
|
3079
3079
|
'market': market['id'],
|
3080
3080
|
'order_id': self.parse_to_numeric(id),
|
3081
3081
|
}
|
@@ -3161,7 +3161,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3161
3161
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3162
3162
|
"""
|
3163
3163
|
await self.load_markets()
|
3164
|
-
request = {}
|
3164
|
+
request: dict = {}
|
3165
3165
|
market = None
|
3166
3166
|
if symbol is not None:
|
3167
3167
|
market = self.market(symbol)
|
@@ -3497,7 +3497,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3497
3497
|
if network is None:
|
3498
3498
|
raise ArgumentsRequired(self.id + ' createDepositAddress() requires a network parameter')
|
3499
3499
|
params = self.omit(params, 'network')
|
3500
|
-
request = {
|
3500
|
+
request: dict = {
|
3501
3501
|
'ccy': currency['id'],
|
3502
3502
|
'chain': self.network_code_to_id(network, currency['code']),
|
3503
3503
|
}
|
@@ -3536,7 +3536,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3536
3536
|
raise ArgumentsRequired(self.id + ' fetchDepositAddress() ' + code + ' requires a network parameter')
|
3537
3537
|
if not (network in networks):
|
3538
3538
|
raise ExchangeError(self.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code)
|
3539
|
-
request = {
|
3539
|
+
request: dict = {
|
3540
3540
|
'ccy': currency['id'],
|
3541
3541
|
'chain': network,
|
3542
3542
|
}
|
@@ -3616,7 +3616,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3616
3616
|
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
|
3617
3617
|
await self.load_markets()
|
3618
3618
|
market = self.market(symbol)
|
3619
|
-
request = {
|
3619
|
+
request: dict = {
|
3620
3620
|
'market': market['id'],
|
3621
3621
|
}
|
3622
3622
|
if limit is not None:
|
@@ -3694,7 +3694,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3694
3694
|
defaultMethod = None
|
3695
3695
|
defaultMethod, params = self.handle_option_and_params(params, 'fetchPositions', 'method', 'v2PrivateGetFuturesPendingPosition')
|
3696
3696
|
symbols = self.market_symbols(symbols)
|
3697
|
-
request = {
|
3697
|
+
request: dict = {
|
3698
3698
|
'market_type': 'FUTURES',
|
3699
3699
|
}
|
3700
3700
|
market = None
|
@@ -3773,7 +3773,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3773
3773
|
"""
|
3774
3774
|
await self.load_markets()
|
3775
3775
|
market = self.market(symbol)
|
3776
|
-
request = {
|
3776
|
+
request: dict = {
|
3777
3777
|
'market_type': 'FUTURES',
|
3778
3778
|
'market': market['id'],
|
3779
3779
|
}
|
@@ -3824,7 +3824,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3824
3824
|
data = self.safe_list(response, 'data', [])
|
3825
3825
|
return self.parse_position(data[0], market)
|
3826
3826
|
|
3827
|
-
def parse_position(self, position, market: Market = None):
|
3827
|
+
def parse_position(self, position: dict, market: Market = None):
|
3828
3828
|
#
|
3829
3829
|
# {
|
3830
3830
|
# "position_id": 305891033,
|
@@ -3918,7 +3918,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3918
3918
|
raise ArgumentsRequired(self.id + ' setMarginMode() requires a leverage parameter')
|
3919
3919
|
if (leverage < 1) or (leverage > maxLeverage):
|
3920
3920
|
raise BadRequest(self.id + ' setMarginMode() leverage should be between 1 and ' + str(maxLeverage) + ' for ' + symbol)
|
3921
|
-
request = {
|
3921
|
+
request: dict = {
|
3922
3922
|
'market': market['id'],
|
3923
3923
|
'market_type': 'FUTURES',
|
3924
3924
|
'margin_mode': marginMode,
|
@@ -3958,7 +3958,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3958
3958
|
maxLeverage = self.safe_integer(market['limits']['leverage'], 'max', 100)
|
3959
3959
|
if (leverage < minLeverage) or (leverage > maxLeverage):
|
3960
3960
|
raise BadRequest(self.id + ' setLeverage() leverage should be between ' + str(minLeverage) + ' and ' + str(maxLeverage) + ' for ' + symbol)
|
3961
|
-
request = {
|
3961
|
+
request: dict = {
|
3962
3962
|
'market': market['id'],
|
3963
3963
|
'market_type': 'FUTURES',
|
3964
3964
|
'margin_mode': marginMode,
|
@@ -3976,7 +3976,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3976
3976
|
# }
|
3977
3977
|
#
|
3978
3978
|
|
3979
|
-
async def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
|
3979
|
+
async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
|
3980
3980
|
"""
|
3981
3981
|
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
3982
3982
|
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
|
@@ -3985,7 +3985,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3985
3985
|
:returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
|
3986
3986
|
"""
|
3987
3987
|
await self.load_markets()
|
3988
|
-
request = {}
|
3988
|
+
request: dict = {}
|
3989
3989
|
if symbols is not None:
|
3990
3990
|
marketIds = self.market_ids(symbols)
|
3991
3991
|
request['market'] = ','.join(marketIds)
|
@@ -4018,7 +4018,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4018
4018
|
data = self.safe_list(response, 'data', [])
|
4019
4019
|
return self.parse_leverage_tiers(data, symbols, 'market')
|
4020
4020
|
|
4021
|
-
def parse_market_leverage_tiers(self, info, market: Market = None):
|
4021
|
+
def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
|
4022
4022
|
tiers = []
|
4023
4023
|
brackets = self.safe_list(info, 'level', [])
|
4024
4024
|
minNotional = 0
|
@@ -4046,7 +4046,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4046
4046
|
requestAmount = rawAmount
|
4047
4047
|
if addOrReduce == 'reduce':
|
4048
4048
|
requestAmount = Precise.string_neg(rawAmount)
|
4049
|
-
request = {
|
4049
|
+
request: dict = {
|
4050
4050
|
'market': market['id'],
|
4051
4051
|
'market_type': 'FUTURES',
|
4052
4052
|
'amount': requestAmount,
|
@@ -4205,7 +4205,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4205
4205
|
raise ArgumentsRequired(self.id + ' fetchFundingHistory() requires a symbol argument')
|
4206
4206
|
await self.load_markets()
|
4207
4207
|
market = self.market(symbol)
|
4208
|
-
request = {
|
4208
|
+
request: dict = {
|
4209
4209
|
'market': market['id'],
|
4210
4210
|
'market_type': 'FUTURES',
|
4211
4211
|
}
|
@@ -4266,7 +4266,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4266
4266
|
market = self.market(symbol)
|
4267
4267
|
if not market['swap']:
|
4268
4268
|
raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
|
4269
|
-
request = {
|
4269
|
+
request: dict = {
|
4270
4270
|
'market': market['id'],
|
4271
4271
|
}
|
4272
4272
|
response = await self.v2PublicGetFuturesFundingRate(self.extend(request, params))
|
@@ -4340,7 +4340,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4340
4340
|
"""
|
4341
4341
|
await self.load_markets()
|
4342
4342
|
symbols = self.market_symbols(symbols)
|
4343
|
-
request = {}
|
4343
|
+
request: dict = {}
|
4344
4344
|
market = None
|
4345
4345
|
if symbols is not None:
|
4346
4346
|
symbol = self.safe_value(symbols, 0)
|
@@ -4392,7 +4392,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4392
4392
|
params = self.omit(params, 'network')
|
4393
4393
|
if tag:
|
4394
4394
|
address = address + ':' + tag
|
4395
|
-
request = {
|
4395
|
+
request: dict = {
|
4396
4396
|
'coin_type': currency['id'],
|
4397
4397
|
'coin_address': address, # must be authorized, inter-user transfer by a registered mobile phone number or an email address is supported
|
4398
4398
|
'actual_amount': float(self.number_to_string(amount)), # the actual amount without fees, https://www.coinex.com/fees
|
@@ -4423,7 +4423,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4423
4423
|
return self.parse_transaction(transaction, currency)
|
4424
4424
|
|
4425
4425
|
def parse_transaction_status(self, status):
|
4426
|
-
statuses = {
|
4426
|
+
statuses: dict = {
|
4427
4427
|
'audit': 'pending',
|
4428
4428
|
'pass': 'pending',
|
4429
4429
|
'processing': 'pending',
|
@@ -4455,7 +4455,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4455
4455
|
if paginate:
|
4456
4456
|
return await self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000)
|
4457
4457
|
market = self.market(symbol)
|
4458
|
-
request = {
|
4458
|
+
request: dict = {
|
4459
4459
|
'market': market['id'],
|
4460
4460
|
}
|
4461
4461
|
if since is not None:
|
@@ -4498,111 +4498,102 @@ class coinex(Exchange, ImplicitAPI):
|
|
4498
4498
|
sorted = self.sort_by(rates, 'timestamp')
|
4499
4499
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
4500
4500
|
|
4501
|
-
def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
|
4501
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
4502
4502
|
#
|
4503
4503
|
# fetchDeposits
|
4504
4504
|
#
|
4505
|
-
#
|
4506
|
-
#
|
4507
|
-
#
|
4508
|
-
#
|
4509
|
-
#
|
4510
|
-
#
|
4511
|
-
#
|
4512
|
-
#
|
4513
|
-
#
|
4514
|
-
#
|
4515
|
-
#
|
4516
|
-
#
|
4517
|
-
#
|
4518
|
-
#
|
4519
|
-
#
|
4520
|
-
#
|
4521
|
-
#
|
4522
|
-
# "transfer_method": "onchain",
|
4523
|
-
# "status": "finish",
|
4524
|
-
# "status_display": "finish",
|
4525
|
-
# "remark": "",
|
4526
|
-
# "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
4527
|
-
# }
|
4505
|
+
# {
|
4506
|
+
# "deposit_id": 5173806,
|
4507
|
+
# "created_at": 1714021652557,
|
4508
|
+
# "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
|
4509
|
+
# "tx_id_display": "",
|
4510
|
+
# "ccy": "USDT",
|
4511
|
+
# "chain": "TRC20",
|
4512
|
+
# "deposit_method": "ON_CHAIN",
|
4513
|
+
# "amount": "30",
|
4514
|
+
# "actual_amount": "",
|
4515
|
+
# "to_address": "TYewD2pVWDUwfNr9A",
|
4516
|
+
# "confirmations": 20,
|
4517
|
+
# "status": "FINISHED",
|
4518
|
+
# "tx_explorer_url": "https://tronscan.org/#/transaction",
|
4519
|
+
# "to_addr_explorer_url": "https://tronscan.org/#/address",
|
4520
|
+
# "remark": ""
|
4521
|
+
# }
|
4528
4522
|
#
|
4529
4523
|
# fetchWithdrawals
|
4530
4524
|
#
|
4531
|
-
#
|
4532
|
-
#
|
4533
|
-
#
|
4534
|
-
#
|
4535
|
-
#
|
4536
|
-
#
|
4537
|
-
#
|
4538
|
-
#
|
4539
|
-
#
|
4540
|
-
#
|
4541
|
-
#
|
4542
|
-
#
|
4543
|
-
#
|
4544
|
-
#
|
4545
|
-
#
|
4546
|
-
#
|
4547
|
-
#
|
4548
|
-
#
|
4549
|
-
#
|
4550
|
-
#
|
4551
|
-
#
|
4552
|
-
|
4553
|
-
|
4554
|
-
#
|
4555
|
-
id = self.safe_string_2(transaction, 'coin_withdraw_id', 'coin_deposit_id')
|
4556
|
-
address = self.safe_string(transaction, 'coin_address')
|
4557
|
-
tag = self.safe_string(transaction, 'remark') # set but unused
|
4525
|
+
# {
|
4526
|
+
# "withdraw_id": 259364,
|
4527
|
+
# "created_at": 1701323541548,
|
4528
|
+
# "withdraw_method": "ON_CHAIN",
|
4529
|
+
# "ccy": "USDT",
|
4530
|
+
# "amount": "23.845744",
|
4531
|
+
# "actual_amount": "22.445744",
|
4532
|
+
# "chain": "TRC20",
|
4533
|
+
# "tx_fee": "1.4",
|
4534
|
+
# "fee_asset": "USDT",
|
4535
|
+
# "fee_amount": "1.4",
|
4536
|
+
# "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
|
4537
|
+
# "memo": "",
|
4538
|
+
# "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
|
4539
|
+
# "confirmations": 18,
|
4540
|
+
# "explorer_address_url": "https://tronscan.org/#/address",
|
4541
|
+
# "explorer_tx_url": "https://tronscan.org/#/transaction",
|
4542
|
+
# "remark": "",
|
4543
|
+
# "status": "finished"
|
4544
|
+
# }
|
4545
|
+
#
|
4546
|
+
address = self.safe_string(transaction, 'to_address')
|
4547
|
+
tag = self.safe_string(transaction, 'memo')
|
4558
4548
|
if tag is not None:
|
4559
4549
|
if len(tag) < 1:
|
4560
4550
|
tag = None
|
4561
|
-
|
4551
|
+
remark = self.safe_string(transaction, 'remark')
|
4552
|
+
if remark is not None:
|
4553
|
+
if len(remark) < 1:
|
4554
|
+
remark = None
|
4555
|
+
txid = self.safe_string(transaction, 'tx_id')
|
4562
4556
|
if txid is not None:
|
4563
4557
|
if len(txid) < 1:
|
4564
4558
|
txid = None
|
4565
|
-
currencyId = self.safe_string(transaction, '
|
4559
|
+
currencyId = self.safe_string(transaction, 'ccy')
|
4566
4560
|
code = self.safe_currency_code(currencyId, currency)
|
4567
|
-
timestamp = self.
|
4568
|
-
type = 'withdrawal' if ('
|
4569
|
-
|
4570
|
-
networkId = self.safe_string(transaction, 'smart_contract_name')
|
4571
|
-
amount = self.safe_number(transaction, 'actual_amount')
|
4561
|
+
timestamp = self.safe_integer(transaction, 'created_at')
|
4562
|
+
type = 'withdrawal' if ('withdraw_id' in transaction) else 'deposit'
|
4563
|
+
networkId = self.safe_string(transaction, 'chain')
|
4572
4564
|
feeCost = self.safe_string(transaction, 'tx_fee')
|
4573
|
-
transferMethod = self.
|
4565
|
+
transferMethod = self.safe_string_lower_2(transaction, 'withdraw_method', 'deposit_method')
|
4574
4566
|
internal = transferMethod == 'local'
|
4575
|
-
|
4576
|
-
|
4567
|
+
amount = self.safe_number(transaction, 'actual_amount')
|
4568
|
+
if amount is None:
|
4569
|
+
amount = self.safe_number(transaction, 'amount')
|
4577
4570
|
if type == 'deposit':
|
4578
4571
|
feeCost = '0'
|
4579
|
-
|
4580
|
-
else:
|
4581
|
-
addressFrom = address
|
4572
|
+
feeCurrencyId = self.safe_string(transaction, 'fee_asset')
|
4582
4573
|
fee = {
|
4583
4574
|
'cost': self.parse_number(feeCost),
|
4584
|
-
'currency':
|
4575
|
+
'currency': self.safe_currency_code(feeCurrencyId),
|
4585
4576
|
}
|
4586
4577
|
return {
|
4587
4578
|
'info': transaction,
|
4588
|
-
'id':
|
4579
|
+
'id': self.safe_string_2(transaction, 'withdraw_id', 'deposit_id'),
|
4589
4580
|
'txid': txid,
|
4590
4581
|
'timestamp': timestamp,
|
4591
4582
|
'datetime': self.iso8601(timestamp),
|
4592
4583
|
'network': self.network_id_to_code(networkId),
|
4593
4584
|
'address': address,
|
4594
|
-
'addressTo':
|
4585
|
+
'addressTo': address,
|
4595
4586
|
'addressFrom': None,
|
4596
4587
|
'tag': tag,
|
4597
|
-
'tagTo':
|
4598
|
-
'tagFrom':
|
4588
|
+
'tagTo': None,
|
4589
|
+
'tagFrom': None,
|
4599
4590
|
'type': type,
|
4600
|
-
'amount':
|
4591
|
+
'amount': amount,
|
4601
4592
|
'currency': code,
|
4602
|
-
'status': status,
|
4593
|
+
'status': self.parse_transaction_status(self.safe_string(transaction, 'status')),
|
4603
4594
|
'updated': None,
|
4604
4595
|
'fee': fee,
|
4605
|
-
'comment':
|
4596
|
+
'comment': remark,
|
4606
4597
|
'internal': internal,
|
4607
4598
|
}
|
4608
4599
|
|
@@ -4624,7 +4615,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4624
4615
|
accountsByType = self.safe_dict(self.options, 'accountsById', {})
|
4625
4616
|
fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
|
4626
4617
|
toId = self.safe_string(accountsByType, toAccount, toAccount)
|
4627
|
-
request = {
|
4618
|
+
request: dict = {
|
4628
4619
|
'ccy': currency['id'],
|
4629
4620
|
'amount': amountToPrecision,
|
4630
4621
|
'from_account_type': fromId,
|
@@ -4653,7 +4644,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4653
4644
|
})
|
4654
4645
|
|
4655
4646
|
def parse_transfer_status(self, status):
|
4656
|
-
statuses = {
|
4647
|
+
statuses: dict = {
|
4657
4648
|
'0': 'ok',
|
4658
4649
|
'SUCCESS': 'ok',
|
4659
4650
|
'OK': 'ok',
|
@@ -4694,7 +4685,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4694
4685
|
if code is None:
|
4695
4686
|
raise ArgumentsRequired(self.id + ' fetchTransfers() requires a code argument')
|
4696
4687
|
currency = self.currency(code)
|
4697
|
-
request = {
|
4688
|
+
request: dict = {
|
4698
4689
|
'ccy': currency['id'],
|
4699
4690
|
}
|
4700
4691
|
marginMode = None
|
@@ -4735,154 +4726,135 @@ class coinex(Exchange, ImplicitAPI):
|
|
4735
4726
|
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4736
4727
|
"""
|
4737
4728
|
fetch all withdrawals made from an account
|
4738
|
-
:see: https://
|
4739
|
-
:param str code: unified currency code
|
4729
|
+
:see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
|
4730
|
+
:param str [code]: unified currency code
|
4740
4731
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
4741
|
-
:param int [limit]: the maximum number of
|
4732
|
+
:param int [limit]: the maximum number of withdrawal structures to retrieve
|
4742
4733
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4743
4734
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4744
4735
|
"""
|
4745
|
-
|
4736
|
+
await self.load_markets()
|
4737
|
+
request: dict = {}
|
4746
4738
|
currency = None
|
4747
4739
|
if code is not None:
|
4748
|
-
await self.load_markets()
|
4749
4740
|
currency = self.currency(code)
|
4750
|
-
request['
|
4741
|
+
request['ccy'] = currency['id']
|
4751
4742
|
if limit is not None:
|
4752
|
-
request['
|
4753
|
-
response = await self.
|
4754
|
-
#
|
4755
|
-
# {
|
4756
|
-
# "code": 0,
|
4757
|
-
# "data": {
|
4758
|
-
# "has_next": False,
|
4759
|
-
# "curr_page": 1,
|
4760
|
-
# "count": 1,
|
4761
|
-
# "data": [
|
4762
|
-
# {
|
4763
|
-
# "coin_withdraw_id": 20076836,
|
4764
|
-
# "create_time": 1673325776,
|
4765
|
-
# "actual_amount": "0.029",
|
4766
|
-
# "actual_amount_display": "0.029",
|
4767
|
-
# "amount": "0.03",
|
4768
|
-
# "amount_display": "0.03",
|
4769
|
-
# "coin_address": "MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
|
4770
|
-
# "app_coin_address_display": "MBh****pAb",
|
4771
|
-
# "coin_address_display": "MBhJcc****UdJpAb",
|
4772
|
-
# "add_explorer": "https://explorer.viawallet.com/ltc/address/MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
|
4773
|
-
# "coin_type": "LTC",
|
4774
|
-
# "confirmations": 7,
|
4775
|
-
# "explorer": "https://explorer.viawallet.com/ltc/tx/a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9",
|
4776
|
-
# "fee": "0",
|
4777
|
-
# "remark": "",
|
4778
|
-
# "smart_contract_name": "",
|
4779
|
-
# "status": "finish",
|
4780
|
-
# "status_display": "finish",
|
4781
|
-
# "transfer_method": "onchain",
|
4782
|
-
# "tx_fee": "0.001",
|
4783
|
-
# "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
|
4784
|
-
# }
|
4785
|
-
# ],
|
4786
|
-
# "total": 1,
|
4787
|
-
# "total_page": 1
|
4788
|
-
# },
|
4789
|
-
# "message": "Success"
|
4790
|
-
# }
|
4743
|
+
request['limit'] = limit
|
4744
|
+
response = await self.v2PrivateGetAssetsWithdraw(self.extend(request, params))
|
4791
4745
|
#
|
4792
|
-
|
4793
|
-
|
4794
|
-
|
4746
|
+
# {
|
4747
|
+
# "data": [
|
4748
|
+
# {
|
4749
|
+
# "withdraw_id": 259364,
|
4750
|
+
# "created_at": 1701323541548,
|
4751
|
+
# "withdraw_method": "ON_CHAIN",
|
4752
|
+
# "ccy": "USDT",
|
4753
|
+
# "amount": "23.845744",
|
4754
|
+
# "actual_amount": "22.445744",
|
4755
|
+
# "chain": "TRC20",
|
4756
|
+
# "tx_fee": "1.4",
|
4757
|
+
# "fee_asset": "USDT",
|
4758
|
+
# "fee_amount": "1.4",
|
4759
|
+
# "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
|
4760
|
+
# "memo": "",
|
4761
|
+
# "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
|
4762
|
+
# "confirmations": 18,
|
4763
|
+
# "explorer_address_url": "https://tronscan.org/#/address",
|
4764
|
+
# "explorer_tx_url": "https://tronscan.org/#/transaction",
|
4765
|
+
# "remark": "",
|
4766
|
+
# "status": "finished"
|
4767
|
+
# },
|
4768
|
+
# ],
|
4769
|
+
# "pagination": {
|
4770
|
+
# "total": 9,
|
4771
|
+
# "has_next": True
|
4772
|
+
# },
|
4773
|
+
# "code": 0,
|
4774
|
+
# "message": "OK"
|
4775
|
+
# }
|
4776
|
+
#
|
4777
|
+
data = self.safe_list(response, 'data', [])
|
4795
4778
|
return self.parse_transactions(data, currency, since, limit)
|
4796
4779
|
|
4797
4780
|
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4798
4781
|
"""
|
4799
4782
|
fetch all deposits made to an account
|
4800
|
-
:see: https://
|
4801
|
-
:param str code: unified currency code
|
4783
|
+
:see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
|
4784
|
+
:param str [code]: unified currency code
|
4802
4785
|
:param int [since]: the earliest time in ms to fetch deposits for
|
4803
|
-
:param int [limit]: the maximum number of
|
4786
|
+
:param int [limit]: the maximum number of deposit structures to retrieve
|
4804
4787
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4805
4788
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4806
4789
|
"""
|
4807
|
-
|
4790
|
+
await self.load_markets()
|
4791
|
+
request: dict = {}
|
4808
4792
|
currency = None
|
4809
4793
|
if code is not None:
|
4810
|
-
await self.load_markets()
|
4811
4794
|
currency = self.currency(code)
|
4812
|
-
request['
|
4795
|
+
request['ccy'] = currency['id']
|
4813
4796
|
if limit is not None:
|
4814
|
-
request['
|
4815
|
-
response = await self.
|
4816
|
-
#
|
4817
|
-
# {
|
4818
|
-
# "code": 0,
|
4819
|
-
# "data": {
|
4820
|
-
# "has_next": False,
|
4821
|
-
# "curr_page": 1,
|
4822
|
-
# "count": 1,
|
4823
|
-
# "data": [
|
4824
|
-
# {
|
4825
|
-
# "coin_deposit_id": 32555985,
|
4826
|
-
# "create_time": 1673325495,
|
4827
|
-
# "amount": "12.71",
|
4828
|
-
# "amount_display": "12.71",
|
4829
|
-
# "diff_amount": "0",
|
4830
|
-
# "min_amount": "0",
|
4831
|
-
# "actual_amount": "12.71",
|
4832
|
-
# "actual_amount_display": "12.71",
|
4833
|
-
# "confirmations": 35,
|
4834
|
-
# "tx_id": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
|
4835
|
-
# "tx_id_display": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
|
4836
|
-
# "coin_address": "0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
|
4837
|
-
# "coin_address_display": "0xe7a3****f4b738",
|
4838
|
-
# "add_explorer": "https://bscscan.com/address/0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
|
4839
|
-
# "coin_type": "USDT",
|
4840
|
-
# "smart_contract_name": "BSC",
|
4841
|
-
# "transfer_method": "onchain",
|
4842
|
-
# "status": "finish",
|
4843
|
-
# "status_display": "finish",
|
4844
|
-
# "remark": "",
|
4845
|
-
# "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
4846
|
-
# }
|
4847
|
-
# ],
|
4848
|
-
# "total": 1,
|
4849
|
-
# "total_page": 1
|
4850
|
-
# },
|
4851
|
-
# "message": "Success"
|
4852
|
-
# }
|
4797
|
+
request['limit'] = limit
|
4798
|
+
response = await self.v2PrivateGetAssetsDepositHistory(self.extend(request, params))
|
4853
4799
|
#
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4800
|
+
# {
|
4801
|
+
# "data": [
|
4802
|
+
# {
|
4803
|
+
# "deposit_id": 5173806,
|
4804
|
+
# "created_at": 1714021652557,
|
4805
|
+
# "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
|
4806
|
+
# "tx_id_display": "",
|
4807
|
+
# "ccy": "USDT",
|
4808
|
+
# "chain": "TRC20",
|
4809
|
+
# "deposit_method": "ON_CHAIN",
|
4810
|
+
# "amount": "30",
|
4811
|
+
# "actual_amount": "",
|
4812
|
+
# "to_address": "TYewD2pVWDUwfNr9A",
|
4813
|
+
# "confirmations": 20,
|
4814
|
+
# "status": "FINISHED",
|
4815
|
+
# "tx_explorer_url": "https://tronscan.org/#/transaction",
|
4816
|
+
# "to_addr_explorer_url": "https://tronscan.org/#/address",
|
4817
|
+
# "remark": ""
|
4818
|
+
# },
|
4819
|
+
# ],
|
4820
|
+
# "paginatation": {
|
4821
|
+
# "total": 8,
|
4822
|
+
# "has_next": True
|
4823
|
+
# },
|
4824
|
+
# "code": 0,
|
4825
|
+
# "message": "OK"
|
4826
|
+
# }
|
4827
|
+
#
|
4828
|
+
data = self.safe_list(response, 'data', [])
|
4857
4829
|
return self.parse_transactions(data, currency, since, limit)
|
4858
4830
|
|
4859
4831
|
def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
|
4860
4832
|
#
|
4861
4833
|
# {
|
4862
4834
|
# "market": "BTCUSDT",
|
4835
|
+
# "ccy": "USDT",
|
4863
4836
|
# "leverage": 10,
|
4864
|
-
# "
|
4865
|
-
#
|
4866
|
-
#
|
4867
|
-
#
|
4868
|
-
# },
|
4869
|
-
# "USDT": {
|
4870
|
-
# "min_amount": "60",
|
4871
|
-
# "max_amount": "5000000",
|
4872
|
-
# "day_rate": "0.001"
|
4873
|
-
# }
|
4874
|
-
# },
|
4837
|
+
# "min_amount": "60",
|
4838
|
+
# "max_amount": "500000",
|
4839
|
+
# "daily_interest_rate": "0.001"
|
4840
|
+
# }
|
4875
4841
|
#
|
4876
4842
|
marketId = self.safe_string(info, 'market')
|
4877
4843
|
market = self.safe_market(marketId, market, None, 'spot')
|
4878
|
-
|
4879
|
-
|
4844
|
+
currency = self.safe_string(info, 'ccy')
|
4845
|
+
rate = self.safe_number(info, 'daily_interest_rate')
|
4846
|
+
baseRate = None
|
4847
|
+
quoteRate = None
|
4848
|
+
if currency == market['baseId']:
|
4849
|
+
baseRate = rate
|
4850
|
+
elif currency == market['quoteId']:
|
4851
|
+
quoteRate = rate
|
4880
4852
|
return {
|
4881
4853
|
'symbol': market['symbol'],
|
4882
4854
|
'base': market['base'],
|
4883
|
-
'baseRate':
|
4855
|
+
'baseRate': baseRate,
|
4884
4856
|
'quote': market['quote'],
|
4885
|
-
'quoteRate':
|
4857
|
+
'quoteRate': quoteRate,
|
4886
4858
|
'period': 86400000,
|
4887
4859
|
'timestamp': None,
|
4888
4860
|
'datetime': None,
|
@@ -4892,153 +4864,116 @@ class coinex(Exchange, ImplicitAPI):
|
|
4892
4864
|
async def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
|
4893
4865
|
"""
|
4894
4866
|
fetch the rate of interest to borrow a currency for margin trading
|
4895
|
-
:see: https://
|
4867
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
|
4896
4868
|
:param str symbol: unified symbol of the market to fetch the borrow rate for
|
4897
4869
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4870
|
+
:param str params['code']: unified currency code
|
4898
4871
|
:returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
|
4899
4872
|
"""
|
4900
4873
|
await self.load_markets()
|
4874
|
+
code = self.safe_string(params, 'code')
|
4875
|
+
if code is None:
|
4876
|
+
raise ArgumentsRequired(self.id + ' fetchIsolatedBorrowRate() requires a code parameter')
|
4877
|
+
params = self.omit(params, 'code')
|
4878
|
+
currency = self.currency(code)
|
4901
4879
|
market = self.market(symbol)
|
4902
|
-
request = {
|
4880
|
+
request: dict = {
|
4903
4881
|
'market': market['id'],
|
4882
|
+
'ccy': currency['id'],
|
4904
4883
|
}
|
4905
|
-
response = await self.
|
4884
|
+
response = await self.v2PrivateGetAssetsMarginInterestLimit(self.extend(request, params))
|
4906
4885
|
#
|
4907
4886
|
# {
|
4908
4887
|
# "code": 0,
|
4909
4888
|
# "data": {
|
4910
4889
|
# "market": "BTCUSDT",
|
4890
|
+
# "ccy": "USDT",
|
4911
4891
|
# "leverage": 10,
|
4912
|
-
# "
|
4913
|
-
#
|
4914
|
-
#
|
4915
|
-
# "day_rate": "0.001"
|
4916
|
-
# },
|
4917
|
-
# "USDT": {
|
4918
|
-
# "min_amount": "60",
|
4919
|
-
# "max_amount": "5000000",
|
4920
|
-
# "day_rate": "0.001"
|
4921
|
-
# }
|
4892
|
+
# "min_amount": "60",
|
4893
|
+
# "max_amount": "500000",
|
4894
|
+
# "daily_interest_rate": "0.001"
|
4922
4895
|
# },
|
4923
|
-
# "message": "
|
4896
|
+
# "message": "OK"
|
4924
4897
|
# }
|
4925
4898
|
#
|
4926
|
-
data = self.
|
4899
|
+
data = self.safe_dict(response, 'data', {})
|
4927
4900
|
return self.parse_isolated_borrow_rate(data, market)
|
4928
4901
|
|
4929
|
-
async def
|
4902
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4930
4903
|
"""
|
4931
|
-
fetch the
|
4932
|
-
:see: https://
|
4904
|
+
fetch the interest owed by the user for borrowing currency for margin trading
|
4905
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
|
4906
|
+
:param str [code]: unified currency code
|
4907
|
+
:param str [symbol]: unified market symbol when fetch interest in isolated markets
|
4908
|
+
:param int [since]: the earliest time in ms to fetch borrrow interest for
|
4909
|
+
:param int [limit]: the maximum number of structures to retrieve
|
4933
4910
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4934
|
-
:returns dict: a list of `
|
4911
|
+
:returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
|
4935
4912
|
"""
|
4936
4913
|
await self.load_markets()
|
4937
|
-
|
4938
|
-
#
|
4939
|
-
# {
|
4940
|
-
# "code": 0,
|
4941
|
-
# "data": [
|
4942
|
-
# {
|
4943
|
-
# "market": "BTCUSDT",
|
4944
|
-
# "leverage": 10,
|
4945
|
-
# "BTC": {
|
4946
|
-
# "min_amount": "0.002",
|
4947
|
-
# "max_amount": "200",
|
4948
|
-
# "day_rate": "0.001"
|
4949
|
-
# },
|
4950
|
-
# "USDT": {
|
4951
|
-
# "min_amount": "60",
|
4952
|
-
# "max_amount": "5000000",
|
4953
|
-
# "day_rate": "0.001"
|
4954
|
-
# }
|
4955
|
-
# },
|
4956
|
-
# ],
|
4957
|
-
# "message": "Success"
|
4958
|
-
# }
|
4959
|
-
#
|
4960
|
-
data = self.safe_value(response, 'data', [])
|
4961
|
-
return self.parse_isolated_borrow_rates(data)
|
4962
|
-
|
4963
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4964
|
-
await self.load_markets()
|
4965
|
-
request = {}
|
4914
|
+
request: dict = {}
|
4966
4915
|
market = None
|
4967
4916
|
if symbol is not None:
|
4968
4917
|
market = self.market(symbol)
|
4969
4918
|
request['market'] = market['id']
|
4970
4919
|
if limit is not None:
|
4971
4920
|
request['limit'] = limit
|
4972
|
-
response = await self.
|
4921
|
+
response = await self.v2PrivateGetAssetsMarginBorrowHistory(self.extend(request, params))
|
4973
4922
|
#
|
4974
4923
|
# {
|
4975
|
-
# "
|
4976
|
-
#
|
4977
|
-
#
|
4978
|
-
#
|
4979
|
-
#
|
4980
|
-
#
|
4981
|
-
#
|
4982
|
-
#
|
4983
|
-
#
|
4984
|
-
#
|
4985
|
-
#
|
4986
|
-
#
|
4987
|
-
#
|
4988
|
-
#
|
4989
|
-
#
|
4990
|
-
#
|
4991
|
-
#
|
4992
|
-
# "unflat_amount": "0",
|
4993
|
-
# "expire_time": 1655078027,
|
4994
|
-
# "is_renew": True,
|
4995
|
-
# "status": "finish"
|
4996
|
-
# }
|
4997
|
-
# ],
|
4998
|
-
# "total_page": 1
|
4924
|
+
# "data": [
|
4925
|
+
# {
|
4926
|
+
# "borrow_id": 2642934,
|
4927
|
+
# "created_at": 1654761016000,
|
4928
|
+
# "market": "BTCUSDT",
|
4929
|
+
# "ccy": "USDT",
|
4930
|
+
# "daily_interest_rate": "0.001",
|
4931
|
+
# "expired_at": 1655625016000,
|
4932
|
+
# "borrow_amount": "100",
|
4933
|
+
# "to_repaied_amount": "0",
|
4934
|
+
# "is_auto_renew": False,
|
4935
|
+
# "status": "finish"
|
4936
|
+
# },
|
4937
|
+
# ],
|
4938
|
+
# "pagination": {
|
4939
|
+
# "total": 4,
|
4940
|
+
# "has_next": True
|
4999
4941
|
# },
|
5000
|
-
# "
|
4942
|
+
# "code": 0,
|
4943
|
+
# "message": "OK"
|
5001
4944
|
# }
|
5002
4945
|
#
|
5003
|
-
|
5004
|
-
rows = self.safe_value(data, 'data', [])
|
4946
|
+
rows = self.safe_value(response, 'data', [])
|
5005
4947
|
interest = self.parse_borrow_interests(rows, market)
|
5006
4948
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
5007
4949
|
|
5008
|
-
def parse_borrow_interest(self, info, market: Market = None):
|
4950
|
+
def parse_borrow_interest(self, info: dict, market: Market = None):
|
5009
4951
|
#
|
5010
4952
|
# {
|
5011
|
-
# "
|
5012
|
-
# "
|
5013
|
-
# "
|
5014
|
-
# "
|
5015
|
-
# "
|
5016
|
-
# "
|
5017
|
-
# "
|
5018
|
-
# "
|
5019
|
-
# "
|
5020
|
-
# "is_renew": True,
|
4953
|
+
# "borrow_id": 2642934,
|
4954
|
+
# "created_at": 1654761016000,
|
4955
|
+
# "market": "BTCUSDT",
|
4956
|
+
# "ccy": "USDT",
|
4957
|
+
# "daily_interest_rate": "0.001",
|
4958
|
+
# "expired_at": 1655625016000,
|
4959
|
+
# "borrow_amount": "100",
|
4960
|
+
# "to_repaied_amount": "0",
|
4961
|
+
# "is_auto_renew": False,
|
5021
4962
|
# "status": "finish"
|
5022
4963
|
# }
|
5023
4964
|
#
|
5024
|
-
marketId = self.safe_string(info, '
|
4965
|
+
marketId = self.safe_string(info, 'market')
|
5025
4966
|
market = self.safe_market(marketId, market, None, 'spot')
|
5026
|
-
|
5027
|
-
timestamp = self.safe_timestamp(info, 'expire_time')
|
5028
|
-
unflatAmount = self.safe_string(info, 'unflat_amount')
|
5029
|
-
loanAmount = self.safe_string(info, 'loan_amount')
|
5030
|
-
interest = Precise.string_sub(unflatAmount, loanAmount)
|
5031
|
-
if unflatAmount == '0':
|
5032
|
-
interest = None
|
4967
|
+
timestamp = self.safe_integer(info, 'expired_at')
|
5033
4968
|
return {
|
5034
4969
|
'account': None, # deprecated
|
5035
|
-
'symbol': symbol,
|
4970
|
+
'symbol': market['symbol'],
|
5036
4971
|
'marginMode': 'isolated',
|
5037
4972
|
'marginType': None, # deprecated
|
5038
|
-
'currency': self.safe_currency_code(self.safe_string(info, '
|
5039
|
-
'interest': self.
|
5040
|
-
'interestRate': self.safe_number(info, '
|
5041
|
-
'amountBorrowed': self.
|
4973
|
+
'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
|
4974
|
+
'interest': self.safe_number(info, 'to_repaied_amount'),
|
4975
|
+
'interestRate': self.safe_number(info, 'daily_interest_rate'),
|
4976
|
+
'amountBorrowed': self.safe_number(info, 'borrow_amount'),
|
5042
4977
|
'timestamp': timestamp, # expiry time
|
5043
4978
|
'datetime': self.iso8601(timestamp),
|
5044
4979
|
'info': info,
|
@@ -5047,32 +4982,43 @@ class coinex(Exchange, ImplicitAPI):
|
|
5047
4982
|
async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
5048
4983
|
"""
|
5049
4984
|
create a loan to borrow margin
|
5050
|
-
:see: https://
|
4985
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
|
5051
4986
|
:param str symbol: unified market symbol, required for coinex
|
5052
4987
|
:param str code: unified currency code of the currency to borrow
|
5053
4988
|
:param float amount: the amount to borrow
|
5054
4989
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4990
|
+
:param boolean [params.isAutoRenew]: whether to renew the margin loan automatically or not, default is False
|
5055
4991
|
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
5056
4992
|
"""
|
5057
4993
|
await self.load_markets()
|
5058
4994
|
market = self.market(symbol)
|
5059
4995
|
currency = self.currency(code)
|
5060
|
-
|
4996
|
+
isAutoRenew = self.safe_bool_2(params, 'isAutoRenew', 'is_auto_renew', False)
|
4997
|
+
params = self.omit(params, 'isAutoRenew')
|
4998
|
+
request: dict = {
|
5061
4999
|
'market': market['id'],
|
5062
|
-
'
|
5063
|
-
'
|
5000
|
+
'ccy': currency['id'],
|
5001
|
+
'borrow_amount': self.currency_to_precision(code, amount),
|
5002
|
+
'is_auto_renew': isAutoRenew,
|
5064
5003
|
}
|
5065
|
-
response = await self.
|
5004
|
+
response = await self.v2PrivatePostAssetsMarginBorrow(self.extend(request, params))
|
5066
5005
|
#
|
5067
5006
|
# {
|
5068
5007
|
# "code": 0,
|
5069
5008
|
# "data": {
|
5070
|
-
# "
|
5009
|
+
# "borrow_id": 13784021,
|
5010
|
+
# "market": "BTCUSDT",
|
5011
|
+
# "ccy": "USDT",
|
5012
|
+
# "daily_interest_rate": "0.001",
|
5013
|
+
# "expired_at": 1717299948340,
|
5014
|
+
# "borrow_amount": "60",
|
5015
|
+
# "to_repaied_amount": "60.0025",
|
5016
|
+
# "status": "loan"
|
5071
5017
|
# },
|
5072
|
-
# "message": "
|
5018
|
+
# "message": "OK"
|
5073
5019
|
# }
|
5074
5020
|
#
|
5075
|
-
data = self.
|
5021
|
+
data = self.safe_dict(response, 'data', {})
|
5076
5022
|
transaction = self.parse_margin_loan(data, currency)
|
5077
5023
|
return self.extend(transaction, {
|
5078
5024
|
'amount': amount,
|
@@ -5082,149 +5028,179 @@ class coinex(Exchange, ImplicitAPI):
|
|
5082
5028
|
async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
5083
5029
|
"""
|
5084
5030
|
repay borrowed margin and interest
|
5085
|
-
:see: https://
|
5031
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
|
5086
5032
|
:param str symbol: unified market symbol, required for coinex
|
5087
5033
|
:param str code: unified currency code of the currency to repay
|
5088
5034
|
:param float amount: the amount to repay
|
5089
5035
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5090
|
-
:param str [params.
|
5036
|
+
:param str [params.borrow_id]: extra parameter that is not required
|
5091
5037
|
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
5092
5038
|
"""
|
5093
5039
|
await self.load_markets()
|
5094
5040
|
market = self.market(symbol)
|
5095
5041
|
currency = self.currency(code)
|
5096
|
-
request = {
|
5042
|
+
request: dict = {
|
5097
5043
|
'market': market['id'],
|
5098
|
-
'
|
5044
|
+
'ccy': currency['id'],
|
5099
5045
|
'amount': self.currency_to_precision(code, amount),
|
5100
5046
|
}
|
5101
|
-
response = await self.
|
5047
|
+
response = await self.v2PrivatePostAssetsMarginRepay(self.extend(request, params))
|
5102
5048
|
#
|
5103
5049
|
# {
|
5104
5050
|
# "code": 0,
|
5105
|
-
# "data":
|
5106
|
-
# "message": "
|
5051
|
+
# "data": {},
|
5052
|
+
# "message": "OK"
|
5107
5053
|
# }
|
5108
5054
|
#
|
5109
|
-
|
5055
|
+
data = self.safe_dict(response, 'data', {})
|
5056
|
+
transaction = self.parse_margin_loan(data, currency)
|
5110
5057
|
return self.extend(transaction, {
|
5111
5058
|
'amount': amount,
|
5112
5059
|
'symbol': symbol,
|
5113
5060
|
})
|
5114
5061
|
|
5115
5062
|
def parse_margin_loan(self, info, currency: Currency = None):
|
5116
|
-
#
|
5117
|
-
# borrowMargin
|
5118
|
-
#
|
5119
|
-
# {
|
5120
|
-
# "loan_id": 1670
|
5121
|
-
# }
|
5122
|
-
#
|
5123
|
-
# repayMargin
|
5124
5063
|
#
|
5125
5064
|
# {
|
5126
|
-
# "
|
5127
|
-
# "
|
5128
|
-
# "
|
5065
|
+
# "borrow_id": 13784021,
|
5066
|
+
# "market": "BTCUSDT",
|
5067
|
+
# "ccy": "USDT",
|
5068
|
+
# "daily_interest_rate": "0.001",
|
5069
|
+
# "expired_at": 1717299948340,
|
5070
|
+
# "borrow_amount": "60",
|
5071
|
+
# "to_repaied_amount": "60.0025",
|
5072
|
+
# "status": "loan"
|
5129
5073
|
# }
|
5130
5074
|
#
|
5075
|
+
currencyId = self.safe_string(info, 'ccy')
|
5076
|
+
marketId = self.safe_string(info, 'market')
|
5077
|
+
timestamp = self.safe_integer(info, 'expired_at')
|
5131
5078
|
return {
|
5132
|
-
'id': self.safe_integer(info, '
|
5133
|
-
'currency': self.safe_currency_code(
|
5134
|
-
'amount':
|
5135
|
-
'symbol': None,
|
5136
|
-
'timestamp':
|
5137
|
-
'datetime':
|
5079
|
+
'id': self.safe_integer(info, 'borrow_id'),
|
5080
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
5081
|
+
'amount': self.safe_string(info, 'borrow_amount'),
|
5082
|
+
'symbol': self.safe_symbol(marketId, None, None, 'spot'),
|
5083
|
+
'timestamp': timestamp,
|
5084
|
+
'datetime': self.iso8601(timestamp),
|
5138
5085
|
'info': info,
|
5139
5086
|
}
|
5140
5087
|
|
5141
|
-
async def
|
5088
|
+
async def fetch_deposit_withdraw_fee(self, code: str, params={}):
|
5142
5089
|
"""
|
5143
|
-
fetch
|
5144
|
-
:see: https://
|
5145
|
-
:param str
|
5090
|
+
fetch the fee for deposits and withdrawals
|
5091
|
+
:see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
|
5092
|
+
:param str code: unified currency code
|
5146
5093
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5147
|
-
:returns dict
|
5094
|
+
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
5148
5095
|
"""
|
5149
5096
|
await self.load_markets()
|
5150
|
-
|
5151
|
-
|
5152
|
-
|
5153
|
-
|
5154
|
-
|
5155
|
-
|
5156
|
-
#
|
5157
|
-
#
|
5158
|
-
#
|
5159
|
-
#
|
5160
|
-
#
|
5161
|
-
#
|
5162
|
-
#
|
5163
|
-
#
|
5164
|
-
#
|
5165
|
-
#
|
5166
|
-
#
|
5167
|
-
#
|
5168
|
-
#
|
5169
|
-
#
|
5170
|
-
#
|
5171
|
-
#
|
5172
|
-
#
|
5173
|
-
#
|
5174
|
-
#
|
5175
|
-
#
|
5176
|
-
#
|
5177
|
-
#
|
5178
|
-
#
|
5179
|
-
#
|
5180
|
-
#
|
5181
|
-
#
|
5182
|
-
|
5097
|
+
currency = self.currency(code)
|
5098
|
+
request: dict = {
|
5099
|
+
'ccy': currency['id'],
|
5100
|
+
}
|
5101
|
+
response = await self.v2PrivateGetAssetsDepositWithdrawConfig(self.extend(request, params))
|
5102
|
+
#
|
5103
|
+
# {
|
5104
|
+
# "code": 0,
|
5105
|
+
# "data": {
|
5106
|
+
# "asset": {
|
5107
|
+
# "ccy": "USDT",
|
5108
|
+
# "deposit_enabled": True,
|
5109
|
+
# "withdraw_enabled": True,
|
5110
|
+
# "inter_transfer_enabled": True,
|
5111
|
+
# "is_st": False
|
5112
|
+
# },
|
5113
|
+
# "chains": [
|
5114
|
+
# {
|
5115
|
+
# "chain": "TRC20",
|
5116
|
+
# "min_deposit_amount": "2.4",
|
5117
|
+
# "min_withdraw_amount": "2.4",
|
5118
|
+
# "deposit_enabled": True,
|
5119
|
+
# "withdraw_enabled": True,
|
5120
|
+
# "deposit_delay_minutes": 0,
|
5121
|
+
# "safe_confirmations": 10,
|
5122
|
+
# "irreversible_confirmations": 20,
|
5123
|
+
# "deflation_rate": "0",
|
5124
|
+
# "withdrawal_fee": "2.4",
|
5125
|
+
# "withdrawal_precision": 6,
|
5126
|
+
# "memo": "",
|
5127
|
+
# "is_memo_required_for_deposit": False,
|
5128
|
+
# "explorer_asset_url": "https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
|
5129
|
+
# },
|
5130
|
+
# ]
|
5131
|
+
# },
|
5132
|
+
# "message": "OK"
|
5133
|
+
# }
|
5134
|
+
#
|
5135
|
+
data = self.safe_dict(response, 'data', {})
|
5136
|
+
return self.parse_deposit_withdraw_fee(data, currency)
|
5183
5137
|
|
5184
|
-
def
|
5185
|
-
|
5186
|
-
|
5187
|
-
|
5188
|
-
|
5189
|
-
|
5190
|
-
|
5191
|
-
|
5192
|
-
|
5193
|
-
|
5194
|
-
|
5195
|
-
|
5196
|
-
|
5197
|
-
|
5198
|
-
|
5199
|
-
|
5200
|
-
|
5201
|
-
|
5202
|
-
|
5203
|
-
|
5204
|
-
|
5205
|
-
|
5206
|
-
|
5207
|
-
|
5208
|
-
|
5209
|
-
|
5210
|
-
|
5211
|
-
|
5212
|
-
|
5213
|
-
|
5214
|
-
|
5215
|
-
|
5138
|
+
def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
|
5139
|
+
#
|
5140
|
+
# {
|
5141
|
+
# "asset": {
|
5142
|
+
# "ccy": "USDT",
|
5143
|
+
# "deposit_enabled": True,
|
5144
|
+
# "withdraw_enabled": True,
|
5145
|
+
# "inter_transfer_enabled": True,
|
5146
|
+
# "is_st": False
|
5147
|
+
# },
|
5148
|
+
# "chains": [
|
5149
|
+
# {
|
5150
|
+
# "chain": "TRC20",
|
5151
|
+
# "min_deposit_amount": "2.4",
|
5152
|
+
# "min_withdraw_amount": "2.4",
|
5153
|
+
# "deposit_enabled": True,
|
5154
|
+
# "withdraw_enabled": True,
|
5155
|
+
# "deposit_delay_minutes": 0,
|
5156
|
+
# "safe_confirmations": 10,
|
5157
|
+
# "irreversible_confirmations": 20,
|
5158
|
+
# "deflation_rate": "0",
|
5159
|
+
# "withdrawal_fee": "2.4",
|
5160
|
+
# "withdrawal_precision": 6,
|
5161
|
+
# "memo": "",
|
5162
|
+
# "is_memo_required_for_deposit": False,
|
5163
|
+
# "explorer_asset_url": "https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
|
5164
|
+
# },
|
5165
|
+
# ]
|
5166
|
+
# }
|
5167
|
+
#
|
5168
|
+
result: dict = {
|
5169
|
+
'info': fee,
|
5170
|
+
'withdraw': {
|
5171
|
+
'fee': None,
|
5172
|
+
'percentage': None,
|
5173
|
+
},
|
5174
|
+
'deposit': {
|
5175
|
+
'fee': None,
|
5176
|
+
'percentage': None,
|
5177
|
+
},
|
5178
|
+
'networks': {},
|
5179
|
+
}
|
5180
|
+
chains = self.safe_list(fee, 'chains', [])
|
5181
|
+
asset = self.safe_dict(fee, 'asset', {})
|
5182
|
+
for i in range(0, len(chains)):
|
5183
|
+
entry = chains[i]
|
5184
|
+
isWithdrawEnabled = self.safe_bool(entry, 'withdraw_enabled')
|
5185
|
+
if isWithdrawEnabled:
|
5186
|
+
result['withdraw']['fee'] = self.safe_number(entry, 'withdrawal_fee')
|
5187
|
+
result['withdraw']['percentage'] = False
|
5188
|
+
networkId = self.safe_string(entry, 'chain')
|
5189
|
+
if networkId:
|
5190
|
+
networkCode = self.network_id_to_code(networkId, self.safe_string(asset, 'ccy'))
|
5191
|
+
result['networks'][networkCode] = {
|
5192
|
+
'withdraw': {
|
5193
|
+
'fee': self.safe_number(entry, 'withdrawal_fee'),
|
5194
|
+
'percentage': False,
|
5195
|
+
},
|
5196
|
+
'deposit': {
|
5197
|
+
'fee': None,
|
5198
|
+
'percentage': None,
|
5199
|
+
},
|
5216
5200
|
}
|
5217
|
-
|
5218
|
-
depositWithdrawFees[code]['withdraw'] = withdrawResult
|
5219
|
-
depositWithdrawFees[code]['deposit'] = depositResult
|
5220
|
-
depositWithdrawCodes = list(depositWithdrawFees.keys())
|
5221
|
-
for i in range(0, len(depositWithdrawCodes)):
|
5222
|
-
code = depositWithdrawCodes[i]
|
5223
|
-
currency = self.currency(code)
|
5224
|
-
depositWithdrawFees[code] = self.assign_default_deposit_withdraw_fees(depositWithdrawFees[code], currency)
|
5225
|
-
return depositWithdrawFees
|
5201
|
+
return result
|
5226
5202
|
|
5227
|
-
async def fetch_leverages(self, symbols:
|
5203
|
+
async def fetch_leverages(self, symbols: Strings = None, params={}) -> Leverages:
|
5228
5204
|
"""
|
5229
5205
|
fetch the set leverage for all contract and margin markets
|
5230
5206
|
:see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
|
@@ -5292,7 +5268,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5292
5268
|
"""
|
5293
5269
|
await self.load_markets()
|
5294
5270
|
market = self.market(symbol)
|
5295
|
-
request = {
|
5271
|
+
request: dict = {
|
5296
5272
|
'market_type': 'FUTURES',
|
5297
5273
|
'market': market['id'],
|
5298
5274
|
}
|
@@ -5495,7 +5471,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5495
5471
|
if positionId is None:
|
5496
5472
|
raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter')
|
5497
5473
|
market = self.market(symbol)
|
5498
|
-
request = {
|
5474
|
+
request: dict = {
|
5499
5475
|
'market': market['id'],
|
5500
5476
|
'market_type': 'FUTURES',
|
5501
5477
|
'position_id': positionId,
|