import ccxt
from pprint import pprint
import time
from numpy import NaN
baseCurrrency='BTC'
aimCurrency='ETH'
pair=aimCurrency+'/'+baseCurrrency
limit=3
highLimit=0.2
lowLimit=0.001
Exchanges=[]
Exchanges.append(ccxt.huobipro())
Exchanges.append(ccxt.lbank())
Exchanges.append(ccxt.zb())
Exchanges.append(ccxt.bittrex())
Exchanges.append(ccxt.bigone())
Exchanges.append(ccxt.bitz())
Names=['火币','lbank','zb','bittrex','bigone','bitz']
bids=[NaN for i in Exchanges]
bidVolum=[NaN for i in Exchanges]
asks=[NaN for i in Exchanges]
askVolum=[NaN for i in Exchanges]whileTrue:for i inrange(6):try:
mes=Exchanges[i].fetch_order_book(pair,limit)
bidPrice=mes['bids'][0][0]
askPrice=mes['asks'][0][0]if bidPrice<highLimit and bidPrice>lowLimit :
bids[i]=bidPrice
else:
bids[i]=NaN
if askPrice < highLimit and askPrice > lowLimit:
asks[i]=askPrice
else:
asks[i]=NaN
bidVolum[i]=mes['bids'][0][1]
askVolum[i]=mes['asks'][0][1]except:
asks[i]=NaN
bids[i]=NaN
askVolum[i]=NaN
bidVolum[i]=NaN
print(str(Exchanges[i])+'_error')
sellPrice=max(bids)
buyPrice=min(asks)if sellPrice>buyPrice :
sellIndex=bids.index(max(bids))
buyIndex=asks.index(min(asks))print('buy in '+Names[buyIndex]+' and sell in '+Names[sellIndex]+' profit='+str(sellPrice-buyPrice))