Candlestick
Candlesticks are generated from quote and trade data. The typical approach involves reading from NATS pub/sub, maintaining forming candles in memory, and persisting completed candles to QuestDB.
Candlestick Generation
This strategy for saving candlestick data is as follows:
- Subscribe to tick/quote feed based on channel from NATS
- In your code, you should store candlestick information to process trades or quotes
- On a new candlestick, write the previous candlestick to disk aka QuestDb
Notes
- The simplest method in using QuestDb for candlesticks is to only have a candlestick table per exchange that streams data into the table append only.
- If you need different timeframes, use Materialized Views for this as it's extremely fast and efficient but note you should only run this on PERIOD and not IMMEDIATE and each timeframe should cascade down from another in timeframe to reduce row query (i.e. 15 gets built from 5 minute and 5 minute gets built from 1 minute candlesticks)