Performance optimizations for backtesting:
- Cache compiled strategy code instead of recompiling every iteration
- Skip save_context() for backtests (no DB persistence needed per tick)
- Check cache existence before recreating broker state caches
- Add margin position processing to backtest strategy
These fixes eliminate O(n) slowdown that caused backtests to progressively
slow to a crawl. Backtests now maintain consistent speed throughout.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>