Daily Bars
A price chart sums a day up in four numbers. trades lists every trade of several days, in order of id. Return one row per day, earliest first, with open (the price of the day's first trade), high (its highest price), low (its lowest) and close (the price of its last trade).
Example 1
trades
| id | day | price |
|---|---|---|
| 1 | 2026-01-02 | 10.0 |
| 2 | 2026-01-02 | 12.5 |
| 3 | 2026-01-02 | 9.0 |
| 4 | 2026-01-02 | 11.0 |
| 5 | 2026-01-05 | 11.5 |
| 6 | 2026-01-05 | 14.0 |
returns
| day | open | high | low | close |
|---|---|---|---|---|
| 2026-01-02 | 10.0 | 12.5 | 9.0 | 11.0 |
| 2026-01-05 | 11.5 | 14.0 | 11.5 | 14.0 |
Constraints
- Up to 18 trades
- Ids are unique and rise with time
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.