I have tick bid/ask data, how can I make candle data from tick's in clickhouse?

102 views Asked by At

I have tick bid/ask data, with columns

symbol
timestamp
ask_amount
ask_price
bid_price
bid_amount

what kind of query in clickhouse can tick data for equal candles with a length of 1 minute? How can I make candle data from ticks in clickhouse?

I try, but I don't know how to make equal candles

1

There are 1 answers

0
Rich Raposa On

Not knowing what aggregations you want in the "candle", here are a few arbitrary ones:

SELECT 
    symbol,
    toStartOfMinute(timestamp) AS minute,
    max(ask_amount),
    max(ask_price),
    max(bid_price),
    min(bid_price),
    avg(bid_amount)
FROM bids
GROUP BY (minute, symbol)
ORDER BY minute ASC