From 17f615fec3052f2cb2e9f1b4ab7c2894c76e87e5 Mon Sep 17 00:00:00 2001 From: elihaidv Date: Wed, 6 Apr 2022 13:18:33 +0300 Subject: [PATCH 1/4] Update node-binance-api.js Add options parameter on cacnel --- node-binance-api.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/node-binance-api.js b/node-binance-api.js index 615485fc..559afcaf 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -2990,10 +2990,15 @@ let api = function Binance( options = {} ) { * Cancels an order * @param {string} symbol - the symbol to cancel * @param {string} orderid - the orderid to cancel + * @param {object} options - options for the request * @param {function} callback - the callback function * @return {promise or undefined} - omitting the callback returns a promise */ - cancel: function ( symbol, orderid, callback = false ) { + cancel: function ( symbol, orderid, options, callback = false ) { + if (typeof options === 'function') { // Accept callback as third parameter + callback = options; + options = {} + } if ( !callback ) { return new Promise( ( resolve, reject ) => { callback = ( error, response ) => { @@ -3003,7 +3008,9 @@ let api = function Binance( options = {} ) { resolve( response ); } } - signedRequest( base + 'v3/order', { symbol: symbol, orderId: orderid }, function ( error, data ) { + options.symbol = symbol + options.orderId = orderid + signedRequest( base + 'v3/order', options, function ( error, data ) { return callback.call( this, error, data, symbol ); }, 'DELETE' ); } ) From f6119e7cd510f6a2c7a2dfac5b164b566e89c4d3 Mon Sep 17 00:00:00 2001 From: elihaidv Date: Wed, 6 Apr 2022 13:21:23 +0300 Subject: [PATCH 2/4] Update node-binance-api.js Adding options parameter --- node-binance-api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node-binance-api.js b/node-binance-api.js index 559afcaf..ec67735b 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -3015,7 +3015,10 @@ let api = function Binance( options = {} ) { }, 'DELETE' ); } ) } else { - signedRequest( base + 'v3/order', { symbol: symbol, orderId: orderid }, function ( error, data ) { + + options.symbol = symbol + options.orderId = orderid + signedRequest( base + 'v3/order', options, function ( error, data ) { return callback.call( this, error, data, symbol ); }, 'DELETE' ); } From 3edf465f5e9650a7c9879f6c805ffc57a4934031 Mon Sep 17 00:00:00 2001 From: elihaidv Date: Thu, 4 May 2023 09:29:44 +0300 Subject: [PATCH 3/4] Add error catch when subscribe to `userFutureData` --- node-binance-api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node-binance-api.js b/node-binance-api.js index c9302d8d..f7928d05 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -5403,7 +5403,7 @@ let api = function Binance( options = {} ) { * @param {function} order_update_callback * @param {Function} subscribed_callback - subscription callback */ - userFutureData: function userFutureData( margin_call_callback, account_update_callback = undefined, order_update_callback = undefined, subscribed_callback = undefined, account_config_update_callback = undefined ) { + userFutureData: function userFutureData( margin_call_callback, account_update_callback = undefined, order_update_callback = undefined, subscribed_callback = undefined, account_config_update_callback = undefined, error_callback = undefined ) { const url = ( Binance.options.test ) ? fapiTest : fapi; let reconnect = () => { @@ -5411,6 +5411,7 @@ let api = function Binance( options = {} ) { } apiRequest( url + 'v1/listenKey', {}, function ( error, response ) { + if (error) return error_callback && error_callback(error.body); Binance.options.listenFutureKey = response.listenKey; setTimeout( function userDataKeepAlive() { // keepalive try { From 5b883e3deb6c45086316030224a06962db3f6866 Mon Sep 17 00:00:00 2001 From: elihaidv Date: Thu, 4 May 2023 09:30:55 +0300 Subject: [PATCH 4/4] Add error callback type --- node-binance-api.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-binance-api.d.ts b/node-binance-api.d.ts index 8aeb610f..1bb60b34 100644 --- a/node-binance-api.d.ts +++ b/node-binance-api.d.ts @@ -56,7 +56,7 @@ declare module "node-binance-api" { * @param {function} order_update_callback * @param {Function} subscribed_callback - subscription callback */ - userFutureData(margin_call_callback: _callback, account_update_callback: _callback, order_update_callback: _callback, subscribed_callback: _callback): any; + userFutureData(margin_call_callback: _callback, account_update_callback: _callback, order_update_callback: _callback, subscribed_callback: _callback, error_callback:_callback): any; userFutureData(...args: any): any; /**