Skip to content

Commit 20f976c

Browse files
author
Jon Eyrick
authored
Adjustable recvWindow
1 parent e1899a4 commit 20f976c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

node-binance-api.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = function() {
1212
const request = require('request');
1313
const crypto = require('crypto');
1414
const base = 'https://www.binance.com/api/';
15+
const wapi = 'https://www.binance.com/wapi/';
1516
const websocket_base = 'wss://stream.binance.com:9443/ws/';
1617
let messageQueue = {};
1718
let depthCache = {};
@@ -61,7 +62,7 @@ module.exports = function() {
6162
if ( !data ) data = {};
6263
data.timestamp = new Date().getTime();
6364
if ( typeof data.symbol !== "undefined" ) data.symbol = data.symbol.replace('_','');
64-
if ( typeof data.recvWindow == "undefined" ) data.recvWindow = 6500;
65+
if ( typeof data.recvWindow == "undefined" ) data.recvWindow = options.recvWindow;
6566
let query = Object.keys(data).reduce(function(a,k){a.push(k+'='+encodeURIComponent(data[k]));return a},[]).join('&');
6667
let signature = crypto.createHmac("sha256", options.APISECRET).update(query).digest("hex"); // set the HMAC hash header
6768
let opt = {
@@ -96,8 +97,11 @@ module.exports = function() {
9697
if ( typeof flags.icebergQty !== "undefined" ) opt.icebergQty = flags.icebergQty;
9798
if ( typeof flags.stopPrice !== "undefined" ) opt.stopPrice = flags.stopPrice;
9899
signedRequest(base+"v3/order", opt, function(response) {
99-
console.log(side+"("+symbol+","+quantity+","+price+") ",response);
100+
if ( typeof response.msg !== "undefined" && response.msg == "Filter failure: MIN_NOTIONAL" ) {
101+
console.log("Order quantity too small. Must be > 0.01");
102+
}
100103
if ( callback ) callback(response);
104+
else console.log(side+"("+symbol+","+quantity+","+price+") ",response);
101105
}, "POST");
102106
};
103107
////////////////////////////
@@ -289,7 +293,14 @@ module.exports = function() {
289293
slice: function(object, start = 0) {
290294
return Object.entries(object).slice(start).map(entry => entry[0]);
291295
},
296+
min: function(object) {
297+
return Math.min.apply(Math, Object.keys(object));
298+
},
299+
max: function(object) {
300+
return Math.max.apply(Math, Object.keys(object));
301+
},
292302
options: function(opt) {
303+
if ( typeof opt.recvWindow == "undefined" ) opt.recvWindow = 16000;
293304
options = opt;
294305
},
295306
buy: function(symbol, quantity, price, flags = {}, callback = false) {

0 commit comments

Comments
 (0)