async def __call__(self, *, feed, pair, book, timestamp): ts = time.time() if self.redis is None: self.redis = await aioredis.create_redis_pool( 'redis://{}:{}'.format(self.host, self.port)) data = { 'timestamp': timestamp_normalize(feed, timestamp), BID: {}, ASK: {} } book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] data = json.dumps(data) await self.redis.zadd("{}-{}-{}".format(self.key, feed, pair), ts, data, exist=self.redis.ZSET_IF_NOT_EXIST)
async def __call__(self, *, feed, pair, book, timestamp): await self.connect() data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) upd = {'type': 'book', 'feed': feed, 'pair': pair, 'data': data} self.transport.sendto(json.dumps(upd).encode())
async def __call__(self, *, feed, pair, book, timestamp): await self.connect() data = {'timestamp': timestamp, 'delta': False, BID: {}, ASK: {}} book_convert(book, data, convert=self.numeric_type) data = json.dumps(data) await self.redis.xadd(f"{self.key}-{feed}-{pair}", {'data': data})
async def __call__(self, *, feed, pair, book, timestamp): await self._connect() data = {'timestamp': timestamp, 'delta': False, BID: {}, ASK: {}} book_convert(book, data) data = json.dumps(data).encode('utf8') topic = f"{self.key}-{feed}-{pair}" if self.key else f"book-{feed}-{pair}" await self.producer.send_and_wait(topic, data)
async def __call__(self, *, feed, pair, book, timestamp): await self.connect() data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data) upd = {'feed': feed, 'pair': pair, 'delta': False, 'data': data} await self.conn.default_exchange.publish( aio_pika.Message(body=f'book {json.dumps(upd)}'.encode()), routing_key='cryptofeed')
async def __call__(self, *, feed: str, pair: str, book: dict, timestamp: float, receipt_timestamp: float): data = { 'timestamp': timestamp, 'receipt_timestamp': receipt_timestamp, 'delta': False, BID: {}, ASK: {} } book_convert(book, data, convert=self.numeric_type) await self.write(feed, pair, timestamp, receipt_timestamp, data)
async def __call__(self, *, feed, pair, book, timestamp): data = {BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] start = f"{self.key}-{feed},pair={pair},delta=False" await self._write_rows(start, data, timestamp)
async def __call__(self, *, feed, pair, book, timestamp): ts = time.time() await self.connect() data = {'timestamp': timestamp, 'delta': False, BID: {}, ASK: {}} book_convert(book, data, convert=self.numeric_type) data = json.dumps(data) await self.redis.zadd(f"{self.key}-{feed}-{pair}", ts, data, exist=self.redis.ZSET_IF_NOT_EXIST)
async def __call__(self, *, feed, pair, book, timestamp): data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) upd = {'type': 'book', 'feed': feed, 'pair': pair, 'data': data} if self.depth: if upd['data'][BID] == self.previous[BID] and upd['data'][ASK] == self.previous[ASK]: return self.previous[ASK] = upd['data'][ASK] self.previous[BID] = upd['data'][BID] await self.con.send_json(upd)
async def __call__(self, *, feed, pair, book, timestamp): data = { 'timestamp': timestamp, 'feed': feed, 'pair': pair, 'delta': False, BID: {}, ASK: {} } book_convert(book, data, convert=lambda x: str(int(x * 10000))) await self.db[self.collection].insert_one(data)
async def __call__(self, *, feed, pair, book, timestamp): data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) upd = {'feed': feed, 'pair': pair, 'delta': False, 'data': data} if self.depth: if upd['data'][BID] == self.previous[BID] and upd['data'][ ASK] == self.previous[ASK]: return self.previous[ASK] = upd['data'][ASK] self.previous[BID] = upd['data'][BID] await self.con.send_string(f'book {json.dumps(upd)}')
async def __call__(self, *, feed, pair, book, timestamp): data = {BID: {}, ASK: {}} book_convert(book, data, convert=self.numeric_type) data = book_flatten(feed, pair, data, timestamp, False) data = itertools.chain(*zip([json.dumps({"index": {}})] * len(data), [json.dumps(d) for d in data])) data = '\n'.join(data) data = f"{data}\n" await self.write('POST', data, headers={'content-type': 'application/x-ndjson'})
async def __call__(self, *, feed, pair, book, timestamp): await self.connect() data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data) upd = { 'type': 'book', 'feed': feed, 'pair': pair, 'delta': False, 'data': data } self.write(upd)
async def __call__(self, *, feed, pair, book, timestamp): ts = time.time() if self.redis is None: self.redis = await aioredis.create_redis_pool( 'redis://{}:{}'.format(self.host, self.port)) data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) data = json.dumps(data) await self.redis.zadd("{}-{}-{}".format(self.key, feed, pair), ts, data, exist=self.redis.ZSET_IF_NOT_EXIST)
async def __call__(self, *, feed, pair, book, timestamp): await self.connect() data = {'timestamp': timestamp, 'delta': False, BID: {}, ASK: {}} book_convert(book, data, self.depth, convert=self.numeric_type) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] data = json.dumps(data) await self.redis.xadd(f"{self.key}-{feed}-{pair}", {'data': data})
async def __call__(self, *, feed, pair, book, timestamp): if self.redis is None: self.redis = await aioredis.create_redis_pool(f'redis://{self.host}:{self.port}') data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] flat = book_flatten(data, data['timestamp']) for update in flat: await self.redis.xadd(f"{self.key}-{feed}-{pair}", update)
async def __call__(self, *, feed, pair, book, timestamp): await self._connect() data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] data = json.dumps(data).encode('utf8') topic = f"{self.key}-{feed}-{pair}" if self.key else f"book-{feed}-{pair}" await self.producer.send_and_wait(topic, data)
async def __call__(self, *, feed, pair, book, timestamp): if self.redis is None: self.redis = await aioredis.create_redis_pool( f'redis://{self.host}:{self.port}') data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] data = json.dumps(data) await self.redis.xadd(f"{self.key}-{feed}-{pair}", {'data': data})
async def __call__(self, *, feed, pair, book, timestamp): data = {BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] start = f"{self.key}-{feed},pair={pair}" for side in (BID, ASK): for price, val in data[side].items(): if isinstance(val, dict): for order_id, amount in val.items(): await self.write(f'{start} side="{side}",id="{order_id}",timestamp={timestamp},price="{price}",amount="{amount}"') else: await self.write(f'{start} side="{side}",price="{price}",timestamp={timestamp},amount="{val}"')
async def __call__(self, *, feed, pair, book, timestamp): data = { 'timestamp': timestamp, 'feed': feed, 'pair': pair, BID: {}, ASK: {} } book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] await self.db[self.collection].insert_one(data)
async def __call__(self, *, feed, pair, book, timestamp): if self.redis is None: self.redis = await aioredis.create_redis_pool( 'redis://{}:{}'.format(self.host, self.port)) data = { 'timestamp': timestamp_normalize(feed, timestamp), BID: {}, ASK: {} } book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] await self.redis.xadd(f"{self.key}-{feed}-{pair}", data)
async def __call__(self, *, feed, pair, book, timestamp): data = {BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] start = f"{feed},pair={pair},feed=book," body = "" for side in (BID, ASK): for price, val in data[side].items(): if isinstance(val, dict): for order_id, amount in val.items(): body += start + f'side={side},id={order_id} timestamp="{timestamp}",price={price},amount={amount}\n' else: body += start + f'side={side} timestamp="{timestamp}",price={price},amount={val}\n' await self.write(body)
async def __call__(self, *, feed, pair, book, timestamp): ts = time.time() if self.redis is None: self.redis = await aioredis.create_redis_pool( f'redis://{self.host}:{self.port}') data = {'timestamp': timestamp, 'delta': False, BID: {}, ASK: {}} book_convert(book, data, self.depth) if self.depth: if data[BID] == self.previous[BID] and data[ASK] == self.previous[ ASK]: return self.previous[ASK] = data[ASK] self.previous[BID] = data[BID] data = json.dumps(data) await self.redis.zadd(f"{self.key}-{feed}-{pair}", ts, data, exist=self.redis.ZSET_IF_NOT_EXIST)
async def __call__(self, *, feed, pair, book, timestamp): data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data) upd = {'feed': feed, 'pair': pair, 'delta': False, 'data': data} await self.con.send_string(f'book {json.dumps(upd)}')
async def __call__(self, *, feed, pair, book, timestamp): data = {'timestamp': timestamp, 'delta': False, BID: {}, ASK: {}} book_convert(book, data, convert=self.numeric_type) await self.write(feed, pair, timestamp, data)
async def __call__(self, *, feed, pair, book, timestamp): data = {'timestamp': timestamp, BID: {}, ASK: {}} book_convert(book, data, self.depth) upd = {'type': 'book', 'feed': feed, 'pair': pair, 'data': data} await self.con.send_json(upd)
async def __call__(self, *, feed: str, symbol: str, book: dict, timestamp: float, receipt_timestamp: float): data = {BID: {}, ASK: {}} book_convert(book, data, convert=self.numeric_type) await self.write(feed, symbol, timestamp, receipt_timestamp, data)
async def __call__(self, *, feed, pair, book, timestamp): data = {BID: {}, ASK: {}} book_convert(book, data) start = f"{self.key}-{feed},pair={pair},delta=False" await self._write_rows(start, data, timestamp)