thu thập thông báo Binance và bán đồng xu Delist

Tác giả:Cỏ nhỏ, Ngày: 2019-02-15 18:33:28
Tags:Công cụĐược hỗ trợ thương mại

Nhấp vào trang thông báo của Binance để xem hai lần gần đây, định dạng cụ thể là Binance sẽ thả CLOAK, MOD, SALT, SUB, WINGS, và Binance sẽ thả BCN, CHAT, ICN, TRIG.

Reptilia sẽ sử dụng các từ khóa để lướt thông báo lướt mới, không loại trừ việc thay đổi định dạng thông báo của Binance để cải thiện chiến lược này. Vì nhiệm vụ của Reptilia quá đơn giản, nó sẽ được viết bằng JavaScript đơn giản. Sau khi lướt, nó sẽ kiểm tra thông tin tài khoản, nếu có tiền lướt, bán tất cả với giá thấp hơn, nếu có lệnh chưa hoàn thành, hủy trước. Một số người cho rằng, "Điều này không phải là một vấn đề lớn".https://zhuanlan.zhihu.com/p/57012933


var exchangeInfo = JSON.parse(HttpQuery('https://api.binance.com/api/v1/exchangeInfo'))
var pairInfo = {} 
var downList = []
if(exchangeInfo){
    for (var i=0; i<exchangeInfo.symbols.length; i++){
        var info = exchangeInfo.symbols[i];
        pairInfo[info.symbol] = {minQty:parseFloat(info.filters[2].minQty),tickerSize:parseFloat(info.filters[0].tickSize), 
            stepSize:parseFloat(info.filters[2].stepSize), minNotional:parseFloat(info.filters[3].minNotional)}
    }
}else{
    Log('fail to get exchangeInfo')
}
function sellAll(coin, free){
    var symbol = coin + 'BTC'
    exchange.IO("currency", coin+'_BTC')
    var ticker = _C(exchange.GetTicker)
    var sellPrice = _N(ticker.Buy*0.7, parseInt((Math.log10(1.1/pairInfo[symbol].tickerSize))))
    var sellAmount = _N(free, parseInt((Math.log10(1.1/pairInfo[symbol].stepSize))))
    if (sellAmount > pairInfo[symbol].minQty && sellPrice*sellAmount > pairInfo[symbol].minNotional){
        var id = exchange.Sell(sellPrice, sellAmount, symbol)
        exchange.CancelOrder(order.orderId)
    }
}
function cancellOrder(){
    var openOrders = exchange.IO('api', 'GET', '/api/v3/openOrders')
    for (var i=0; i<openOrders.length; i++){
        var order = openOrders[i];
        for (var j=0;j<downList.length;j++){
            if(order.symbol.startsWith(downList[j])){
                var currency = downList[j] + '_' + order.symbol.slice(downList[j].length);
                Log('delist coin exist, cancel all orders first', currency)
                exchange.IO("currency", currency)
                exchange.CancelOrder(order.orderId)
            }
        }
    }
}
function checkAccount(){
    var done = false
    while(!done){
        account = _C(exchange.GetAccount)
        done = true
        for (var i=0; i<account.Info.balances.length; i++){
            if(downList.indexOf(account.Info.balances[i].asset)>-1 && parseFloat(account.Info.balances[i].free)>pairInfo[account.Info.balances[i].asset+'BTC'].minQty){
                Log('this coin will be dumped', account.Info.balances[i].asset)
                sellAll(account.Info.balances[i].asset, parseFloat(account.Info.balances[i].free))
                done = false
            }
        }
        Sleep(1000)
    }
    Log('sell done')
}
function main() {
    var title = ''
    while(true){
        var html = HttpQuery('https://support.binance.com/hc/en-us/sections/115000202591-Latest-News')
        html = html.slice(html.indexOf('Delist '),html.length)
        if(html){
            if(html.slice(7,html.indexOf('</a>')) != title){
                title = html.slice(7,html.indexOf('</a>'))          
                downList = html.slice(7,html.indexOf('</a>')).replace(' and ', ',').split(',')
                Log('new announcement,will delist:', downList)
                cancellOrder()
                checkAccount()
            }else{
                Log('new announcement was not found')
            }
        }else{
            Log('web spider wrong')
        }
        Sleep(60*1000)
    }
}

Có liên quan

Thêm nữa