Repository navigation
docs(0211): state that the ohlcv window is inclusive on bucket start - #434
Conversation
…tart A candle is returned when its bucket starts inside [start, end]: a mid-bucket start drops that bucket, a mid-bucket end keeps it, and the newest candle can be the still-open current bucket. Stated in the /ohlcv OpenAPI description and params (bundled portal copy refreshed) and in overview section 4.2, whose auto-granularity table also stops claiming all defaults to 1d.
stkrolikiewicz
left a comment
There was a problem hiding this comment.
Read the whole diff against the handler and the rollup MVs. The inclusive bucket-start semantics match the SQL. One issue on the "still open" bullet: coarse candles keep changing after their bucket ends, so the client rule there isn't safe. Two nits inline.
| past `end`. | ||
| - `timeframe` anchors to `end` (task 0119): `end=…&timeframe=7d` is the seven days ending | ||
| there; without `end` it ends now. | ||
| - **The newest candle can be the current bucket, still open.** It is returned while the |
There was a problem hiding this comment.
issue: this holds for 1m only. /ohlcv reads price_ohlcv_{g} directly, and the coarser tables are filled by refreshable MVs: 15m every minute, 1h every 15 min, 4h hourly, mv_ohlcv_4h_to_1d every 4 h, 1w and 1M once a day. On top of that the mv_reconcile_* views rewrite buckets up to INTERVAL 7 DAY back. So a 1d candle read at 00:30 UTC passes the timestamp + granularity check but can still be missing its last ~4 h, and it can change again for a week. A client caching by this rule keeps a truncated candle.
I'd state the refresh lag and the 7-day reconcile window instead of the client rule. The same sentence is in the OpenAPI description (handlers.rs, openapi.json) and in the revision-history row.
There was a problem hiding this comment.
Right, the client rule was only safe for 1m. Replaced it in all four places (overview §4.2, the /ohlcv OpenAPI description + bundled openapi.json, and the revision row): sizes above 1m are rebuilt from the size below on a schedule (15m every minute, 1h every 15 min, 4h hourly, 1d every 4 h, 1w/1M daily), an hourly reconcile pass rewrites them up to 7 days back, so a candle should not be cached as final until its bucket ended more than 7 days ago. The overview now also says outright that timestamp + granularity being past is not "final". ebc4d05
| | `end` | ISO8601 | — | Custom range end | | ||
| | `granularity` | string | auto | `1m`, `15m`, `1h`, `4h`, `1d`, `1w`, `1M`. Auto-selected if omitted (table below) | | ||
| | `start` | ISO8601 | — | Custom range start, **inclusive** (overrides the timeframe's start) | | ||
| | `end` | ISO8601 | now | Custom range end, **inclusive**. With `end` alone, the `timeframe` window ends there | |
There was a problem hiding this comment.
nit: end alone also switches the grain. explicit_window is start.is_some() || end.is_some(), so timeframe=7d&end=… returns 15m candles, not the table's 1h. Maybe say so here or in the start/end window row.
There was a problem hiding this comment.
Yes, both now say it: the table row is "start and/or end window", the end row says end alone switches to the finest grain within 5000 candles (timeframe=7d&end=… returns 15m), and the OpenAPI granularity default reads "when start or end is given". ebc4d05
| | `30d` | `4h` | ~180 | | ||
| | `1y` | `1d` | ~365 | | ||
| | `all` | `1d` | variable | | ||
| | `all` | finest size within 5000 candles (`1d` until 2029-06-08, then `1w`) | ≤ 5000 | |
There was a problem hiding this comment.
nit: 2029-06-07, not 06-08. 1d holds only while the span is under 5000 days, i.e. up to 4999 days after 2015-09-30 (same note on #432).
finest_for_span keeps 1d only while span.div_ceil(DAY) < 5000, so from Stellar genesis (2015-09-30) the grain turns weekly after 4999 days, on 2029-06-07 00:00:01 UTC, not on 2029-06-08 as stated. Spotted in review of PR #432.
Sizes above 1m are rebuilt from the size below on a schedule (15m every minute up to 1w/1M once a day) and rewritten hourly up to 7 days back, so the 'timestamp + granularity is past now' rule for a closed candle was unsafe: a 1d candle read at 00:30 UTC can still lack its last hours. State the refresh lag and the 7-day reconcile window instead, in the overview, the /ohlcv OpenAPI description and the revision row. Also state that end alone switches to the computed granularity, as start does (timeframe=7d&end=... returns 15m). Spotted in review of PR #434.
All four PRs merged into develop on 2026-11-30 after Stan's review: - 0253: #432 (d3bee99) - 0302: #433 (ef601af), writer probe on production recorded - 0211: #434 (638beb8), overview revision row now links the archive - 0288: #435 (9ea7b6c) Each task records the review fixes, status completed, and moves to archive/.
Summary
/ohlcvdocs now say what the window means: a candle is returned when its bucket's start time falls inside[start, end], both ends inclusive. Example from 0120:start=2026-08-14&end=2026-08-19at1dreturns six candles.startinside a bucket leaves that bucket out; anendinside one keeps it. The newest candle can be the still-open current bucket and changes until it ends.start/endparams (bundledweb/portal/public/openapi.jsonrefreshed) and in overview §4.2, with a revision-history row.all → 1d:allandstart/endwindows take the finest size within 5000 candles.openapi:verify-bundled,openapi:lintandprices-apiunit tests pass.Task: lore 0211.