From e6dedf6df577f55e34a974ffe7fe7e642c093c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Creusot?= Date: Tue, 5 Jan 2021 16:27:04 +0100 Subject: [PATCH 1/3] [UPDATE] usless variable futuresInfo, add 2 params for usedWeight and orderCount --- node-binance-api.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node-binance-api.js b/node-binance-api.js index d403f560..419ef96c 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -41,7 +41,7 @@ let api = function Binance( options = {} ) { const contentType = 'application/x-www-form-urlencoded'; Binance.subscriptions = {}; Binance.futuresSubscriptions = {}; - Binance.futuresInfo = {}; + // Binance.futuresInfo = {}; Binance.futuresMeta = {}; Binance.futuresTicks = {}; Binance.futuresRealtime = {}; @@ -85,6 +85,10 @@ let api = function Binance( options = {} ) { orderCount1d: 0, timeOffset: 0 }; + Binance.futuresInfo = { + usedWeight: 0, + orderCount: 0 + }; Binance.socketHeartbeatInterval = null; if ( options ) setOptions( options ); From 5cfd3b5b6044bc23ab952c0b28034298cab5cff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Creusot?= Date: Tue, 5 Jan 2021 16:32:36 +0100 Subject: [PATCH 2/3] [ADD] usedWeight and orderCount when we have a futures respond --- node-binance-api.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/node-binance-api.js b/node-binance-api.js index 419ef96c..e830b29f 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -85,10 +85,10 @@ let api = function Binance( options = {} ) { orderCount1d: 0, timeOffset: 0 }; - Binance.futuresInfo = { - usedWeight: 0, - orderCount: 0 - }; + Binance.futuresInfo = { + usedWeight: 0, + orderCount: 0 + }; Binance.socketHeartbeatInterval = null; if ( options ) setOptions( options ); @@ -563,7 +563,11 @@ let api = function Binance( options = {} ) { Binance.info.statusCode = response.statusCode || 0; if ( response.request ) Binance.info.lastURL = response.request.uri.href; if ( response.headers ) { - Binance.info.usedWeight = response.headers['x-mbx-used-weight-1m'] || 0; + Binance.futuresInfo.usedWeight = response.headers['x-mbx-used-weight-1m'] || 0; + if (response.headers['x-mbx-order-count-1m'] !== undefined) { + Binance.futuresInfo.orderCount = response.headers['x-mbx-order-count-1m']; + // never see other x-mbx-order-count-* than 1m... + } Binance.info.futuresLatency = response.headers['x-response-time'] || 0; } } From 8af5cd8f67787304fc64f5aa59374484f63d70dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Creusot?= Date: Tue, 5 Jan 2021 16:34:14 +0100 Subject: [PATCH 3/3] [ADD] futures fonction for get weight and order count --- node-binance-api.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/node-binance-api.js b/node-binance-api.js index e830b29f..b526491f 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -563,11 +563,11 @@ let api = function Binance( options = {} ) { Binance.info.statusCode = response.statusCode || 0; if ( response.request ) Binance.info.lastURL = response.request.uri.href; if ( response.headers ) { - Binance.futuresInfo.usedWeight = response.headers['x-mbx-used-weight-1m'] || 0; - if (response.headers['x-mbx-order-count-1m'] !== undefined) { - Binance.futuresInfo.orderCount = response.headers['x-mbx-order-count-1m']; - // never see other x-mbx-order-count-* than 1m... - } + Binance.futuresInfo.usedWeight = response.headers['x-mbx-used-weight-1m'] || 0; + if (response.headers['x-mbx-order-count-1m'] !== undefined) { + Binance.futuresInfo.orderCount = response.headers['x-mbx-order-count-1m']; + // never see other x-mbx-order-count-* than 1m... + } Binance.info.futuresLatency = response.headers['x-response-time'] || 0; } } @@ -2760,7 +2760,19 @@ let api = function Binance( options = {} ) { * Returns the ping time from the last futures request * @return {object} - latency/ping (2ms) */ - futuresLatency: () => Binance.info.futuresLatency, + futuresLatency: () => Binance.info.futuresLatency, // Binance.futuresInfo.latency + + /** + * Returns the used weight from the last futures request + * @return {object} - 1m weight used + */ + futuresUsedWeight: () => Binance.futuresInfo.usedWeight, + + /** + * Returns the order count from the last futures request + * @return {object} - orders allowed per 1m + */ + futuresOrderCount: () => Binance.futuresInfo.orderCount, /** * Returns the complete URL from the last request