@@ -284,6 +284,12 @@ export default class Binance {
284284 }
285285
286286 if ( response && response . status !== 200 ) {
287+ // let parsedResponse = '';
288+ // try {
289+ // parsedResponse = await response.json();
290+ // } catch (e) {
291+ // parsedResponse = await response.text();
292+ // }
287293 const error = new Error ( await response . text ( ) ) ;
288294 // error.code = response.status;
289295 // error.url = response.url;
@@ -751,7 +757,7 @@ export default class Binance {
751757 * @param {string } orderid - the orderid to cancel
752758 * @return {promise or undefined } - omitting the callback returns a promise
753759 */
754- async cancel ( symbol : string , orderid : string , params : Dict = { } ) : Promise < CancelOrder > {
760+ async cancel ( symbol : string , orderid : number | string , params : Dict = { } ) : Promise < CancelOrder > {
755761 return await this . privateSpotRequest ( 'v3/order' , this . extend ( { symbol : symbol , orderId : orderid } , params ) , 'DELETE' ) ;
756762 }
757763
@@ -763,7 +769,7 @@ export default class Binance {
763769* @param {object } flags - any additional flags
764770* @return {promise or undefined } - omitting the callback returns a promise
765771*/
766- async orderStatus ( symbol : string , orderid ?: string , flags = { } ) {
772+ async orderStatus ( symbol : string , orderid ?: number | string , flags = { } ) {
767773 let parameters = Object . assign ( { symbol : symbol } , flags ) ;
768774 if ( orderid ) {
769775 parameters = Object . assign ( { orderId : orderid } , parameters ) ;
@@ -788,33 +794,33 @@ export default class Binance {
788794 * @param {string } symbol - the symbol to cancel all orders for
789795 * @return {promise or undefined } - omitting the callback returns a promise
790796 */
791- async cancelAll ( symbol : string , params : Dict = { } ) {
797+ async cancelAllOrders ( symbol : string , params : Dict = { } ) {
792798 return await this . privateSpotRequest ( 'v3/openOrders' , this . extend ( { symbol } , params ) , 'DELETE' ) ;
793799 }
794800
795- /**
796- * Cancels all orders of a given symbol
797- * @param {string } symbol - the symbol to cancel all orders for
798- * @return {promise or undefined } - omitting the callback returns a promise
799- */
800- async cancelOrders ( symbol : string , params : Dict = { } ) {
801- const json = await this . privateSpotRequest ( 'v3/openOrders' , this . extend ( { symbol : symbol } , params ) , 'DELETE' ) ;
802- // if (json.length === 0) {
803- // return callback.call(this, 'No orders present for this symbol', {}, symbol);
804- // }
805- // if (Object.keys(json).length === 0) {
806- // return callback.call(this, 'No orders present for this symbol', {}, symbol);
807- // }
808- // for (let obj of json) {
809- // let quantity = obj.origQty - obj.executedQty;
810- // this.options.log('cancel order: ' + obj.side + ' ' + symbol + ' ' + quantity + ' @ ' + obj.price + ' #' + obj.orderId);
811- // signedRequest(this.getSpotUrl() + 'v3/order', { symbol: symbol, orderId: obj.orderId }, function (error, data) {
812- // return callback.call(this, error, data, symbol);
813- // }, 'DELETE');
814- // }
815- return json ; // to do: check this logic of cancelling remaining orders manually
801+ // / **
802+ // * Cancels all orders of a given symbol
803+ // * @param {string } symbol - the symbol to cancel all orders for
804+ // * @return {promise or undefined } - omitting the callback returns a promise
805+ // */
806+ // async cancelOrders(symbol: string, params: Dict = {}) {
807+ // const json = await this.privateSpotRequest('v3/openOrders', this.extend({ symbol: symbol }, params), 'DELETE');
808+ // // if (json.length === 0) {
809+ // // return callback.call(this, 'No orders present for this symbol', {}, symbol);
810+ // // }
811+ // // if (Object.keys(json).length === 0) {
812+ // // return callback.call(this, 'No orders present for this symbol', {}, symbol);
813+ // // }
814+ // // for (let obj of json) {
815+ // // let quantity = obj.origQty - obj.executedQty;
816+ // // this.options.log('cancel order: ' + obj.side + ' ' + symbol + ' ' + quantity + ' @ ' + obj.price + ' #' + obj.orderId);
817+ // // signedRequest(this.getSpotUrl() + 'v3/order', { symbol: symbol, orderId: obj.orderId }, function (error, data) {
818+ // // return callback.call(this, error, data, symbol);
819+ // // }, 'DELETE');
820+ // // }
821+ // return json; // to do: check this logic of cancelling remaining orders manually
816822
817- }
823+ // }
818824
819825 /**
820826 * Gets all order of a given symbol
@@ -4127,7 +4133,7 @@ export default class Binance {
41274133 * @param params extra parameters to be sent in the request
41284134 * @returns
41294135 */
4130- async futuresCancel ( symbol : string , orderId ?: string , params : Dict = { } ) : Promise < CancelOrder > { // Either orderId or origClientOrderId must be sent
4136+ async futuresCancel ( symbol : string , orderId ?: number | string , params : Dict = { } ) : Promise < CancelOrder > { // Either orderId or origClientOrderId must be sent
41314137 params . symbol = symbol ;
41324138 if ( orderId ) params . orderId = orderId ;
41334139 return await this . privateFuturesRequest ( 'v1/order' , params , 'DELETE' ) ;
@@ -4579,7 +4585,7 @@ export default class Binance {
45794585 * @param {string } orderid - the orderid to cancel
45804586 * @return {undefined }
45814587 */
4582- async mgCancel ( symbol : string , orderid : string , isIsolated = 'FALSE' ) : Promise < CancelOrder > {
4588+ async mgCancel ( symbol : string , orderid : number | string , isIsolated = 'FALSE' ) : Promise < CancelOrder > {
45834589 return await this . privateSpotRequest ( 'v1/margin/order' , { symbol : symbol , orderId : orderid , isIsolated } , 'DELETE' ) ;
45844590 }
45854591
@@ -4601,7 +4607,7 @@ export default class Binance {
46014607 * @param {object } flags - any additional flags
46024608 * @return {undefined }
46034609 */
4604- async mgOrderStatus ( symbol : string , orderid : string , flags = { } ) : Promise < Order > {
4610+ async mgOrderStatus ( symbol : string , orderid : number | string , flags = { } ) : Promise < Order > {
46054611 const parameters = Object . assign ( { symbol : symbol , orderId : orderid } , flags ) ;
46064612 return await this . privateSpotRequest ( 'v1/margin/order' , parameters ) ;
46074613 }
0 commit comments