dino
April 17, 2020, 5:47am
1
This url works fine to place batch order:
params = {
"batchOrders": [
{
"symbol":"BTCUSDT",
"side": "SELL",
"type": "LIMIT",
"quantity": "0.001",
"timeInForce": "GTC",
"reduceOnly": "false",
"price": "9563.51"
},
{
"symbol":"BTCUSDT",
"side": "SELL",
"type": "LIMIT",
"quantity": "0.001",
"timeInForce": "GTC",
"reduceOnly": "false",
"price": "9613.51"
}
}
https://testnet.binancefuture.com/fapi/v1/batchOrders?batchOrders=%5B%7B%22symbol%22%3A+%22BTCUSDT%22%2C+%22side%22%3A+%22SELL%22%2C+%22type%22%3A+%22LIMIT%22%2C+%22quantity%22%3A+%220.001%22%2C+%22timeInForce%22%3A+%22GTC%22%2C+%22reduceOnly%22%3A+%22false%22%2C+%22price%22%3A+%229563.51%22%7D%2C+%7B%22symbol%22%3A+%22BTCUSDT%22%2C+%22side%22%3A+%22SELL%22%2C+%22type%22%3A+%22LIMIT%22%2C+%22quantity%22%3A+%220.001%22%2C+%22timeInForce%22%3A+%22GTC%22%2C+%22reduceOnly%22%3A+%22false%22%2C+%22price%22%3A+%229613.51%22%7D%5D×tamp=1592732592992&signature=2b29764224816bbc2366cf97688958d2bf3e790dc6270804c6982160cf9fb444
json encode the batch orders.
We have an example python script and work out of the box.
"symbol": "BNBUSDT", "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "quantity": 1, "price": "15" } response = send_signed_request('POST', '/fapi/v1/order', params) print(response) # place batch orders # if you see order response, then the parameters setting is correct # if it has response from server saying some parameter error, please adjust the parameters according the market. params = { "batchOrders": [ { "symbol":"BNBUSDT", "side": "BUY", "type": "STOP", "quantity": "1", "price": "9000",
I want to send batchOrder in Python, but I recive [{‘code’: 400, ‘msg’: None}, {‘code’: 400, ‘msg’: None}]
What is wrong ?
When I send a simple Order everything is OK.
Here is pice of code.
timestamp2 = (int(time.time() * 1000))
params2 = { “batchOrders”: [
{
"symbol": "BTCUSDT",
"type":"STOP_MARKET",
"positionSide":"BOTH",
"side": "BUY",
"quantity":0.03,
"stopPrice":56000,
"recvWindow":8000,
"timestamp": timestamp2
},
{
"symbol": "BTCUSDT",
"type":"STOP_MARKET",
"positionSide":"BOTH",
"side": "SELL",
"quantity":0.03,
"stopPrice":51000,
"recvWindow":8000,
"timestamp": timestamp2
}
]
}
sending = send_signed_request(‘POST’, ‘/fapi/v1/batchOrders’, params2)
dino
April 30, 2021, 3:03am
3
using the example code above for debugging.
T_B_L
January 17, 2022, 5:05pm
4
I use example code above and encounter this error. do you know why?
{‘code’: -1130, ‘msg’: “Data sent for parameter ‘batchOrders:[{‘symbol’: ‘ETHUSDT’, ‘side’: ‘BUY’, ‘type’: ‘LIMIT’, ‘quantity’: ‘0.001’, ‘timeInForce’: ‘GTC’, ‘price’: ‘3254.36’}]’ is not valid.”}
dino
March 8, 2022, 1:59am
5
the qty can only set up to 2 decimals, please check the rules from the /exchangeInfo.
It could be tricky to debug in the batch order endpoint, I would suggest to test with the same parameters in the single order endpoint first.
Wutong
August 5, 2022, 11:13pm
6
If you send a post request to the endpoint to post 1 order: The price and quantity needs to be a FLOAT.
If you send a post request to the batch orders enpoint to post multiple orders (up to 5): The prices and qantities needs to be a STRING.
I dont know if this is what caused your error, but it took me way to much time to figure out the documentation was lying!
Hope this can help someone
5 Likes
THANK YOU, THEY REALLY SHOULD BE STRINGS! WTF Binance? And I didn’t see it in the documentation…
2 Likes