ccxt 4.3.28__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/abstract/bingx.py +88 -81
- ccxt/abstract/bitmart.py +1 -0
- 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/base/ws/order_book_side.py +3 -0
- ccxt/async_support/bingx.py +98 -84
- ccxt/async_support/bitmart.py +65 -1
- ccxt/async_support/coinex.py +254 -307
- ccxt/async_support/kucoin.py +1 -0
- ccxt/async_support/whitebit.py +44 -4
- ccxt/base/exchange.py +5 -1
- ccxt/bingx.py +98 -84
- ccxt/bitmart.py +65 -1
- ccxt/coinex.py +254 -307
- ccxt/kucoin.py +1 -0
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitfinex.py +4 -4
- ccxt/pro/bitfinex2.py +2 -2
- ccxt/pro/bitmex.py +3 -3
- ccxt/pro/blockchaincom.py +2 -2
- ccxt/pro/cryptocom.py +4 -4
- ccxt/pro/deribit.py +9 -9
- ccxt/pro/idex.py +1 -1
- ccxt/pro/luno.py +4 -5
- ccxt/pro/mexc.py +2 -2
- ccxt/whitebit.py +44 -4
- {ccxt-4.3.28.dist-info → ccxt-4.3.30.dist-info}/METADATA +4 -4
- {ccxt-4.3.28.dist-info → ccxt-4.3.30.dist-info}/RECORD +33 -33
- {ccxt-4.3.28.dist-info → ccxt-4.3.30.dist-info}/WHEEL +0 -0
- {ccxt-4.3.28.dist-info → ccxt-4.3.30.dist-info}/top_level.txt +0 -0
ccxt/coinex.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinex import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate,
|
8
|
+
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
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import ExchangeError
|
11
11
|
from ccxt.base.errors import AuthenticationError
|
@@ -89,7 +89,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
89
89
|
'fetchFundingRates': True,
|
90
90
|
'fetchIndexOHLCV': False,
|
91
91
|
'fetchIsolatedBorrowRate': True,
|
92
|
-
'fetchIsolatedBorrowRates':
|
92
|
+
'fetchIsolatedBorrowRates': False,
|
93
93
|
'fetchLeverage': 'emulated',
|
94
94
|
'fetchLeverages': True,
|
95
95
|
'fetchLeverageTiers': True,
|
@@ -4501,107 +4501,98 @@ class coinex(Exchange, ImplicitAPI):
|
|
4501
4501
|
#
|
4502
4502
|
# fetchDeposits
|
4503
4503
|
#
|
4504
|
-
#
|
4505
|
-
#
|
4506
|
-
#
|
4507
|
-
#
|
4508
|
-
#
|
4509
|
-
#
|
4510
|
-
#
|
4511
|
-
#
|
4512
|
-
#
|
4513
|
-
#
|
4514
|
-
#
|
4515
|
-
#
|
4516
|
-
#
|
4517
|
-
#
|
4518
|
-
#
|
4519
|
-
#
|
4520
|
-
#
|
4521
|
-
# "transfer_method": "onchain",
|
4522
|
-
# "status": "finish",
|
4523
|
-
# "status_display": "finish",
|
4524
|
-
# "remark": "",
|
4525
|
-
# "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
4526
|
-
# }
|
4504
|
+
# {
|
4505
|
+
# "deposit_id": 5173806,
|
4506
|
+
# "created_at": 1714021652557,
|
4507
|
+
# "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
|
4508
|
+
# "tx_id_display": "",
|
4509
|
+
# "ccy": "USDT",
|
4510
|
+
# "chain": "TRC20",
|
4511
|
+
# "deposit_method": "ON_CHAIN",
|
4512
|
+
# "amount": "30",
|
4513
|
+
# "actual_amount": "",
|
4514
|
+
# "to_address": "TYewD2pVWDUwfNr9A",
|
4515
|
+
# "confirmations": 20,
|
4516
|
+
# "status": "FINISHED",
|
4517
|
+
# "tx_explorer_url": "https://tronscan.org/#/transaction",
|
4518
|
+
# "to_addr_explorer_url": "https://tronscan.org/#/address",
|
4519
|
+
# "remark": ""
|
4520
|
+
# }
|
4527
4521
|
#
|
4528
4522
|
# fetchWithdrawals
|
4529
4523
|
#
|
4530
|
-
#
|
4531
|
-
#
|
4532
|
-
#
|
4533
|
-
#
|
4534
|
-
#
|
4535
|
-
#
|
4536
|
-
#
|
4537
|
-
#
|
4538
|
-
#
|
4539
|
-
#
|
4540
|
-
#
|
4541
|
-
#
|
4542
|
-
#
|
4543
|
-
#
|
4544
|
-
#
|
4545
|
-
#
|
4546
|
-
#
|
4547
|
-
#
|
4548
|
-
#
|
4549
|
-
#
|
4550
|
-
# "tx_fee": "0.001",
|
4551
|
-
# "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
|
4552
|
-
# }
|
4524
|
+
# {
|
4525
|
+
# "withdraw_id": 259364,
|
4526
|
+
# "created_at": 1701323541548,
|
4527
|
+
# "withdraw_method": "ON_CHAIN",
|
4528
|
+
# "ccy": "USDT",
|
4529
|
+
# "amount": "23.845744",
|
4530
|
+
# "actual_amount": "22.445744",
|
4531
|
+
# "chain": "TRC20",
|
4532
|
+
# "tx_fee": "1.4",
|
4533
|
+
# "fee_asset": "USDT",
|
4534
|
+
# "fee_amount": "1.4",
|
4535
|
+
# "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
|
4536
|
+
# "memo": "",
|
4537
|
+
# "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
|
4538
|
+
# "confirmations": 18,
|
4539
|
+
# "explorer_address_url": "https://tronscan.org/#/address",
|
4540
|
+
# "explorer_tx_url": "https://tronscan.org/#/transaction",
|
4541
|
+
# "remark": "",
|
4542
|
+
# "status": "finished"
|
4543
|
+
# }
|
4553
4544
|
#
|
4554
|
-
|
4555
|
-
|
4556
|
-
tag = self.safe_string(transaction, 'remark') # set but unused
|
4545
|
+
address = self.safe_string(transaction, 'to_address')
|
4546
|
+
tag = self.safe_string(transaction, 'memo')
|
4557
4547
|
if tag is not None:
|
4558
4548
|
if len(tag) < 1:
|
4559
4549
|
tag = None
|
4560
|
-
|
4550
|
+
remark = self.safe_string(transaction, 'remark')
|
4551
|
+
if remark is not None:
|
4552
|
+
if len(remark) < 1:
|
4553
|
+
remark = None
|
4554
|
+
txid = self.safe_string(transaction, 'tx_id')
|
4561
4555
|
if txid is not None:
|
4562
4556
|
if len(txid) < 1:
|
4563
4557
|
txid = None
|
4564
|
-
currencyId = self.safe_string(transaction, '
|
4558
|
+
currencyId = self.safe_string(transaction, 'ccy')
|
4565
4559
|
code = self.safe_currency_code(currencyId, currency)
|
4566
|
-
timestamp = self.
|
4567
|
-
type = 'withdrawal' if ('
|
4568
|
-
|
4569
|
-
networkId = self.safe_string(transaction, 'smart_contract_name')
|
4570
|
-
amount = self.safe_number(transaction, 'actual_amount')
|
4560
|
+
timestamp = self.safe_integer(transaction, 'created_at')
|
4561
|
+
type = 'withdrawal' if ('withdraw_id' in transaction) else 'deposit'
|
4562
|
+
networkId = self.safe_string(transaction, 'chain')
|
4571
4563
|
feeCost = self.safe_string(transaction, 'tx_fee')
|
4572
|
-
transferMethod = self.
|
4564
|
+
transferMethod = self.safe_string_lower_2(transaction, 'withdraw_method', 'deposit_method')
|
4573
4565
|
internal = transferMethod == 'local'
|
4574
|
-
|
4575
|
-
|
4566
|
+
amount = self.safe_number(transaction, 'actual_amount')
|
4567
|
+
if amount is None:
|
4568
|
+
amount = self.safe_number(transaction, 'amount')
|
4576
4569
|
if type == 'deposit':
|
4577
4570
|
feeCost = '0'
|
4578
|
-
|
4579
|
-
else:
|
4580
|
-
addressFrom = address
|
4571
|
+
feeCurrencyId = self.safe_string(transaction, 'fee_asset')
|
4581
4572
|
fee = {
|
4582
4573
|
'cost': self.parse_number(feeCost),
|
4583
|
-
'currency':
|
4574
|
+
'currency': self.safe_currency_code(feeCurrencyId),
|
4584
4575
|
}
|
4585
4576
|
return {
|
4586
4577
|
'info': transaction,
|
4587
|
-
'id':
|
4578
|
+
'id': self.safe_string_2(transaction, 'withdraw_id', 'deposit_id'),
|
4588
4579
|
'txid': txid,
|
4589
4580
|
'timestamp': timestamp,
|
4590
4581
|
'datetime': self.iso8601(timestamp),
|
4591
4582
|
'network': self.network_id_to_code(networkId),
|
4592
4583
|
'address': address,
|
4593
|
-
'addressTo':
|
4584
|
+
'addressTo': address,
|
4594
4585
|
'addressFrom': None,
|
4595
4586
|
'tag': tag,
|
4596
|
-
'tagTo':
|
4597
|
-
'tagFrom':
|
4587
|
+
'tagTo': None,
|
4588
|
+
'tagFrom': None,
|
4598
4589
|
'type': type,
|
4599
|
-
'amount':
|
4590
|
+
'amount': amount,
|
4600
4591
|
'currency': code,
|
4601
|
-
'status': status,
|
4592
|
+
'status': self.parse_transaction_status(self.safe_string(transaction, 'status')),
|
4602
4593
|
'updated': None,
|
4603
4594
|
'fee': fee,
|
4604
|
-
'comment':
|
4595
|
+
'comment': remark,
|
4605
4596
|
'internal': internal,
|
4606
4597
|
}
|
4607
4598
|
|
@@ -4734,154 +4725,135 @@ class coinex(Exchange, ImplicitAPI):
|
|
4734
4725
|
def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4735
4726
|
"""
|
4736
4727
|
fetch all withdrawals made from an account
|
4737
|
-
:see: https://
|
4738
|
-
:param str code: unified currency code
|
4728
|
+
:see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
|
4729
|
+
:param str [code]: unified currency code
|
4739
4730
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
4740
|
-
:param int [limit]: the maximum number of
|
4731
|
+
:param int [limit]: the maximum number of withdrawal structures to retrieve
|
4741
4732
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4742
4733
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4743
4734
|
"""
|
4735
|
+
self.load_markets()
|
4744
4736
|
request = {}
|
4745
4737
|
currency = None
|
4746
4738
|
if code is not None:
|
4747
|
-
self.load_markets()
|
4748
4739
|
currency = self.currency(code)
|
4749
|
-
request['
|
4740
|
+
request['ccy'] = currency['id']
|
4750
4741
|
if limit is not None:
|
4751
|
-
request['
|
4752
|
-
response = self.
|
4742
|
+
request['limit'] = limit
|
4743
|
+
response = self.v2PrivateGetAssetsWithdraw(self.extend(request, params))
|
4753
4744
|
#
|
4754
|
-
#
|
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
|
-
# "total": 1,
|
4786
|
-
# "total_page": 1
|
4787
|
-
# },
|
4788
|
-
# "message": "Success"
|
4789
|
-
# }
|
4745
|
+
# {
|
4746
|
+
# "data": [
|
4747
|
+
# {
|
4748
|
+
# "withdraw_id": 259364,
|
4749
|
+
# "created_at": 1701323541548,
|
4750
|
+
# "withdraw_method": "ON_CHAIN",
|
4751
|
+
# "ccy": "USDT",
|
4752
|
+
# "amount": "23.845744",
|
4753
|
+
# "actual_amount": "22.445744",
|
4754
|
+
# "chain": "TRC20",
|
4755
|
+
# "tx_fee": "1.4",
|
4756
|
+
# "fee_asset": "USDT",
|
4757
|
+
# "fee_amount": "1.4",
|
4758
|
+
# "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
|
4759
|
+
# "memo": "",
|
4760
|
+
# "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
|
4761
|
+
# "confirmations": 18,
|
4762
|
+
# "explorer_address_url": "https://tronscan.org/#/address",
|
4763
|
+
# "explorer_tx_url": "https://tronscan.org/#/transaction",
|
4764
|
+
# "remark": "",
|
4765
|
+
# "status": "finished"
|
4766
|
+
# },
|
4767
|
+
# ],
|
4768
|
+
# "pagination": {
|
4769
|
+
# "total": 9,
|
4770
|
+
# "has_next": True
|
4771
|
+
# },
|
4772
|
+
# "code": 0,
|
4773
|
+
# "message": "OK"
|
4774
|
+
# }
|
4790
4775
|
#
|
4791
|
-
data = self.
|
4792
|
-
if not isinstance(data, list):
|
4793
|
-
data = self.safe_value(data, 'data', [])
|
4776
|
+
data = self.safe_list(response, 'data', [])
|
4794
4777
|
return self.parse_transactions(data, currency, since, limit)
|
4795
4778
|
|
4796
4779
|
def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4797
4780
|
"""
|
4798
4781
|
fetch all deposits made to an account
|
4799
|
-
:see: https://
|
4800
|
-
:param str code: unified currency code
|
4782
|
+
:see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
|
4783
|
+
:param str [code]: unified currency code
|
4801
4784
|
:param int [since]: the earliest time in ms to fetch deposits for
|
4802
|
-
:param int [limit]: the maximum number of
|
4785
|
+
:param int [limit]: the maximum number of deposit structures to retrieve
|
4803
4786
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4804
4787
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4805
4788
|
"""
|
4789
|
+
self.load_markets()
|
4806
4790
|
request = {}
|
4807
4791
|
currency = None
|
4808
4792
|
if code is not None:
|
4809
|
-
self.load_markets()
|
4810
4793
|
currency = self.currency(code)
|
4811
|
-
request['
|
4794
|
+
request['ccy'] = currency['id']
|
4812
4795
|
if limit is not None:
|
4813
|
-
request['
|
4814
|
-
response = self.
|
4796
|
+
request['limit'] = limit
|
4797
|
+
response = self.v2PrivateGetAssetsDepositHistory(self.extend(request, params))
|
4815
4798
|
#
|
4816
|
-
#
|
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
|
-
# "remark": "",
|
4844
|
-
# "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
4845
|
-
# }
|
4846
|
-
# ],
|
4847
|
-
# "total": 1,
|
4848
|
-
# "total_page": 1
|
4849
|
-
# },
|
4850
|
-
# "message": "Success"
|
4851
|
-
# }
|
4799
|
+
# {
|
4800
|
+
# "data": [
|
4801
|
+
# {
|
4802
|
+
# "deposit_id": 5173806,
|
4803
|
+
# "created_at": 1714021652557,
|
4804
|
+
# "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
|
4805
|
+
# "tx_id_display": "",
|
4806
|
+
# "ccy": "USDT",
|
4807
|
+
# "chain": "TRC20",
|
4808
|
+
# "deposit_method": "ON_CHAIN",
|
4809
|
+
# "amount": "30",
|
4810
|
+
# "actual_amount": "",
|
4811
|
+
# "to_address": "TYewD2pVWDUwfNr9A",
|
4812
|
+
# "confirmations": 20,
|
4813
|
+
# "status": "FINISHED",
|
4814
|
+
# "tx_explorer_url": "https://tronscan.org/#/transaction",
|
4815
|
+
# "to_addr_explorer_url": "https://tronscan.org/#/address",
|
4816
|
+
# "remark": ""
|
4817
|
+
# },
|
4818
|
+
# ],
|
4819
|
+
# "paginatation": {
|
4820
|
+
# "total": 8,
|
4821
|
+
# "has_next": True
|
4822
|
+
# },
|
4823
|
+
# "code": 0,
|
4824
|
+
# "message": "OK"
|
4825
|
+
# }
|
4852
4826
|
#
|
4853
|
-
data = self.
|
4854
|
-
if not isinstance(data, list):
|
4855
|
-
data = self.safe_value(data, 'data', [])
|
4827
|
+
data = self.safe_list(response, 'data', [])
|
4856
4828
|
return self.parse_transactions(data, currency, since, limit)
|
4857
4829
|
|
4858
4830
|
def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
|
4859
4831
|
#
|
4860
4832
|
# {
|
4861
4833
|
# "market": "BTCUSDT",
|
4834
|
+
# "ccy": "USDT",
|
4862
4835
|
# "leverage": 10,
|
4863
|
-
# "
|
4864
|
-
#
|
4865
|
-
#
|
4866
|
-
#
|
4867
|
-
# },
|
4868
|
-
# "USDT": {
|
4869
|
-
# "min_amount": "60",
|
4870
|
-
# "max_amount": "5000000",
|
4871
|
-
# "day_rate": "0.001"
|
4872
|
-
# }
|
4873
|
-
# },
|
4836
|
+
# "min_amount": "60",
|
4837
|
+
# "max_amount": "500000",
|
4838
|
+
# "daily_interest_rate": "0.001"
|
4839
|
+
# }
|
4874
4840
|
#
|
4875
4841
|
marketId = self.safe_string(info, 'market')
|
4876
4842
|
market = self.safe_market(marketId, market, None, 'spot')
|
4877
|
-
|
4878
|
-
|
4843
|
+
currency = self.safe_string(info, 'ccy')
|
4844
|
+
rate = self.safe_number(info, 'daily_interest_rate')
|
4845
|
+
baseRate = None
|
4846
|
+
quoteRate = None
|
4847
|
+
if currency == market['baseId']:
|
4848
|
+
baseRate = rate
|
4849
|
+
elif currency == market['quoteId']:
|
4850
|
+
quoteRate = rate
|
4879
4851
|
return {
|
4880
4852
|
'symbol': market['symbol'],
|
4881
4853
|
'base': market['base'],
|
4882
|
-
'baseRate':
|
4854
|
+
'baseRate': baseRate,
|
4883
4855
|
'quote': market['quote'],
|
4884
|
-
'quoteRate':
|
4856
|
+
'quoteRate': quoteRate,
|
4885
4857
|
'period': 86400000,
|
4886
4858
|
'timestamp': None,
|
4887
4859
|
'datetime': None,
|
@@ -4891,75 +4863,52 @@ class coinex(Exchange, ImplicitAPI):
|
|
4891
4863
|
def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
|
4892
4864
|
"""
|
4893
4865
|
fetch the rate of interest to borrow a currency for margin trading
|
4894
|
-
:see: https://
|
4866
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
|
4895
4867
|
:param str symbol: unified symbol of the market to fetch the borrow rate for
|
4896
4868
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4869
|
+
:param str params['code']: unified currency code
|
4897
4870
|
:returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
|
4898
4871
|
"""
|
4899
4872
|
self.load_markets()
|
4873
|
+
code = self.safe_string(params, 'code')
|
4874
|
+
if code is None:
|
4875
|
+
raise ArgumentsRequired(self.id + ' fetchIsolatedBorrowRate() requires a code parameter')
|
4876
|
+
params = self.omit(params, 'code')
|
4877
|
+
currency = self.currency(code)
|
4900
4878
|
market = self.market(symbol)
|
4901
4879
|
request = {
|
4902
4880
|
'market': market['id'],
|
4881
|
+
'ccy': currency['id'],
|
4903
4882
|
}
|
4904
|
-
response = self.
|
4883
|
+
response = self.v2PrivateGetAssetsMarginInterestLimit(self.extend(request, params))
|
4905
4884
|
#
|
4906
4885
|
# {
|
4907
4886
|
# "code": 0,
|
4908
4887
|
# "data": {
|
4909
4888
|
# "market": "BTCUSDT",
|
4889
|
+
# "ccy": "USDT",
|
4910
4890
|
# "leverage": 10,
|
4911
|
-
# "
|
4912
|
-
#
|
4913
|
-
#
|
4914
|
-
# "day_rate": "0.001"
|
4915
|
-
# },
|
4916
|
-
# "USDT": {
|
4917
|
-
# "min_amount": "60",
|
4918
|
-
# "max_amount": "5000000",
|
4919
|
-
# "day_rate": "0.001"
|
4920
|
-
# }
|
4891
|
+
# "min_amount": "60",
|
4892
|
+
# "max_amount": "500000",
|
4893
|
+
# "daily_interest_rate": "0.001"
|
4921
4894
|
# },
|
4922
|
-
# "message": "
|
4895
|
+
# "message": "OK"
|
4923
4896
|
# }
|
4924
4897
|
#
|
4925
|
-
data = self.
|
4898
|
+
data = self.safe_dict(response, 'data', {})
|
4926
4899
|
return self.parse_isolated_borrow_rate(data, market)
|
4927
4900
|
|
4928
|
-
def
|
4901
|
+
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4929
4902
|
"""
|
4930
|
-
fetch the
|
4931
|
-
:see: https://
|
4903
|
+
fetch the interest owed by the user for borrowing currency for margin trading
|
4904
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
|
4905
|
+
:param str [code]: unified currency code
|
4906
|
+
:param str [symbol]: unified market symbol when fetch interest in isolated markets
|
4907
|
+
:param int [since]: the earliest time in ms to fetch borrrow interest for
|
4908
|
+
:param int [limit]: the maximum number of structures to retrieve
|
4932
4909
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4933
|
-
:returns dict: a list of `
|
4910
|
+
:returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
|
4934
4911
|
"""
|
4935
|
-
self.load_markets()
|
4936
|
-
response = self.v1PrivateGetMarginConfig(params)
|
4937
|
-
#
|
4938
|
-
# {
|
4939
|
-
# "code": 0,
|
4940
|
-
# "data": [
|
4941
|
-
# {
|
4942
|
-
# "market": "BTCUSDT",
|
4943
|
-
# "leverage": 10,
|
4944
|
-
# "BTC": {
|
4945
|
-
# "min_amount": "0.002",
|
4946
|
-
# "max_amount": "200",
|
4947
|
-
# "day_rate": "0.001"
|
4948
|
-
# },
|
4949
|
-
# "USDT": {
|
4950
|
-
# "min_amount": "60",
|
4951
|
-
# "max_amount": "5000000",
|
4952
|
-
# "day_rate": "0.001"
|
4953
|
-
# }
|
4954
|
-
# },
|
4955
|
-
# ],
|
4956
|
-
# "message": "Success"
|
4957
|
-
# }
|
4958
|
-
#
|
4959
|
-
data = self.safe_value(response, 'data', [])
|
4960
|
-
return self.parse_isolated_borrow_rates(data)
|
4961
|
-
|
4962
|
-
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4963
4912
|
self.load_markets()
|
4964
4913
|
request = {}
|
4965
4914
|
market = None
|
@@ -4968,76 +4917,62 @@ class coinex(Exchange, ImplicitAPI):
|
|
4968
4917
|
request['market'] = market['id']
|
4969
4918
|
if limit is not None:
|
4970
4919
|
request['limit'] = limit
|
4971
|
-
response = self.
|
4920
|
+
response = self.v2PrivateGetAssetsMarginBorrowHistory(self.extend(request, params))
|
4972
4921
|
#
|
4973
4922
|
# {
|
4974
|
-
# "
|
4975
|
-
#
|
4976
|
-
#
|
4977
|
-
#
|
4978
|
-
#
|
4979
|
-
#
|
4980
|
-
#
|
4981
|
-
#
|
4982
|
-
#
|
4983
|
-
#
|
4984
|
-
#
|
4985
|
-
#
|
4986
|
-
#
|
4987
|
-
#
|
4988
|
-
#
|
4989
|
-
#
|
4990
|
-
#
|
4991
|
-
# "unflat_amount": "0",
|
4992
|
-
# "expire_time": 1655078027,
|
4993
|
-
# "is_renew": True,
|
4994
|
-
# "status": "finish"
|
4995
|
-
# }
|
4996
|
-
# ],
|
4997
|
-
# "total_page": 1
|
4923
|
+
# "data": [
|
4924
|
+
# {
|
4925
|
+
# "borrow_id": 2642934,
|
4926
|
+
# "created_at": 1654761016000,
|
4927
|
+
# "market": "BTCUSDT",
|
4928
|
+
# "ccy": "USDT",
|
4929
|
+
# "daily_interest_rate": "0.001",
|
4930
|
+
# "expired_at": 1655625016000,
|
4931
|
+
# "borrow_amount": "100",
|
4932
|
+
# "to_repaied_amount": "0",
|
4933
|
+
# "is_auto_renew": False,
|
4934
|
+
# "status": "finish"
|
4935
|
+
# },
|
4936
|
+
# ],
|
4937
|
+
# "pagination": {
|
4938
|
+
# "total": 4,
|
4939
|
+
# "has_next": True
|
4998
4940
|
# },
|
4999
|
-
# "
|
4941
|
+
# "code": 0,
|
4942
|
+
# "message": "OK"
|
5000
4943
|
# }
|
5001
4944
|
#
|
5002
|
-
|
5003
|
-
rows = self.safe_value(data, 'data', [])
|
4945
|
+
rows = self.safe_value(response, 'data', [])
|
5004
4946
|
interest = self.parse_borrow_interests(rows, market)
|
5005
4947
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
5006
4948
|
|
5007
4949
|
def parse_borrow_interest(self, info, market: Market = None):
|
5008
4950
|
#
|
5009
4951
|
# {
|
5010
|
-
# "
|
5011
|
-
# "
|
5012
|
-
# "
|
5013
|
-
# "
|
5014
|
-
# "
|
5015
|
-
# "
|
5016
|
-
# "
|
5017
|
-
# "
|
5018
|
-
# "
|
5019
|
-
# "is_renew": True,
|
4952
|
+
# "borrow_id": 2642934,
|
4953
|
+
# "created_at": 1654761016000,
|
4954
|
+
# "market": "BTCUSDT",
|
4955
|
+
# "ccy": "USDT",
|
4956
|
+
# "daily_interest_rate": "0.001",
|
4957
|
+
# "expired_at": 1655625016000,
|
4958
|
+
# "borrow_amount": "100",
|
4959
|
+
# "to_repaied_amount": "0",
|
4960
|
+
# "is_auto_renew": False,
|
5020
4961
|
# "status": "finish"
|
5021
4962
|
# }
|
5022
4963
|
#
|
5023
|
-
marketId = self.safe_string(info, '
|
4964
|
+
marketId = self.safe_string(info, 'market')
|
5024
4965
|
market = self.safe_market(marketId, market, None, 'spot')
|
5025
|
-
|
5026
|
-
timestamp = self.safe_timestamp(info, 'expire_time')
|
5027
|
-
unflatAmount = self.safe_string(info, 'unflat_amount')
|
5028
|
-
loanAmount = self.safe_string(info, 'loan_amount')
|
5029
|
-
interest = Precise.string_sub(unflatAmount, loanAmount)
|
5030
|
-
if unflatAmount == '0':
|
5031
|
-
interest = None
|
4966
|
+
timestamp = self.safe_integer(info, 'expired_at')
|
5032
4967
|
return {
|
5033
4968
|
'account': None, # deprecated
|
5034
|
-
'symbol': symbol,
|
4969
|
+
'symbol': market['symbol'],
|
5035
4970
|
'marginMode': 'isolated',
|
5036
4971
|
'marginType': None, # deprecated
|
5037
|
-
'currency': self.safe_currency_code(self.safe_string(info, '
|
5038
|
-
'interest': self.
|
5039
|
-
'interestRate': self.safe_number(info, '
|
5040
|
-
'amountBorrowed': self.
|
4972
|
+
'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
|
4973
|
+
'interest': self.safe_number(info, 'to_repaied_amount'),
|
4974
|
+
'interestRate': self.safe_number(info, 'daily_interest_rate'),
|
4975
|
+
'amountBorrowed': self.safe_number(info, 'borrow_amount'),
|
5041
4976
|
'timestamp': timestamp, # expiry time
|
5042
4977
|
'datetime': self.iso8601(timestamp),
|
5043
4978
|
'info': info,
|
@@ -5046,32 +4981,43 @@ class coinex(Exchange, ImplicitAPI):
|
|
5046
4981
|
def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
5047
4982
|
"""
|
5048
4983
|
create a loan to borrow margin
|
5049
|
-
:see: https://
|
4984
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
|
5050
4985
|
:param str symbol: unified market symbol, required for coinex
|
5051
4986
|
:param str code: unified currency code of the currency to borrow
|
5052
4987
|
:param float amount: the amount to borrow
|
5053
4988
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4989
|
+
:param boolean [params.isAutoRenew]: whether to renew the margin loan automatically or not, default is False
|
5054
4990
|
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
5055
4991
|
"""
|
5056
4992
|
self.load_markets()
|
5057
4993
|
market = self.market(symbol)
|
5058
4994
|
currency = self.currency(code)
|
4995
|
+
isAutoRenew = self.safe_bool_2(params, 'isAutoRenew', 'is_auto_renew', False)
|
4996
|
+
params = self.omit(params, 'isAutoRenew')
|
5059
4997
|
request = {
|
5060
4998
|
'market': market['id'],
|
5061
|
-
'
|
5062
|
-
'
|
4999
|
+
'ccy': currency['id'],
|
5000
|
+
'borrow_amount': self.currency_to_precision(code, amount),
|
5001
|
+
'is_auto_renew': isAutoRenew,
|
5063
5002
|
}
|
5064
|
-
response = self.
|
5003
|
+
response = self.v2PrivatePostAssetsMarginBorrow(self.extend(request, params))
|
5065
5004
|
#
|
5066
5005
|
# {
|
5067
5006
|
# "code": 0,
|
5068
5007
|
# "data": {
|
5069
|
-
# "
|
5008
|
+
# "borrow_id": 13784021,
|
5009
|
+
# "market": "BTCUSDT",
|
5010
|
+
# "ccy": "USDT",
|
5011
|
+
# "daily_interest_rate": "0.001",
|
5012
|
+
# "expired_at": 1717299948340,
|
5013
|
+
# "borrow_amount": "60",
|
5014
|
+
# "to_repaied_amount": "60.0025",
|
5015
|
+
# "status": "loan"
|
5070
5016
|
# },
|
5071
|
-
# "message": "
|
5017
|
+
# "message": "OK"
|
5072
5018
|
# }
|
5073
5019
|
#
|
5074
|
-
data = self.
|
5020
|
+
data = self.safe_dict(response, 'data', {})
|
5075
5021
|
transaction = self.parse_margin_loan(data, currency)
|
5076
5022
|
return self.extend(transaction, {
|
5077
5023
|
'amount': amount,
|
@@ -5081,12 +5027,12 @@ class coinex(Exchange, ImplicitAPI):
|
|
5081
5027
|
def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
5082
5028
|
"""
|
5083
5029
|
repay borrowed margin and interest
|
5084
|
-
:see: https://
|
5030
|
+
:see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
|
5085
5031
|
:param str symbol: unified market symbol, required for coinex
|
5086
5032
|
:param str code: unified currency code of the currency to repay
|
5087
5033
|
:param float amount: the amount to repay
|
5088
5034
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5089
|
-
:param str [params.
|
5035
|
+
:param str [params.borrow_id]: extra parameter that is not required
|
5090
5036
|
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
5091
5037
|
"""
|
5092
5038
|
self.load_markets()
|
@@ -5094,46 +5040,47 @@ class coinex(Exchange, ImplicitAPI):
|
|
5094
5040
|
currency = self.currency(code)
|
5095
5041
|
request = {
|
5096
5042
|
'market': market['id'],
|
5097
|
-
'
|
5043
|
+
'ccy': currency['id'],
|
5098
5044
|
'amount': self.currency_to_precision(code, amount),
|
5099
5045
|
}
|
5100
|
-
response = self.
|
5046
|
+
response = self.v2PrivatePostAssetsMarginRepay(self.extend(request, params))
|
5101
5047
|
#
|
5102
5048
|
# {
|
5103
5049
|
# "code": 0,
|
5104
|
-
# "data":
|
5105
|
-
# "message": "
|
5050
|
+
# "data": {},
|
5051
|
+
# "message": "OK"
|
5106
5052
|
# }
|
5107
5053
|
#
|
5108
|
-
|
5054
|
+
data = self.safe_dict(response, 'data', {})
|
5055
|
+
transaction = self.parse_margin_loan(data, currency)
|
5109
5056
|
return self.extend(transaction, {
|
5110
5057
|
'amount': amount,
|
5111
5058
|
'symbol': symbol,
|
5112
5059
|
})
|
5113
5060
|
|
5114
5061
|
def parse_margin_loan(self, info, currency: Currency = None):
|
5115
|
-
#
|
5116
|
-
# borrowMargin
|
5117
5062
|
#
|
5118
5063
|
# {
|
5119
|
-
# "
|
5120
|
-
#
|
5121
|
-
#
|
5122
|
-
#
|
5123
|
-
#
|
5124
|
-
#
|
5125
|
-
# "
|
5126
|
-
# "
|
5127
|
-
# "message": "Success"
|
5064
|
+
# "borrow_id": 13784021,
|
5065
|
+
# "market": "BTCUSDT",
|
5066
|
+
# "ccy": "USDT",
|
5067
|
+
# "daily_interest_rate": "0.001",
|
5068
|
+
# "expired_at": 1717299948340,
|
5069
|
+
# "borrow_amount": "60",
|
5070
|
+
# "to_repaied_amount": "60.0025",
|
5071
|
+
# "status": "loan"
|
5128
5072
|
# }
|
5129
5073
|
#
|
5074
|
+
currencyId = self.safe_string(info, 'ccy')
|
5075
|
+
marketId = self.safe_string(info, 'market')
|
5076
|
+
timestamp = self.safe_integer(info, 'expired_at')
|
5130
5077
|
return {
|
5131
|
-
'id': self.safe_integer(info, '
|
5132
|
-
'currency': self.safe_currency_code(
|
5133
|
-
'amount':
|
5134
|
-
'symbol': None,
|
5135
|
-
'timestamp':
|
5136
|
-
'datetime':
|
5078
|
+
'id': self.safe_integer(info, 'borrow_id'),
|
5079
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
5080
|
+
'amount': self.safe_string(info, 'borrow_amount'),
|
5081
|
+
'symbol': self.safe_symbol(marketId, None, None, 'spot'),
|
5082
|
+
'timestamp': timestamp,
|
5083
|
+
'datetime': self.iso8601(timestamp),
|
5137
5084
|
'info': info,
|
5138
5085
|
}
|
5139
5086
|
|