Longest Winning Streak
results has one row per trading day with that day's profit or loss, pnl. A winning day has pnl above 0. Return one row with one column, longest: the largest number of winning days in a row, taking the days in date order. With no winning day at all it is 0.
Example 1
results
| day | pnl |
|---|---|
| 2026-01-02 | 5 |
| 2026-01-05 | 7 |
| 2026-01-06 | -2 |
| 2026-01-07 | 1 |
| 2026-01-08 | 4 |
| 2026-01-09 | 9 |
| 2026-01-12 | 0 |
returns
| longest |
|---|
| 3 |
Constraints
- Up to 16 days, each day once
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.