Hello everyone,
I hope you’re all doing well. I’m facing an issue while trying to cancel some open orders when using DELETE /fapi/v1/batchOrders endpoint.
This error return:
{ code: -1022, msg: 'Signature for this request is not valid.' }
If i use ‘DELETE /fapi/v1/order’ endpoint, it worked, no error with Signature. But DELETE /fapi/v1/batchOrders is not working.
Any problem in my code ?
Thank in advanced !
This is my code:
const symbol = dataToCancel.symbol;
const origClientOrderIdList = dataToCancel.origClientOrderIdList;
const params = {
symbol: symbol,
origClientOrderIdList: origClientOrderIdList,
timestamp: Date.now()
}
queryString = Object.keys(params)
.map((key) => `${key}=${params[key]}`)
.join('&');
signature = crypto
.createHmac('sha256', secretKey)
.update(queryString)
.digest('hex');
console.log(signature);
params.signature = signature;
await axios.delete(`${BASE_URL}/fapi/v1/batchOrders`, {
headers: headers,
params: params
})
.then(async (response) =>{
console.log(response);
})
.catch(error => {
console.error(`Error get position and open orders 1:`, error.response.data);
})