Skip to content

Commit

Permalink
Update influx.py (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenNaim authored Nov 13, 2020
1 parent 20fa67f commit a2c4d63
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cryptostore/data/influx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a2c4d63

Please sign in to comment.