Marcel Fischer
Marcel Fischer

Reputation: 11

Get borrow size of currency from Kucoin via Python

I want to get the current borrow size for the currency´s.

I tried that:

client = kucoin.Client(api_key, api_secret, api_passphrase)
response = client.get_accounts()

but the borrow size is missing in the response.

Do you have a proposals?

I could found that: https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-cross-margin but I don´t know, how I can implement that in Python.

I tried that:

client = kucoin.Client(api_key, api_secret, api_passphrase)
response = client.get_accounts()

Upvotes: 1

Views: 27

Answers (1)

Marcel Fischer
Marcel Fischer

Reputation: 11

I tried also that:

import base64, hmac, hashlib, json, time

# constants
API_KEY = '***'
API_SECRET = '***'
API_PASSPHRASE = '***'

url = "https://api/v3/margin/accounts"

str_to_sign = 'GET' + '/api/v3/margin/accounts?quoteCurrency=BTC'

signature = base64.b64encode(hmac.new(API_SECRET.encode(
    'utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256).digest())

passphrase = base64.b64encode(hmac.new(API_SECRET.encode(
    'utf-8'), API_PASSPHRASE.encode('utf-8'), hashlib.sha256).digest())

headers = {
    "KC-API-SIGN": signature,
    "KC-API-TIMESTAMP": str(now),
    "KC-API-KEY": API_KEY,
    "KC-API-PASSPHRASE": passphrase,
    "KC-API-KEY-VERSION": "2",
    "Content-Type": "application/json"
}

try:
    res = requests.get(
        url, headers=headers).json()

    print(res)

except Exception as err:
    print(err)

but it doesn´t work.

Upvotes: 0

Related Questions