Trading the Breaking

Trading the Breaking

Quant Lectures

Backtesting - Building your backtesting pipeline

BACKTESTING SERIES - Volume IV

Quant Beckman's avatar
Quant Beckman
Dec 01, 2026
∙ Paid

…


Before you begin, remember that you have an index with the newsletter content organized by clicking below.

INDEX


Last eBook about backtesting until the next year (new methods are coming). 
This other one is the compilation of 6 articles from the Research section. 

How do you build and check a backtest?

In this case, we used a toy example for the ebook. We use a moving-average crossover on SPY as a toy example. After each close, we compare the 10-day and 40-day averages. If the shorter average is higher, our target for the next open is 100 shares. Otherwise, we hold cash. We can calculate the signal by hand and trace each day’s gain or loss back to the shares we held.

What’s inside

  1. Reconstruct what the trader knew: We check the price history for missing sessions and use the quotes available when each decision was due. In one exercise, a vendor changes Friday’s close from $51 to $50 on Tuesday. Apply that correction a day too early and Monday’s long signal disappears.

  2. Turn the signal into an order: When the rule calls for 100 shares and we hold cash, we buy at the next open. If we already own the shares, we carry them into the next session. In a separate exercise, a daily bar crosses both a stop and a profit target. Either order could have filled first, so we calculate both outcomes.

  3. Check one day’s profit by hand: SPY closed at $142.41 when the first buy signal formed. The order filled at $145.11 the next session, and SPY closed that day at $146.06. The 100 shares earned $95. After the entry fee, the ledger should show a gain of $87.74. This check catches a backtest that credits the buyer with the overnight jump.

  4. Test the strategy at different account sizes: We keep the orders on the same dates, increase their size, and recalculate commissions, spread, and market impact. In a four-order exercise, costs absorb the gross profit at about $253,000 of capital. An order first reaches 10% of average daily volume when the account reaches about $632,000.

  5. Decide what the result should beat: At equal stakes, a 60% hit rate breaks even before fees if the average win is 0.8% and the average loss is 1.2%. For SPY, we compare two $100,000 accounts using the same 100-share lot. From 2013 through 2015, the crossover earned $1,240 against $5,859 for buy and hold, with a smaller drawdown. Both gains are net of fees and exclude dividends.

  6. Choose the settings before testing them: In a separate SPY study, we rank four moving-average pairs using only returns known at each review. The final review selects the 30- and 90-session windows. We keep them fixed for the next 252 close-to-close intervals. That entire test period contains just two completed trades.

  7. Test how much depended on the dates: We return to the 100-share rule and shift its sequence of invested and cash days around the 2013–2015 calendar. Counting the original schedule, 693 of 756 alignments earned at least as much as the crossover. On alternative price paths, we recalculate the averages so the rule can place different orders.

Sample
421KB ∙ PDF file
Download
Download
User's avatar

Continue reading this post for free, courtesy of Quant Beckman.

Or purchase a paid subscription.
© 2026 Quant Beckman · Publisher Privacy ∙ Publisher Terms
Substack · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for writing, podcasting, and media founders.