비트코인 발표 페이지로 이동하여 최근 2차례의 하차 정보를 살펴보세요. 구체적 형식은 Binance 하차 CLOAK,MOD,SALT,SUB,WINGS,BCN,CHAT,ICN,TRIGS입니다.
크래퍼는 을 을 키워드로 새 발표를 크래프할 것이며, 물론 코인안 변경 공지 형식을 참고하면 이 전략을 개선할 수 있다. 크래퍼의 임무가 너무 단순하기 때문에 간단한 자바스크립트로 작성한다. 동전까지 크래프한 후, 계정 정보를 확인하고, 동전이 있다면, 더 낮은 가격으로 모두 판매하고, 미완성 주문이 있다면, 먼저 철회한다. 이 글은 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)
}
}