From d1f03426680732d8ea4500d1d104261361c1df0b Mon Sep 17 00:00:00 2001 From: Isaiah Nixon Date: Wed, 6 Oct 2021 23:41:58 -0600 Subject: [PATCH 1/2] Added get_account_lend_record function. --- kucoin/client.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/kucoin/client.py b/kucoin/client.py index b597a76..7c24316 100644 --- a/kucoin/client.py +++ b/kucoin/client.py @@ -1981,3 +1981,44 @@ def get_ws_endpoint(self, private=False): path = 'bullet-private' return self._post(path, signed) + + # Margin Endpoints + + def get_account_lend_record(self, currency=None): + """Get the lending history of the main account + + https://docs.kucoin.com/#get-account-lend-record + + :param currency: optional Currency code + :type currency: string + + .. code:: python + + lend_record = client.get_account_lend_record() + lend_record = client.get_account_lend_record('USDT') + + :returns: API Response + + .. code-block:: python + + [ + { + 'currency': 'USDT', + 'outstanding': '0', + 'filledSize': '300', + 'accruedInterest': '2.002', + 'realizedProfit': '1.001', + 'isAutoLend': True + } + ] + + + :raises: KucoinResponseException, KucoinAPIException + + """ + + data = {} + if currency: + data['currency'] = currency + + return self._get('margin/lend/assets', True, data=data) From 5cab4a5faff4f0e0399f929fd8927dc2e32237c1 Mon Sep 17 00:00:00 2001 From: Isaiah Nixon Date: Thu, 7 Oct 2021 18:49:23 -0600 Subject: [PATCH 2/2] Added get_all_sub_accounts() method. --- kucoin/client.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/kucoin/client.py b/kucoin/client.py index 7c24316..1b03df5 100644 --- a/kucoin/client.py +++ b/kucoin/client.py @@ -296,6 +296,95 @@ def get_currency(self, currency): # User Account Endpoints + def get_all_sub_accounts(self): + """Get the account info of all sub-users. + + https://docs.kucoin.com/#get-the-aggregated-balance-of-all-sub-accounts + + .. code:: python + + sub_accounts = client.get_all_sub_accounts() + + :returns: API Response + + .. code-block:: python + + [ + { + "subUserId":"5caefba7d9575a0688f83c45", + "subName":"kucoin1", + "mainAccounts":[ + { + "currency":"BTC", + "balance":"6", + "available":"6", + "holds":"0", + "baseCurrency":"BTC", + "baseCurrencyPrice":"1", + "baseAmount":"1.1" + } + ], + "tradeAccounts":[ + { + "currency":"BTC", + "balance":"1000", + "available":"1000", + "holds":"0", + "baseCurrency":"BTC", + "baseCurrencyPrice":"1", + "baseAmount":"1.1" + } + ], + "marginAccounts":[ + { + "currency":"BTC", + "balance":"1.1", + "available":"1.1", + "holds":"0", + "baseCurrency":"BTC", + "baseCurrencyPrice":"1", + "baseAmount":"1.1" + } + ] + } + ] + + + :raises: KucoinResponseException, KucoinAPIException + + """ + + return self._get('sub-accounts', True, data={}) + + def get_account(self, account_id): + """Get an individual account + + https://docs.kucoin.com/#get-an-account + + :param account_id: ID for account - from list_accounts() + :type account_id: string + + .. code:: python + + account = client.get_account('5bd6e9216d99522a52e458d6') + + :returns: API Response + + .. code-block:: python + + { + "currency": "KCS", + "balance": "1000000060.6299", + "available": "1000000060.6299", + "holds": "0" + } + + :raises: KucoinResponseException, KucoinAPIException + + """ + + return self._get('accounts/{}'.format(account_id), True) + def get_accounts(self, currency=None, account_type=None): """Get a list of accounts