async def __call__(self, *, feed, pair, delta, timestamp): ts = time.time() await self.connect() data = {'timestamp': timestamp, 'delta': True, BID: {}, ASK: {}} book_delta_convert(delta, 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, delta, timestamp): await self.connect() data = {'timestamp': timestamp, 'delta': True, BID: {}, ASK: {}} book_delta_convert(delta, 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, delta, timestamp): await self._connect() data = {'timestamp': timestamp, 'delta': True, BID: {}, ASK: {}} book_delta_convert(delta, 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, delta, timestamp): await self.connect() data = {'timestamp': timestamp, BID: {}, ASK: {}} book_delta_convert(delta, data) upd = {'feed': feed, 'pair': pair, 'delta': True, '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, pair, delta, timestamp): if self.redis is None: self.redis = await aioredis.create_redis_pool( f'redis://{self.host}:{self.port}') data = {'timestamp': timestamp, 'delta': True, BID: {}, ASK: {}} book_delta_convert(delta, data) data = json.dumps(data) await self.redis.xadd(f"{self.key}-{feed}-{pair}", {'data': data})
async def __call__(self, *, feed: str, pair: str, delta: dict, timestamp: float, receipt_timestamp: float): data = { 'timestamp': timestamp, 'receipt_timestamp': receipt_timestamp, 'delta': True, BID: {}, ASK: {} } book_delta_convert(delta, data, convert=self.numeric_type) await self.write(feed, pair, timestamp, receipt_timestamp, data)
async def __call__(self, *, feed, pair, delta, timestamp): start = f"{self.key}-{feed},pair={pair},delta=True" data = {BID: {}, ASK: {}} book_delta_convert(delta, data) 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, delta, timestamp): data = { 'timestamp': timestamp, 'feed': feed, 'pair': pair, 'delta': True, BID: {}, ASK: {} } book_delta_convert(delta, data, convert=lambda x: str(int(x * 10000))) await self.db[self.collection].insert_one(data)
async def __call__(self, *, feed, pair, delta, timestamp): data = {'timestamp': timestamp, BID: {}, ASK: {}} book_delta_convert(delta, data) upd = { 'type': 'book', 'feed': feed, 'pair': pair, 'delta': True, 'data': data } await self.con.send_json(upd)
async def __call__(self, *, feed, pair, delta, 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': True, BID: {}, ASK: {}} book_delta_convert(delta, data) 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, delta, timestamp): data = {BID: {}, ASK: {}} book_delta_convert(delta, data, convert=self.numeric_type) data = book_flatten(feed, pair, data, timestamp, True) 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, delta, timestamp, receipt_timestamp): delta_update = {"bid": [], "ask": []} for side in (BID, ASK): for price, size in delta[side]: if price in self.book[pair][side]: size_delta = size - self.book[pair][side][price] else: size_delta = size if abs(size_delta) > 0: delta_update[side].append((price, size_delta)) data = {'timestamp': timestamp, 'delta': True, BID: {}, ASK: {}} book_delta_convert(delta_update, data, convert=self.numeric_type) await self.write(feed, pair, timestamp, receipt_timestamp, data)
async def __call__(self, *, feed, pair, delta, timestamp): data = {'timestamp': timestamp, 'delta': True, BID: {}, ASK: {}} book_delta_convert(delta, data, convert=self.numeric_type) await self.write(feed, pair, timestamp, data)
async def __call__(self, *, feed, pair, delta, timestamp): start = f"{self.key}-{feed},pair={pair},delta=True" data = {BID: {}, ASK: {}} book_delta_convert(delta, data) await self._write_rows(start, data, timestamp)
async def __call__(self, *, feed, pair, delta, timestamp): data = {'timestamp': timestamp, BID: {}, ASK: {}} book_delta_convert(delta, data) upd = {'feed': feed, 'pair': pair, 'delta': True, 'data': data} await self.con.send_string(f'book {json.dumps(upd)}')