def _current_orders_extractor(cls, data, max_qty=3): ''' Method for extracting orders ''' orders = {} bids = {} asks = {} buymax = 0 sellmax = 0 for level in data["bids"]: if buymax > max_qty: continue else: bids[apply_format_level(level["price"])] = "{:.8f}".format(float(level["amount"])) buymax = buymax + float(level["amount"]) for level in data["asks"]: if sellmax > max_qty: continue else: asks[apply_format_level(level["price"])] = "{:.8f}".format(float(level["amount"])) sellmax = sellmax + float(level["amount"]) orders["source"] = "Bitfinex" orders["bids"] = bids orders["asks"] = asks orders["timestamp"] = str(int(time.time())) return orders
def _current_orders_extractor(cls, data, max_qty=3): orders = {} bids = {} asks = {} buymax = 0 sellmax = 0 for level in data["bids"]: if buymax > max_qty: pass else: bids[apply_format_level(level[0])] = "{:.8f}".format(float(level[1])) buymax = buymax + float(level[1]) for level in data["asks"]: if sellmax > max_qty: pass else: asks[apply_format_level(level[0])] = "{:.8f}".format(float(level[1])) sellmax = sellmax + float(level[1]) orders["source"] = "OKCoin" orders["bids"] = bids orders["asks"] = asks orders["timestamp"] = str(int(time.time())) return orders
def _current_orders_extractor(cls, data, max_qty=100.0): orders = {} bids = {} asks = {} buymax = 0.0 sellmax = 0.0 pair = data["result"].keys()[0] for level in data["result"][pair]["bids"]: print level if buymax > max_qty: pass else: asks[apply_format_level(level[0])] = "{:.8f}".format(float(level[1])) buymax = buymax + float(level[1]) for level in data["result"][pair]["asks"]: if sellmax > max_qty: pass else: bids[apply_format_level(level[0])] = "{:.8f}".format(float(level[1])) sellmax = sellmax + float(level[1]) orders["source"] = "Kraken" orders["bids"] = bids orders["asks"] = asks orders["timestamp"] = str(int(time.time())) return orders