const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
app.use(bodyParser.json());
app.use(cors());
const crypto = require('crypto');
const axios = require('axios');
var qs = require('qs');
const main = async () => {
const ts = Date.now();
const apikey = 'ejUb1XDWbYAoJtjXRHX3UN6pNT7fkcQ48kHyXdLphUwcQnC0ItHn60caCkFBpWVN';
const seckey = 'yAsnZhg9eu1zdxMV7TqvWTEaOThxeatL2l5xlzzIMk8DhPWaGCbxePCCWk0ACuA2';
const param = `symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=${ts}`;
console.log(param);
const hash = await crypto.createHmac('sha256', seckey).update(param).digest('hex');
console.log(hash);
// console.log( typeof ts.toString())
var data = qs.stringify({
'symbol': 'LTCBTC',
'side': 'BUY',
'type': 'LIMIT',
'timeInForce': 'GTC',
'quantity': '1',
'price': '0.1',
'recvWindow': '5000',
'timestamp': ts.toString(),
'signature': hash
});
try {
const res = await axios.post(`https://testnet.binance.vision/api/v3/order`, data, {
headers: {
'X-MBX-APIKEY': apikey
}
})
console.log(res);
} catch (err) {
// console.log(err);
}
}
main();
The price doesn’t look right, try a much smaller value; (The latest price in testnet is about 0.003 so try price like 0.004)
I tried with 0.004 then it did not work , then I reduced it to 0.002 then it started working.
THANKS.