nocoffeenoworkee
nocoffeenoworkee

Reputation: 59

Cannot Place an order in Kucoin API Python

I'm trying to place a sell market order on Kucoin API in Python. It gives me a successful response, but doesn't place the order:

200 {'code': '200000', 'data': {'currentPage': 1, 'pageSize': 50, 'totalNum': 0, 'totalPage': 0, 'items': []}}

The Code:

import requests
from kucoin.client import Client
import base64
import hashlib
import hmac
import kucoin


url = 'https://api.kucoin.com/api/v1/orders'
now = int(time.time() * 1000)
str_to_sign = str(now) + 'GET' + '/api/v1/orders'
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",
    "clientOid": "AAA",
    "side": "sell",
    "symbol": "BTC-USDT",
    "type": "market",
    "size": "0.001",
    
}
response = requests.request('get', url, headers=headers)
print(response.status_code)
print(response.json())

Upvotes: 0

Views: 805

Answers (1)

David Janusek
David Janusek

Reputation: 11

I think you have to use command "POST" instead of "GET".

Upvotes: 1

Related Questions