Skip to content

fix(tui): fill candle gaps for illiquid instruments#3

Merged
llcro merged 1 commit intomainfrom
fix/candle-gap-rendering
Apr 22, 2026
Merged

fix(tui): fill candle gaps for illiquid instruments#3
llcro merged 1 commit intomainfrom
fix/candle-gap-rendering

Conversation

@llcro
Copy link
Copy Markdown
Collaborator

@llcro llcro commented Apr 22, 2026

Summary

  • Illiquid instruments (e.g. RWA perps) return candlestick series with periods of zero trading activity omitted, producing visibly broken/gapped charts.
  • Introduce fill_candle_gaps(candles, interval_ms) in widgets::candlestick — a pure function that inserts synthetic zero-volume, O=H=L=C=prev_close candles for each missing period.
  • Detect synthetic candles in the renderer and draw them as a dim full-cell horizontal bar on the matching price row; adjacent fill cells merge into one continuous line rather than a dotted sequence.
  • Applied in all three chart render paths: MarketTab::ViewMode::Chart, MarketTab::ViewMode::Compare, and the split-screen 1h chart in App.

Test plan

  • Unit tests: gap insertion, contiguous no-op, empty/single inputs (cargo test -p cdcx-tui --lib candlestick)
  • cargo fmt --all --check + cargo clippy --locked --all-features -- -D warnings
  • Manual: launch TUI on an illiquid RWA perp in Chart, Compare, and split-screen modes — verify gaps render as a flat dim line rather than empty columns

…as continuous series

Illiquid instruments (e.g. RWA perps) omit candlestick periods with zero trading
activity. The renderer previously drew them as empty columns, producing a
visibly broken/gapped chart. Pre-process candles with a carry-forward fill so
missing periods render as a flat dim line at the previous close price.

- Add `fill_candle_gaps(candles, interval_ms)`: pure function that inserts
  synthetic zero-volume candles (O=H=L=C=prev_close) for each missing period.
- Detect synthetic candles in `render_chart_panel` via the
  (volume==0, open==close, high==low) sentinel and draw a full-cell horizontal
  bar on the matching price row so adjacent fill cells merge into one line.
- Apply in the three chart paths: MarketTab detail (`ViewMode::Chart`),
  MarketTab compare (`ViewMode::Compare`), and the split-screen 1h chart in
  `app.rs`.
- Tests cover gap insertion, contiguous no-op, and empty/single inputs.
@llcro llcro merged commit e8bdf31 into main Apr 22, 2026
8 checks passed
@llcro llcro deleted the fix/candle-gap-rendering branch April 22, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant