Skip to content

Fix records_to_dataframe FieldError on MBP-1/MBP-10/BBO (issue #40)#41

Merged
tbeason merged 1 commit into
mainfrom
fix-mbp-dataframe
Jun 22, 2026
Merged

Fix records_to_dataframe FieldError on MBP-1/MBP-10/BBO (issue #40)#41
tbeason merged 1 commit into
mainfrom
fix-mbp-dataframe

Conversation

@tbeason

@tbeason tbeason commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Fixes #40.

Problem

records_to_dataframe (and therefore to_dataframe and dbn_to_parquet) throws FieldError for TBBO / MBP-1 and MBP-10. The converters read flat bid_px_00…, ask_px_00… fields that don't exist on the record structs — the bid/ask data lives in the nested levels:

  • MBP1Msg (and CMBP1Msg, TCBBOMsg, CBBO1sMsg, CBBO1mMsg, BBO1sMsg, BBO1mMsg): levels::BidAskPair
  • MBP10Msg: levels::NTuple{10,BidAskPair}
FieldError: type MBP1Msg has no field `bid_px_00`

Fix

  • mbp1_to_dataframe reads through r.levels.bid_px / .ask_px / .bid_sz / …. Its signature is widened to Vector{<:TopOfBookMsg} (a new union alias) since the consolidated/BBO family share the exact MBP-1 layout — they previously fell through to mixed_records_to_dataframe and produced no bid/ask columns.
  • mbp10_to_dataframe iterates/indexes the levels tuple instead of nonexistent flat fields.
  • records_to_dataframe routes the whole top-of-book family to the one converter.

No change to the OHLCV / trades / MBO paths.

Tests

New test/test_issue40_mbp_dataframe.jl (31 assertions): MBP-1 reads through levels; MBP-10 expands to 10 level-indexed rows with correct per-level values; and each of TCBBOMsg/CMBP1Msg/CBBO1sMsg/CBBO1mMsg/BBO1sMsg/BBO1mMsg now yields a bid_price column. Full suite green locally (3728 pass).

Note

This targets the same upcoming 0.1.4 release as #38 (symbol resolution); both should land before registering 0.1.4. The version bump lives in #38.

🤖 Generated with Claude Code

mbp1_to_dataframe and mbp10_to_dataframe read flat bid_px_00… fields that
don't exist on the record structs — the bid/ask data lives in the nested
levels::BidAskPair (MBP-1 and the consolidated/BBO family) or
levels::NTuple{10,BidAskPair} (MBP-10). records_to_dataframe (and thus
to_dataframe and dbn_to_parquet) therefore threw FieldError on TBBO/MBP-1 and
MBP-10.

- mbp1_to_dataframe now reads through `levels`; its signature is widened to the
  shared top-of-book layout so it also serves CMBP1Msg/TCBBOMsg/CBBO*/BBO*,
  which previously fell through to the generic mixed-record path.
- mbp10_to_dataframe indexes the levels tuple instead of nonexistent flat
  fields.
- records_to_dataframe dispatches the whole top-of-book family to one converter.

Adds test/test_issue40_mbp_dataframe.jl covering MBP-1, MBP-10 (10-level
expansion), and each consolidated/BBO type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tbeason tbeason force-pushed the fix-mbp-dataframe branch from 2d44f32 to 29f3021 Compare June 22, 2026 17:11
@tbeason tbeason merged commit 7723635 into main Jun 22, 2026
8 checks passed
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.

records_to_dataframe/to_dataframe/dbn_to_parquet throw FieldError on TBBO (MBP-1) and MBP-10 — flat bid/ask fields vs nested levels

1 participant