Skip to content

OHLC results in incorrect and sometimes random values #611

@jerryxwu

Description

@jerryxwu

Relevant system information:

  • OS: Ubuntu 22.04
  • PostgreSQL version (output of SELECT version();): 14.5
  • TimescaleDB Toolkit version (output of \dx timescaledb_toolkit in psql): 1.11.0
  • Installation method: "Timescale Cloud"

Describe the bug
Running the same query involving OHLC returns different results from run to run.

To Reproduce

Query involving more than one company:

SELECT time_bucket('1 hour'::interval, "time") AS ts,
symbol,
toolkit_experimental.open(toolkit_experimental.ohlc("time", price))
FROM stocks_real_time
GROUP BY ts, symbol;

Screenshot 2022-11-10 at 12 51 08 PM

There are at least two issues here:
  1. The same opening price is returned for different companies, which is just wrong.
  2. Different opening prices are returned from the same company from run to run.

Query involving only one company:

SELECT time_bucket('1 hour'::interval, "time") AS ts,
symbol,
toolkit_experimental.open(toolkit_experimental.ohlc("time", price))
FROM stocks_real_time
WHERE symbol IN ('AAPL')
GROUP BY ts, symbol;

Screenshot 2022-11-10 at 12 51 37 PM

Even restricting the query to just one company, from run to run, different opening prices are returned for the same time.

Additional context
Reported initially by @zseta , If no accessor (toolkit_experimental.open()) is specified, this query

SELECT time_bucket('1 minute'::interval, "time") AS ts,
  symbol,
  toolkit_experimental.ohlc("time", price)
FROM stocks_real_time
GROUP BY ts, symbol;

returns error:

ERROR:  timestamp out of range
CONTEXT:  extension/src/serialization.rs:39:13

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions