Hi guys,
this is code:
// API endpoint
const endpoint = 'https://fapi.binance.com/fapi/v1/order';
// Order parameters
const symbol = 'BTCUSDT'; // The trading symbol
const side = 'BUY'; // BUY or SELL
const type = 'LIMIT'; // The order type
const quantity = 0.001; // The order quantity
const price = 20000; // The order price
// Generate a signature
const timestamp = Date.now();
console.log(timestamp);
const queryString = `symbol=${symbol}&side=${side}&type=${type}&quantity=${quantity}&price=${price}×tamp=${timestamp}`;
const signature = crypto.createHmac('sha256', secretKey).update(queryString).digest('hex');
// Request parameters
const params = {
symbol,
side,
type,
quantity,
price,
timestamp,
signature
};
// Request headers
const headers = {
'X-MBX-APIKEY': apiKey
};
// Send the request
axios.post(endpoint, params, { headers })
.then(response => {
console.log('Order placed successfully:', response.data);
})
.catch(error => {
console.error('Error placing order:', error.response.data);
});
But error:
Error placing order: {
code: -1102,
msg: "Mandatory parameter 'timestamp' was not sent, was empty/null, or malformed."
}
My code had ‘timestamp’. I dno’t know why error.
‘timestamp’ is: 1685094060835
Please help me.
Thank in advanced !