From a2c4d6372e386196ccf6e6edca6e1b42f48aa9f9 Mon Sep 17 00:00:00 2001 From: GoldenNaim <74271280+GoldenNaim@users.noreply.github.com> Date: Fri, 13 Nov 2020 02:12:26 +0100 Subject: [PATCH] Update influx.py (#133) --- cryptostore/data/influx.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cryptostore/data/influx.py b/cryptostore/data/influx.py index 418aa12..ee1f0a8 100644 --- a/cryptostore/data/influx.py +++ b/cryptostore/data/influx.py @@ -8,7 +8,7 @@ from collections import defaultdict import logging -from cryptofeed.defines import TRADES, L2_BOOK, L3_BOOK, TICKER, FUNDING, OPEN_INTEREST +from cryptofeed.defines import TRADES, L2_BOOK, L3_BOOK, TICKER, FUNDING, OPEN_INTEREST, LIQUIDATIONS import requests from cryptostore.exceptions import EngineWriteError @@ -92,6 +92,10 @@ def write(self, exchange, data_type, pair, timestamp): for entry in self.data: ts = int(Decimal(entry["timestamp"]) * 1000000000) agg.append(f'{data_type}-{exchange},pair={pair},exchange={exchange} open_interest={entry["open_interest"]},timestamp={entry["timestamp"]},receipt_timestamp={entry["receipt_timestamp"]} {ts}') + elif data_type == LIQUIDATIONS: + for entry in self.data: + ts = int(Decimal(entry["timestamp"]) * 1000000000) + agg.append(f'{data_type}-{exchange},pair={pair},exchange={exchange} side="{entry["side"]}",leaves_qty={entry["leaves_qty"]},order_id="{entry["order_id"]}",price="{entry["price"]}",timestamp={entry["timestamp"]},receipt_timestamp={entry["receipt_timestamp"]} {ts}') # https://v2.docs.influxdata.com/v2.0/write-data/best-practices/optimize-writes/ # Tuning docs indicate 5k is the ideal chunk size for batch writes