Repository navigation
fix(features): carry the previous sign in the effective tick rule - #79
Merged
Merged
Conversation
Unchanged prices were stored as 0 before forward-fill, so the fill never replaced them and flat trades were classified as no trade. Zero changes now keep the previous nonzero tick, including in order-flow imbalance. Co-authored-by: quantum-like <[email protected]>
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.
Closes #78. Supersedes the tick-rule portion of #71.
Carry the last observed nonzero trade sign across unchanged prices, leaving an unobservable adjacent price comparison unclassified. Normalize NaN price changes before sign comparisons so a real CSV missing price cannot become an uptick or corrupt later flat-price classifications. Order-flow imbalance uses the same implementation instead of a divergent duplicate.
At head 8b44031, refreshed onto qualified main 828d594, all 76 microstructure tests and the full 4,252-test suite pass on Python 3.12, 3.13 and 3.14 (57 intentional deselections).
Permanent real-CSV and grouped-state regressions showed 10 failures and eight passing empty-field controls before the additional producer repair; they pass afterward. Coverage includes eager/lazy evaluation, string/expression inputs, buy/sell histories, order-flow consumers, symbol isolation, leading unchanged prices, empty/singleton/all-missing inputs, and integer-price compatibility. Existing finite flat-price and Roll covariance regressions are preserved.
Additional compatibility review found that direct fill_nan rejects Polars Decimal prices. Four permanent eager/lazy tick/order-flow regressions fail at 5bdad31 and pass at the current head. Compute differences in the original numeric type before casting for NaN handling. A controlled producer mutation that casts prices first fails the two high-precision cases, proving that small moves in large Decimal prices are not rounded away. The same four public cases also pass on pre-normalization revision 8fab64b.
Ruff, formatting, ty, all-file hooks, lock validation, wheel/sdist build, import, twine metadata checks and strict MkDocs pass. The isolated built wheel passes both public CSV-gap and Decimal reproductions. Fresh current-head supported-platform hosted qualification is required before merge; earlier checks retain their actual tested revisions and do not qualify the current head.
Trade signs and order-flow values change and warrant inclusion in the eventual qualified patch release. This PR does not publish a release or deploy documentation.
AI assistance: Codex reproduced public classification failures and the Decimal compatibility defect, inspected the actual diffs and overlap, implemented the focused repairs and permanent regressions, ran checks and drafted this description. Original Cursor Agent source-fix authorship is retained; supplemental repairs are separate Stefan Jansen commits.