def on_message(self, ws, message): message = json.loads(message) data = message cp = self.currencypair[data['channel'].replace('_depth', '')] trades = {'asks': [], 'bids': []} for side in data: if side == 'asks': for order in data[side]: trades['asks'].append(td(float(order[0]), float(order[1]))) elif side == 'bids': for order in data[side]: trades['bids'].append(td(float(order[0]), float(order[1]))) try: Min, Max = self.data[cp].lastAsksLow, self.data[cp].lastBidsHigh self.data.update({cp: Traders()}) self.data[cp].lastAsksLow, self.data[cp].lastBidsHigh = Min, Max except: self.data.update({cp: Traders()}) self.data[cp].formate(trades, ZB) self.isReady = True Min = min(list(map(float, self.data[cp].asks.keys()))) Max = max(list(map(float, self.data[cp].bids.keys()))) if cp in self.targe: if (not Min == self.data[cp].lastAsksLow) or ( not Max == self.data[cp].lastBidsHigh): self.data[cp].lastAsksLow = min( list(map(float, self.data[cp].asks.keys()))) self.data[cp].lastBidsHigh = max( list(map(float, self.data[cp].bids.keys()))) callback(self.notice, cp)
def __init__(self, currencypair=['BTC_USDT', 'ETH_USDT'], targe=['BTC_USDT'], notice=None): self.data = {} self.isReady = False self.currencypair = currencypair for a in self.currencypair: self.data.update({a: Traders()}) self.caller = BittrexApi() self.targe = targe self.notice = notice self.restart = True
def __init__(self, currencypair=['BTC_USDT,ETH_USDT'], targe=['BTC_USDT'], notice=None): self.data = {} self.isReady = False self.currencypair = {} for a in currencypair: self.data.update({a: Traders()}) self.currencypair.update({a.replace('_', '').lower(): a}) self.targe = targe self.notice = notice self.channelId = {} self.restart = True
def __init__(self, currencypair=['BTC_USDT', 'ETH_USDT', 'ETH_BTC', 'ZEC_BTC'], targe=['BTC_USDT'], notice=None): self.p = True self.data = {} self.isReady = False self.currencypair = currencypair for a in currencypair: self.data.update({a: Traders()}) self.marketChannel = [] self.targe = targe self.notice = notice self.caller = Api() self.restart = True self.ids = {} self.cps = {}
def __init__(self, currencypair=['BTC_USDT'], targe=['BTC_USDT'], notice=None): self.p = True self.data = {} self.isReady = False self.currencypair = currencypair for a in self.currencypair: self.data.update({a: Traders()}) self.lastTime = time.time() self.targe = targe self.notice = notice self.name = OKEX self.restart = True