feat: configurable entity column in DataFeed - #7
Merged
Conversation
…sset, product, ticker
There was a problem hiding this comment.
Pull request overview
This PR makes the DataFeed class's entity identifier column configurable instead of hardcoding "asset". It adds auto-detection (checking symbol > asset > product > ticker in order) and an explicit entity_col keyword parameter for override.
Changes:
- Added
ENTITY_COL_CANDIDATESclass constant and_resolve_entity_colclassmethod to auto-detect or validate the entity column - Added
entity_colkeyword-only parameter toDataFeed.__init__and replaced all hardcoded"asset"references with the resolved_entity_col - Added comprehensive tests covering auto-detection, explicit override, error cases, and signals integration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/ml4t/backtest/datafeed.py |
Add entity column auto-detection and entity_col parameter; replace hardcoded "asset" with dynamic _entity_col |
tests/test_datafeed_memory.py |
Add TestDataFeedEntityColumn test class covering auto-detect, priority, explicit override, and error cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
symbol>asset>product>tickerentity_colkeyword parameter for explicit override"asset"column name — existing code withassetcolumn still worksWhy
The book codebase uses
symbolas the canonical entity column (andproductfor CME futures). DataFeed hardcodedasset, requiring callers to rename columns before passing data. This was fragile and got lost on everyuv sync.Test plan
assetcolumn)symbol,asset,product; explicit override; error cases; signals withsymbol🤖 Generated with Claude Code