def say(): while(1): global k global sell global buy global numvar global trading price=HuobiService.getPrice() price=eval(price) ticker=price['ticker'] sell=round(ticker['sell'],2) buy=round(ticker['buy'],2) if stage==2 or stage==3: if text[1]=='M': if text[0]=='B': numvar=sell if text[0]=='S': numvar=buy if text[1]=='H': numvar=round(((sell+buy)/2),2) if text[1]=='B': if text[0]=='B': numvar=buy if text[0]=='S': numvar=sell global comment ordStatus=HuobiService.getOrders(1,GET_ORDERS) k=k+1 if str(ordStatus)=='[]' and trading==1 and k>=6: k=0 trading=0 comment=comment+'Done!' show(text,sell,buy,stage,way,method,numvar,amounttp,offset,comment) sleep(0.5)
canned=0 Trade_Pass='******' def sellit(sellat): print ("限价卖出:"+str(sellat)) print (HuobiService.sell(1,str(sellat),amount,Trade_Pass,None,SELL)) def buyit(buyat): print ("限价买入:"+str(buyat)) print (HuobiService.buy(1,str(buyat),amount,Trade_Pass,None,BUY)) if __name__ == "__main__": #print("获取所有正在进行的委托") print(HuobiService.getOrders(1,GET_ORDERS)) while(1): sleep(0.3) price=HuobiService.getPrice() price=eval(price) ticker=price['ticker'] sell=round(ticker['sell'],2) buy=round(ticker['buy'],2) print('Ask:'+str(sell)) print('Bid:'+str(buy)) sellat=round(sell-0.02,2) buyat=round(buy+0.02,2) spread=(sell*100-buy*100)/100 print('Spread:'+str(spread)) ordStatus=HuobiService.getOrders(1,GET_ORDERS) if(str(ordStatus)=='[]'): if spread>=0.15 and spread<=1: c=c+1 print(c);