A backtest is only as honest as its data and its fills. Run the same rules in a different engine and the results change — sometimes by enough to turn a marginal strategy into an obvious one, and occasionally the other way around. That is the point of the port.
This log records the move of my systematic strategy stack from a custom research codebase into QuantConnect’s LEAN. It is published as it happens, including the parts that did not work, because the process of finding an engine’s disagreements with your research is more informative than a clean final chart.
01Why port at all
The original research stack was built for speed: a desktop backtester, a custom data layer and a research loop tuned for iteration. It was good at answering “does this idea have legs” and weak at answering “would this have filled.” LEAN is the opposite: slower to iterate, stricter about data, and explicit about brokerage mechanics.
Three reasons made the port worth the effort. An independent implementation catches specification errors that the original code has internalized. A public, auditable engine makes the results discussable with someone outside my own stack. And the constraint of a fixed event-driven model forces decisions that a vectorized backtest lets you postpone — when to rebalance, what price to use, what happens when a position cannot be filled.
02Point-in-time data and survivorship
The first serious disagreement was about the universe. The original tests used a current list of liquid ETFs and mapped it backwards, which quietly assumes that today’s vehicles existed and were liquid throughout the test. LEAN’s universe selection forces the question: what was actually available, and how was it priced, at each point in time?
The resolution was to build an explicit instrument timeline with listing and delisting dates, and to run the backtest on adjusted price series that include dividends and splits. For the equity sleeves, the same logic applies to constituent lists: a miner ETF’s holdings in 2015 are not today’s holdings, and using today’s would import survivorship into the signal.
Two of the sleeves had materially shorter histories than the original test assumed. The backtest window now starts where all instruments have a verified price history, and the earlier period is treated as a separate, lower-confidence test rather than being papered over.
03Fills, fees and slippage
The original cost model applied a fixed basis-point haircut per trade. LEAN’s fill models are event-driven: an order is filled against a data slice, with a slippage assumption and a fee model attached to the security. The results are not identical, and the difference is informative.
| Assumption | Original stack | LEAN implementation |
|---|---|---|
| Fill price | Next bar close with a haircut | Configurable fill model against the data slice |
| Slippage | Fixed basis points per trade | Volume-share model plus explicit spread assumption |
| Fees | Flat per-trade estimate | Per-security fee model (commission plus regulatory) |
| Rebalance timing | Signal date equals execution date | Scheduled event, executed on the next available slice |
| Corporate actions | Pre-adjusted series | Handled by the data feed, verified against raw prices |
The rebalance timing line is the one that matters most. Giving the signal a one-day implementation lag removes a small amount of apparent performance and a large amount of self-deception. Any strategy whose edge disappears with a one-day lag was never executable.
04Universe and scheduling
The algorithm uses a coarse, manually defined universe rather than a screener. That is a deliberate choice: the strategy allocates across four sleeves, and a dynamic screener would introduce a selection process that is not part of the thesis. The universe is defined once, with listing dates, and held fixed.
Scheduling follows the research specification: signals evaluated monthly, a weekly risk-reduction pass, and orders submitted through a scheduled event rather than in the data handler. Keeping execution out of the data handler is the LEAN equivalent of not letting the model see the future.
05Parameter stability
Every parameter is tested on a grid, and the output of interest is not the best cell but the shape of the surface around it. A plateau is acceptable. A single sharp peak is a warning, regardless of how good the number is.
Three parameters dominate: the trend lookback, the volatility target, and the de-risking threshold. The first two are being tested on a coarse grid with a fixed holdout. The third is being tested for sensitivity of the left tail rather than the mean, because its job is to limit damage, not to add return.
# Coarse grid, fixed holdout, no re-optimization per cell
for lookback in [120, 150, 180, 210, 240]:
for target in [0.06, 0.08, 0.10, 0.12]:
result = run_backtest(lookback=lookback, vol_target=target)
record(result, params=(lookback, target))
06Build status
| Component | State | Note |
|---|---|---|
| Instrument timeline | Complete | Listing and delisting dates verified for all sleeves |
| Adjusted price data | Complete | Cross-checked against raw prices for corporate actions |
| Signal implementation | Complete | Ported to LEAN indicators with the same transforms |
| Risk and sizing layer | In progress | Budget and caps ported; ladder thresholds under test |
| Fill and fee models | In progress | Calibrating volume-share slippage against realized spreads |
| Parameter grid | Next | Runs after the sizing layer is frozen |
| Walk-forward study | Next | Rolling re-estimation, no parameter carry-over |
07Log entries
- 04 NovEquity curve reconciliationThe first full run diverged from the original backtest by more than the cost difference alone. Cause: the original stack rebalanced on the signal date, while LEAN executes on the next slice. The gap is now treated as a feature of the port, not a bug.
- 28 OctUniverse correctionTwo instruments had no verified price history before 2016. The backtest window was shortened rather than backfilled, and the earlier period moved to a separate, flagged test.
- 19 OctSlippage calibrationVolume-share slippage was over-penalizing small trades in the energy sleeve. Replaced with a spread-plus-impact model calibrated to observed bid-ask costs.
- 07 OctSignal parityRolling z-score transforms matched to the research implementation. The remaining difference is a one-observation lag in the warm-up period, documented and accepted.
08Next tests
- Sizing layer freeze. Lock the risk budget and ladder thresholds, then run the parameter grid without touching them.
- Walk-forward. Rolling re-estimation with no parameter carry-over, to see whether the stability found in-sample survives.
- Macro layer ablation. Compare the full scorecard against a trend-and-volatility-only version. If the macro inputs do not improve out-of-sample drawdowns, they are removed.
- Capacity check. Estimate the strategy’s capacity from sleeve liquidity and the trade bands, and test sensitivity to tighter bands.
The log will be updated as these run. The results, including the ones that weaken the case for the strategy, will be published here.
Research in progress. Nothing on this page is investment advice or a representation of actual or expected performance.
Back to work