Storing orders, trades data in Influxdb

#1

Hello,

My name is Anish. I just started to use influx and would like to store crypto (trade, order) data.
The data comes from a websocket as JSON, i will parse using Java and would like to write to influx.
Should i be creating:
different measurements like asks, trades, bids?
use Tags like currency_pair, trade_type?
use Fields like price, amount, tid, last_price?

Sorry, i am perplexed on how to write all the below data to influx, any pointers should be very helpful.

Thanks and Regards
Anish

Below is the data that comes as a single JSON:
{“asks”:
[
[38.5097,64.0],
[38.51,1211.0],
[38.59,7.2],
],
“last_price”:{“action”:“ask”,“price”:38.5},
“target_users”:[“sadasda”],
“trades”:
[
{“currency_pair”:“xem_jpy”,“trade_type”:“ask”,“price”:38.5,“currency_pair”:“xem_jpy”,“date”:1521088883,“amount”:1343.0,“tid”:106350611},
{“currency_pair”:“xem_jpy”,“trade_type”:“ask”,“price”:38.5,“currency_pair”:“xem_jpy”,“date”:1521088879,“amount”:1851.0,“tid”:106350587},
{“currency_pair”:“xem_jpy”,“trade_type”:“ask”,“price”:38.5,“currency_pair”:“xem_jpy”,“date”:1521088872,“amount”:29.0,“tid”:106350580},
],
“bids”:
[
[38.5,5032.9],
[38.4,4.0],
[38.344,4495.8],
],
“currency_pair”:“xem_jpy”,“timestamp”:“2018-03-15 13:41:24.923787”}

#2

Hi Anish,

You ask a really great question. Schema design is really important to your InfluxDB instance as it can heavily impact the database’s query performance. I think you’re pretty on point with what you have so far, but I would also recommend reading through the InfluxDB schema design documentation to gain a better understanding of how you want to organize your data within InfluxDB. The docs discuss general guidelines - for example, it’s best practice to store meta data in tags rather than fields, as queries on tags are more performant than those on fields, and tags are always stored as strings (so if the value needs to be a non-string, it should be stored as a field value).

Hopefully this provides a better understanding of how you can design your schema for InfluxDB.

Best of luck!