docs
docs copied to clipboard
[Feedback] Page: /api/latest/hyperfunctions/time_bucket/
Is it easy to find the information you need?
Yes
Are the instructions clear?
Yes
How could we improve the Timescale documentation site?
the time_bucket fuction lost precision when the timestamp not reach 3rd second yet.
the DDL is followed as
create table delta ( id bigint default nextval('delta_id_seq'::regclass), symbol varchar(16), delta_value numeric(18, 5), delta_ratio numeric(5, 3), open_price numeric(18, 5), high_price numeric(18, 5), close_price numeric(18, 5), low_price numeric(18, 5), amount numeric(18, 5), trading_date_time timestamp not null, volume numeric(18, 6), seconds integer, ask_amount numeric(18, 5), bid_amount numeric(18, 5) );
SELECT time_bucket('${timeFrame}', trading_date_time) AS bucket, symbol as symbol, FIRST(open_price, trading_date_time) AS openPrice, MAX(high_price) AS highPrice, MIN(low_price) AS lowPrice, LAST(close_price, trading_date_time) AS closePrice, SUM(volume) AS volume, '${timeFrame}' as timeFrame FROM delta where trading_date_time between #{start} and #{end} and symbol = #{symbol} GROUP BY bucket, symbol order by bucket
case is here:
-
if the timestamp is after the 3rd second of each minute, the time_bucket can return the latest candle aggregation result like this
-
on the contrary.
hope for response.
Thank you for the report. We welcome documentation contributions!
- For information about how to propose a change, see the contributing guide in our GitHub repository.
- For information on style and word usage, see the style guide
Hello @lyncodes! Could you please provide some raw data which triggers this issue?
I had a play but can't seem to produce your output.
One possible reason could be that your timestamps for the 14:33 bucket start at 14:33:04 (and so are excluded by your WHERE), but I'm guessing you've checked this?
sorry for late respose. yes, the problem is still there. here is the sample data tsdb_public_delta.zip
============== my expectation is this: if timestamp reach 14:10:59, the bucket should only reach 14:10. only if the timestamp crossed 14:11:00, means this minute is over, then the bucket can reach 14:11 but current senerior is weird. pass the 3rd second will return the new bucket. 😂😂😂
thanks.