Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new API methods. #100

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions kucoin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1981,3 +2070,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)