The resource loading... loading...

Cancel ALL Binance Orders

Author: The grass, Date: 2018-10-13 14:25:38
Tags: BinanceStudyExtent-API

Binance cancels all transactions for uncompleted orders, using an IO interface, which can be used as an example of learning IO interface connections to support API interfaces


function cancellAll(){
    try{
        var openOrders = exchange.IO('api', 'GET', '/api/v3/openOrders');
        for (var i=0; i<openOrders.length; i++){
            var order = openOrders[i];
            var currency = '';
            if (order.symbol.endsWith('USDT')){
                currency = order.symbol.slice(0,order.symbol.length-4) + '_' + 'USDT';
            }
            else{
                currency = order.symbol.slice(0,order.symbol.length-3) + '_' + order.symbol.slice(order.symbol.length-3,order.symbol.length);
            }
            exchange.IO("currency", currency);
            exchange.CancelOrder(order.orderId);
        }
    }
    catch(err){
        Log('error');
    }
}
function main(){
    cancellAll()
}

Related

More