Repository navigation
Detect future-calendar leakage and handle zero-volatility rebalances - #9
Merged
Merged
Conversation
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.
The no-lookahead checker used to perturb future prices while leaving the dates in place. A custom strategy that sold on the last supplied date passed every cutoff. Check a truncated history as well, and require identical targets on the dates both runs share. The checker still samples cutoffs and retains the price-perturbation test.
InverseVolatility now follows the engine’s existing no-trade convention when a reciprocal weight is undefined. A flat asset next to a moving asset previously produced a partly specified target and caused the public runner to reject its own built-in strategy. If any required trailing volatility is zero, the strategy keeps existing shares or initial cash until a scheduled rebalance has defined weights. Regression cases cover all-flat and mixed windows, drift and costed recovery.
On synthetic prices, 3,096 truncated runs produced identical prefixes for the five built-in strategies and four additional schedule/window settings. An independent share-and-cash calculation matched turnover, fees and wealth in seven scenarios, including shorts, flat prices and a final-day rebalance. No market data or brokerage account was used.
The full suite and README examples passed 440 checks each on Python 3.11, 3.12 and 3.13. The wheel built from this revision passed the installed README examples and the flat-price CLI run outside the checkout. Ruff, formatting and strict mypy passed.