I have this code and i want to place a buy order using the binance spot api, but it doesn't like my symbol that i am using showing me the error:
{'code': -1102, 'msg': "Mandatory parameter 'symbol' was not sent, was empty/null, or malformed."}
import json
import requests
import time
API_KEY = "apikey"
SECRET_KEY = "secretkey"
ENDPOINT = "https://api.binance.com/api/v3/order"
HEADERS = {
"X-MBX-APIKEY": API_KEY
}
PAYLOAD = {
"symbol": "BTCUSDT",
"side": "BUY",
"type": "MARKET",
"quantity": "0.1",
"timestamp": int(time.time() * 1000)
}
response = requests.post(ENDPOINT, headers=HEADERS, params=json.dumps(PAYLOAD))
if response.status_code != 200:
print("Error placing buy order:")
print(response.json())
else:
print("Buy order placed successfully:")
print(response.json())
I wanted it to tell me that i had insufficient funds (true) but just to know that if i had money on it, it would place the order.
EDIT: Changed to most recent comment, the prevailing error occurs.
Can you try this:
import json
response = requests.post(ENDPOINT, headers=HEADERS, params=json.dumps(PAYLOAD))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.