Resample
analytics_resampleResample a stored time series to a coarser timeframe locally in DuckDB. Aggregate bars with OHLCV rules or other values by last, first, mean, sum, min, or max into UTC-aligned buckets.
Instructions
Resample a stored time series to a coarser timeframe, computed locally in DuckDB. Bars: open = first, high = max, low = min, close = last, volume = sum, trade_count = sum (None if any bar lacks it), vwap = volume-weighted (None when the volume is 0); the target must be coarser than the bars and hold whole bars. Other series (quotes, trades, snapshots, portfolio history, query results): each value column aggregated with agg (last, first, mean, sum, min, max) per series and bucket; other columns come from the bucket's last row. Rows with a NaN or infinite value are skipped. Buckets are UTC-aligned (weeks start Monday 00:00 UTC; t = bucket start). The output has the input's model. Large outputs are stored and you get a result_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agg | No | Aggregation of each value column for inputs that are not bars (bars use OHLCV rules). | last |
| result_id | Yes | A stored time series: bars, or quotes, trades, snapshots, portfolio history, ... | |
| timeframe | Yes | Target bucket: Nmin, Nh, 1d, 1w (Monday 00:00 UTC), Nmo; coarser than the input's bars. | |
| series_column | No | Column naming each series. Default: the result's group column. |