ccxt 4.3.29__py2.py3-none-any.whl → 4.3.30__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/base/ws/aiohttp_client.py +1 -0
- ccxt/async_support/base/ws/future.py +27 -29
- ccxt/async_support/bingx.py +1 -1
- ccxt/async_support/coinex.py +254 -307
- ccxt/async_support/whitebit.py +43 -3
- ccxt/base/exchange.py +5 -1
- ccxt/bingx.py +1 -1
- ccxt/coinex.py +254 -307
- ccxt/pro/__init__.py +1 -1
- ccxt/whitebit.py +43 -3
- {ccxt-4.3.29.dist-info → ccxt-4.3.30.dist-info}/METADATA +4 -4
- {ccxt-4.3.29.dist-info → ccxt-4.3.30.dist-info}/RECORD +17 -17
- {ccxt-4.3.29.dist-info → ccxt-4.3.30.dist-info}/WHEEL +0 -0
- {ccxt-4.3.29.dist-info → ccxt-4.3.30.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, 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
|
@@ -90,7 +90,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
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,
|
@@ -4502,107 +4502,98 @@ class coinex(Exchange, ImplicitAPI):
|
|
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
|
-
# "tx_fee": "0.001",
|
4552
|
-
# "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
|
4553
|
-
# }
|
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
|
+
# }
|
4554
4545
|
#
|
4555
|
-
|
4556
|
-
|
4557
|
-
tag = self.safe_string(transaction, 'remark') # set but unused
|
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
|
|
@@ -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
|
"""
|
4736
|
+
await self.load_markets()
|
4745
4737
|
request = {}
|
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.
|
4743
|
+
request['limit'] = limit
|
4744
|
+
response = await self.v2PrivateGetAssetsWithdraw(self.extend(request, params))
|
4754
4745
|
#
|
4755
|
-
#
|
4756
|
-
#
|
4757
|
-
#
|
4758
|
-
#
|
4759
|
-
#
|
4760
|
-
#
|
4761
|
-
#
|
4762
|
-
#
|
4763
|
-
#
|
4764
|
-
#
|
4765
|
-
#
|
4766
|
-
#
|
4767
|
-
#
|
4768
|
-
#
|
4769
|
-
#
|
4770
|
-
#
|
4771
|
-
#
|
4772
|
-
#
|
4773
|
-
#
|
4774
|
-
#
|
4775
|
-
#
|
4776
|
-
#
|
4777
|
-
#
|
4778
|
-
#
|
4779
|
-
#
|
4780
|
-
#
|
4781
|
-
#
|
4782
|
-
#
|
4783
|
-
#
|
4784
|
-
#
|
4785
|
-
# ],
|
4786
|
-
# "total": 1,
|
4787
|
-
# "total_page": 1
|
4788
|
-
# },
|
4789
|
-
# "message": "Success"
|
4790
|
-
# }
|
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
|
+
# }
|
4791
4776
|
#
|
4792
|
-
data = self.
|
4793
|
-
if not isinstance(data, list):
|
4794
|
-
data = self.safe_value(data, 'data', [])
|
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
|
"""
|
4790
|
+
await self.load_markets()
|
4807
4791
|
request = {}
|
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.
|
4797
|
+
request['limit'] = limit
|
4798
|
+
response = await self.v2PrivateGetAssetsDepositHistory(self.extend(request, params))
|
4816
4799
|
#
|
4817
|
-
#
|
4818
|
-
#
|
4819
|
-
#
|
4820
|
-
#
|
4821
|
-
#
|
4822
|
-
#
|
4823
|
-
#
|
4824
|
-
#
|
4825
|
-
#
|
4826
|
-
#
|
4827
|
-
#
|
4828
|
-
#
|
4829
|
-
#
|
4830
|
-
#
|
4831
|
-
#
|
4832
|
-
#
|
4833
|
-
#
|
4834
|
-
#
|
4835
|
-
#
|
4836
|
-
#
|
4837
|
-
#
|
4838
|
-
#
|
4839
|
-
#
|
4840
|
-
#
|
4841
|
-
#
|
4842
|
-
#
|
4843
|
-
#
|
4844
|
-
# "remark": "",
|
4845
|
-
# "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
4846
|
-
# }
|
4847
|
-
# ],
|
4848
|
-
# "total": 1,
|
4849
|
-
# "total_page": 1
|
4850
|
-
# },
|
4851
|
-
# "message": "Success"
|
4852
|
-
# }
|
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
|
+
# }
|
4853
4827
|
#
|
4854
|
-
data = self.
|
4855
|
-
if not isinstance(data, list):
|
4856
|
-
data = self.safe_value(data, 'data', [])
|
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,75 +4864,52 @@ 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
4880
|
request = {
|
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
|
-
await self.load_markets()
|
4937
|
-
response = await self.v1PrivateGetMarginConfig(params)
|
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
4913
|
await self.load_markets()
|
4965
4914
|
request = {}
|
4966
4915
|
market = None
|
@@ -4969,76 +4918,62 @@ class coinex(Exchange, ImplicitAPI):
|
|
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
4950
|
def parse_borrow_interest(self, info, 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)
|
4996
|
+
isAutoRenew = self.safe_bool_2(params, 'isAutoRenew', 'is_auto_renew', False)
|
4997
|
+
params = self.omit(params, 'isAutoRenew')
|
5060
4998
|
request = {
|
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,12 +5028,12 @@ 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()
|
@@ -5095,46 +5041,47 @@ class coinex(Exchange, ImplicitAPI):
|
|
5095
5041
|
currency = self.currency(code)
|
5096
5042
|
request = {
|
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
5063
|
#
|
5119
5064
|
# {
|
5120
|
-
# "
|
5121
|
-
#
|
5122
|
-
#
|
5123
|
-
#
|
5124
|
-
#
|
5125
|
-
#
|
5126
|
-
# "
|
5127
|
-
# "
|
5128
|
-
# "message": "Success"
|
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
|
|