Skip to content

candlestick_agg()

Aggregate tick data into an intermediate form for further calculation

Since 1.14.0

This is the first step for performing financial calculations on raw tick data. Use candlestick_agg to create an intermediate aggregate from your tick data. This intermediate form can then be used by one or more accessors in this group to compute final results.

Optionally, multiple such intermediate aggregate objects can be combined using rollup() before an accessor is applied.

If you’re starting with pre-aggregated candlestick data rather than raw tick data, use the companion candlestick() function instead. This function transforms the existing aggregated data into the correct form for use with the candlestick accessors.

The syntax is:

candlestick_agg(
ts TIMESTAMPTZ,
price DOUBLE PRECISION,
volume DOUBLE PRECISION
) RETURNS Candlestick
NameTypeDefaultRequiredDescription
tsTIMESTAMPTZ-Timestamp associated with stock price
priceDOUBLE PRECISION-Stock quote/price at the given time
volumeDOUBLE PRECISION-Volume of the trade
ColumnTypeDescription
aggCandlestickAn object storing (timestamp, value) pairs for each of the opening, high, low, and closing prices, in addition to information used to calculate the total volume and Volume Weighted Average Price.