Skip to content

Detect future-calendar leakage and handle zero-volatility rebalances - #9

Merged
ult666666 merged 2 commits into
mainfrom
fix/backtest-prefix-and-flat-windows
Nov 18, 2026
Merged

ult666666 merged 2 commits into
mainfrom
fix/backtest-prefix-and-flat-windows

Conversation

@ult666666

@ult666666 ult666666 commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

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.

@ult666666
ult666666 merged commit e172682 into main Nov 18, 2026
6 checks passed
@ult666666
ult666666 deleted the fix/backtest-prefix-and-flat-windows branch November 18, 2026 05:29
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.

1 participant