Skip to content

feat(bars): add fixed tick run bar sampler#13

Merged
stefan-jansen merged 2 commits into
mainfrom
feat/fixed-tick-run-bar-sampler
Jun 21, 2026
Merged

feat(bars): add fixed tick run bar sampler#13
stefan-jansen merged 2 commits into
mainfrom
feat/fixed-tick-run-bar-sampler

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Summary

  • Add FixedTickRunBarSampler for stable, fixed-threshold tick run bars.
  • Export the sampler from ml4t.engineer.bars.
  • Add focused run-bar tests and document the change in the v0.1.0b9 changelog entry.

Validation

  • uv run --locked pytest tests/bars/test_run_bars.py -q
  • uv run --locked ruff check src/ml4t/engineer/bars tests/bars/test_run_bars.py

stefan-jansen and others added 2 commits June 15, 2026 19:49
…ars)

Run bars previously had only the adaptive (alpha-EWMA) TickRunBarSampler,
which threshold-spirals on persistently one-sided flow — the same
instability the imbalance family already addresses with its Fixed/Window
variants. This adds the run-bar analog of FixedTickImbalanceBarSampler:
a bar forms when max(cumulative_buys, cumulative_sells) within the bar
reaches a fixed threshold (cumulative per AFML; no reset on direction
change). Stable, reproducible, predictable bar count, no feedback loop.

Exported from ml4t.engineer.bars. 9 tests cover init validation, schema,
threshold monotonicity, cumulative (not consecutive) counting, and the
key stability property: an all-one-side stream yields exactly floor(n/T)
bars instead of spiraling. Full bars suite: 156 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 21, 2026 16:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new fixed-threshold tick run bar sampler to the ml4t.engineer.bars sampling toolkit, aiming to provide a stable alternative to the adaptive AFML tick run bar algorithm.

Changes:

  • Implement FixedTickRunBarSampler backed by a Numba-compiled fixed-threshold run-bar indexer.
  • Export the new sampler from ml4t.engineer.bars and ml4t.engineer.bars.run.
  • Add focused tests for fixed tick run bars and update the 0.1.0b9 changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/ml4t/engineer/bars/run.py Adds the fixed-threshold run bar index calculation and the FixedTickRunBarSampler implementation.
src/ml4t/engineer/bars/__init__.py Re-exports FixedTickRunBarSampler from the public ml4t.engineer.bars surface.
tests/bars/test_run_bars.py Adds initialization, validation, stability, and incomplete-bar tests for the new sampler.
CHANGELOG.md Documents the new sampler under 0.1.0b9 and updates version comparison links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md
Comment on lines +13 to +19
### Fixed
- Public package metadata links now point to the `ml4t/engineer` repository and
published documentation
- Added the missing MIT license file to the source distribution
- Synced lockfile metadata with relaxed dependency bounds
- Reduced pytest warning noise for performance markers and cyclical feature
metadata
@stefan-jansen stefan-jansen merged commit 8d397ab into main Jun 21, 2026
7 checks passed
@stefan-jansen stefan-jansen deleted the feat/fixed-tick-run-bar-sampler branch June 21, 2026 16:30
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.

2 participants