Query series data with range

Let’s say i insert multiple series data for a symbol “XXC”, with interval of 1000 (1 second), is there a way to query the data using range, let’s say 5min, 15min, 1h .e.t.c

{
  "ticker": "XXC",
  "ts_start": 1677730930000,
  "ts_end": 1677730939000,
  "ts_interval": 1000,
  "ts_data": [ 16.30, 16.31, 16.32, 16.33, 16.34,
               16.35, 16.36, 16.37, 16.38, 16.39 ]
}

i think i should just query whatever i stored in the db throw it to the client, then let the client sort/aggregate by it’s range 1m/5m/15m/1h …e.t.c

Check examples here, Example 4 refers window function but it is similar concept you can use

Thank you @vsr1

Can you provide an example query please, in influxdb i use something like this

  from(bucket: "${bucket}")
  |> range(start: ${startDate.toISOString()}, stop: ${endDate.toISOString()})
  |> filter(fn: (r) => r["symbol"] == "${symbol.toLocaleUpperCase()}")
  |> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
  |> yield()
WITH range_start AS (STR_TO_MILLIS ("2013-07-01", "YYYY-MM-DD")),
       range_end AS (STR_TO_MILLIS ("2013-08-31", "YYYY-MM-DD"))
SELECT minutes,  AVG(t._v0) AS average
FROM mycollection AS d
UNNEST _timeseries(d, {"ts_ranges": [range_start, range_end]}) AS t
WHERE d.ticker = 'XXC'
  AND (d.ts_start <= range_end AND d.ts_end >= range_start)
GROUP BY IDIV(t._t, 1000*60) AS minutes;

Sick!

R.I.P InfluxDB

@vsr1 how to save OHLC data?

is it like this when saving

ts_data: [date, open, high, low, close, vol]

then when querying i do this

SELECT 
AVG(t._v0) AS open, 
AVG(t._v1) AS high, 
AVG(t._v2) AS low, 
AVG(t._v3) AS close,
AVG(t._v4) AS vol

Example 2

ts_data: [[date, open, high, low, close, vol], [date, open, high, low, close, vol], ...]
1 Like