Skip to content

feat: preserve extra bar fields; diagonal concat for realtime bars#95

Open
rupurt wants to merge 1 commit into
TexasCoding:mainfrom
rupurt:upstream/preserve-extra-bar-fields
Open

feat: preserve extra bar fields; diagonal concat for realtime bars#95
rupurt wants to merge 1 commit into
TexasCoding:mainfrom
rupurt:upstream/preserve-extra-bar-fields

Conversation

@rupurt

@rupurt rupurt commented Jul 6, 2026

Copy link
Copy Markdown

Problem

When the bars API response includes fields beyond OHLCV, get_bars returned a frame wider than the six-column bars the realtime data manager constructs. Seeding a timeframe from get_bars and then appending a new realtime bar failed with pl.exceptions.ShapeError: unable to append to a DataFrame of width N with a DataFrame of width 6, spamming errors and freezing realtime timeframes (most visibly the fast ones like 5min).

Fix

  • get_bars preserves any extra API fields (canonical OHLCV columns first) instead of dropping them.
  • The realtime data manager's three bar-append sites use pl.concat(..., how="diagonal_relaxed"), so a six-column realtime bar extends a wider historical frame (extra fields become null) rather than raising a width mismatch.

Tests

  • New regression test: extra bars-API fields are preserved with canonical columns first.
  • tests/client/test_market_data.py (17) pass; realtime_data_manager suite unaffected; ruff + mypy clean.

The bars API can return fields beyond OHLCV. Rather than dropping them,
get_bars now keeps any extra fields (canonical timestamp/open/high/low/close/
volume first), so callers retain the richer data.

To keep the realtime data manager schema-safe, its three bar-append sites now
use diagonal concatenation, so a six-column realtime bar can extend a wider
historical frame (extra fields become null on the realtime bar) instead of
raising "unable to append to a DataFrame of width N with a DataFrame of
width 6".
rupurt added a commit to rupurt/project-x-py that referenced this pull request Jul 6, 2026
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