You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: missing OHLC bars (candlestick) for financial data when there is no transaction.
I am expecting that even if the tick data is missing for that period, it still produces a new bar with Open=High=Low=Closed=Previous closed.
I have a tick table in timescaledb as follows from which I create a materialized view for 1-minute OHLC bars with its corresponding refresh policy. However, my tick_1min table does not end up having the correct OHLC bar and there are missing bars in the table, as can be seen in below. I have created a trigger signal that whenever the OHLC is created in the table a client is notified and will act upon the new data to process the update.
CREATE TABLE tick
(
tstamp TIMESTAMP WITH TIME ZONE NOT NULL,
tstamp_micro INT NOT NULL,
exchange VARCHAR(100) NOT NULL,
symbol VARCHAR(100) NOT NULL,
price DOUBLE PRECISION NOT NULL,
vwap DOUBLE PRECISION NOT NULL,
size INT NOT NULL,
volume_bought INT NOT NULL,
volume_sold INT NOT NULL,
side SMALLINT NOT NULL,
context VARCHAR(200) DEFAULT NULL
);
SELECT create_hypertable('tick', 'tstamp');
materialized view for 1-minute OHLC bars
CREATE MATERIALIZED VIEW tick_1min
WITH (timescaledb.continuous) AS
SELECT time_bucket('1 minute', tstamp) AS bucket,
symbol,
first(tick.price, tick."tstamp") AS open,
max(tick.price) AS high,
min(tick.price) AS low,
last(tick.price, tick."tstamp") AS close
FROM tick
GROUP BY symbol, bucket;
-- Refresh policy
SELECT add_continuous_aggregate_policy('tick_1min',
start_offset => INTERVAL '1 day', --
end_offset => INTERVAL '1 minute',
schedule_interval => INTERVAL '1 minute');
-- Manual refresh
CALL refresh_continuous_aggregate('tick_1min', now() - interval '1 week', now())
Missing rows in tick_1min, e.g., data from 22:25:00 to 22:28:00 is not added (with expected Open=High=Low=Closed=Previous closed)
afpgit
changed the title
Missing rows in a continuous aggregate hypertable: financial tick data
Missing rows in a continuous aggregate hypertable
Feb 22, 2024
afpgit
changed the title
Missing rows in a continuous aggregate hypertable
[Bug]: Missing rows in a continuous aggregate hypertable
Feb 22, 2024
afpgit
changed the title
[Bug]: Missing rows in a continuous aggregate hypertable
[Bug]: Continuous Aggregate - Missing rows in hypertable
Feb 22, 2024
Thanks for reaching out. The reported behavior is the expected behavior of a continuous aggregate using time_bucket. When no data is available in the raw hypertable, no data is available in the continuous aggregate.
However, there are two different time_bucket functions available in TimescaleDB: time_bucket and time_bucket_gapfill. time_bucket_gapfill is intended to fill the gaps of missing data with previous values.
So, time_bucket_gapfill is intended to handle use-cases like yours. Unfortunately, time_bucket_gapfill is currently not supported in continuous aggregates (see #1324). I will keep the issue open but re-label it from bug to enhancement.
What type of bug is this?
Incorrect result
What subsystems and features are affected?
Continuous aggregate
What happened?
Problem: missing OHLC bars (candlestick) for financial data when there is no transaction.
I am expecting that even if the tick data is missing for that period, it still produces a new bar with Open=High=Low=Closed=Previous closed.
I have a tick table in timescaledb as follows from which I create a materialized view for 1-minute OHLC bars with its corresponding refresh policy. However, my
tick_1min
table does not end up having the correct OHLC bar and there are missing bars in the table, as can be seen in below. I have created a trigger signal that whenever the OHLC is created in the table a client is notified and will act upon the new data to process the update.materialized view for 1-minute OHLC bars
Missing rows in
tick_1min
, e.g., data from 22:25:00 to 22:28:00 is not added (with expected Open=High=Low=Closed=Previous closed)TimescaleDB version affected
2.10.2
PostgreSQL version used
14.7
What operating system did you use?
Ubuntu 14.7-1.pgdg22.04+1
What installation method did you use?
Docker
What platform did you run on?
Other
Relevant log output and stack trace
No response
How can we reproduce the bug?
The text was updated successfully, but these errors were encountered: