Fix records_to_dataframe FieldError on MBP-1/MBP-10/BBO (issue #40)#41
Merged
Conversation
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>
2d44f32 to
29f3021
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #40.
Problem
records_to_dataframe(and thereforeto_dataframeanddbn_to_parquet) throwsFieldErrorfor TBBO / MBP-1 and MBP-10. The converters read flatbid_px_00…,ask_px_00…fields that don't exist on the record structs — the bid/ask data lives in the nestedlevels:MBP1Msg(andCMBP1Msg,TCBBOMsg,CBBO1sMsg,CBBO1mMsg,BBO1sMsg,BBO1mMsg):levels::BidAskPairMBP10Msg:levels::NTuple{10,BidAskPair}Fix
mbp1_to_dataframereads throughr.levels.bid_px/.ask_px/.bid_sz/ …. Its signature is widened toVector{<:TopOfBookMsg}(a new union alias) since the consolidated/BBO family share the exact MBP-1 layout — they previously fell through tomixed_records_to_dataframeand produced no bid/ask columns.mbp10_to_dataframeiterates/indexes thelevelstuple instead of nonexistent flat fields.records_to_dataframeroutes 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 throughlevels; MBP-10 expands to 10 level-indexed rows with correct per-level values; and each ofTCBBOMsg/CMBP1Msg/CBBO1sMsg/CBBO1mMsg/BBO1sMsg/BBO1mMsgnow yields abid_pricecolumn. 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