⚡ Bolt: Optimize time-series data lookups during backtesting#64
⚡ Bolt: Optimize time-series data lookups during backtesting#64toreleon wants to merge 3 commits into
Conversation
- Implement binary search utility `findLastBarIndex` - Update `vnindexAt` and `priceOverride` in backtestRunner to use O(log n) lookups instead of `.filter` - Add performance learning to journal Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Implement binary search utility `findLastBarIndex` - Update `vnindexAt` and `priceOverride` in backtestRunner to use O(log n) lookups instead of `.filter` - Add performance learning to journal Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
- Implement binary search utility `findLastBarIndex` - Update `vnindexAt` and `priceOverride` in backtestRunner to use O(log n) lookups instead of `.filter` - Add performance learning to journal - Resolve high severity security vulnerabilities in CI by overriding `ws` version and updating `undici` Co-authored-by: toreleon <42534763+toreleon@users.noreply.github.com>
💡 What: Replaced
array.filter(b => b.time <= asOf)with an O(log n) binary search lookup (findLastBarIndex) in the backtesting engine.🎯 Why: During backtesting loops, the
vnindexAtandpriceOverridefunctions are called constantly for every symbol at every interval. Filtering the entire time-series array on each call results in O(n) complexity on chronologically sorted arrays. As backtests scale in interval density and candidate counts, this CPU bottleneck degrades performance significantly.📊 Impact: Reduces time complexity of looking up historical bars from O(n) to O(log n), eliminating unnecessary array allocations and iterations. Expected to drastically improve performance for long backtesting periods.
🔬 Measurement: Verified by running the full test suite (
pnpm testandpnpm typecheck), and the correctness is functionally identical while using binary search logic on sorted arrays.PR created automatically by Jules for task 8960681477467071551 started by @toreleon