feat: add fill feature logging for ML dataset building#159
Open
keitaj wants to merge 1 commit into
Open
Conversation
Persist per-fill order book features (spread, book imbalance, micro-price skew, top-of-book sizes) together with the adverse selection tracker's 5s/30s/60s markout samples as one JSON line per fill in a daily-rotated JSONL file. - fill_features.compute_fill_features is the single shared feature definition (guards against train/serve skew for future inference) - FillFeatureWriter buffers records in memory on the WS thread and flushes from the main loop after a 65s maturity window so markout labels can be embedded in the same line - Fail-silent by design: IO errors, size caps and buffer overflows are counted and never affect trading - Default OFF; requires --enable-ws and --enable-adverse-selection-log Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
fill_features.compute_fill_features) shared by the logger and any future in-bot inference, structurally preventing train/serve skew.Changes
fill_features.py(new): shared pure feature computation +FEATURE_SCHEMA_VERSION.ws/fill_feature_writer.py(new):FillFeatureWriter— buffered, maturity-gated, daily-rotated JSONL writer with size/buffer caps and rate-limited error logging.ws/adverse_selection_tracker.py: optionalraw_fillkwarg onon_fill(backward compatible), feature record composition (tid/oid/hashjoin keys + features),set_feature_writer()hook,recordfield onFillSnapshot.ws/fill_feed.py: pass the raw userFills object to the tracker (raw_fill=fill).bot.py: writer wiring (warns and disables when the adverse tracker is unavailable), main-loopmaybe_flush(), shutdownflush_all(), config keys + defaults, argparse flags.ws/__init__.py: exportFillFeatureWriter.README.md: human-facing description + AI YAML parameter reference entries.test_fill_features.py,test_fill_feature_writer.py(new), plus additions to tracker/fill-feed tests and a stub-attribute fix intest_risk_check_throttle.py.Test plan
on_fillcalls)flake8passespytestpasses (1,149 tests)🤖 Generated with Claude Code