惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
量子位
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
V
Visual Studio Blog
雷峰网
雷峰网
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Backtested 96 SPY Put Credit Spread Strategies - Here's...
tomasz dobro · 2026-04-29 · via DEV Community

tomasz dobrowolski

I built a backtest engine for SPY put credit spreads. 7 years of 1-minute option chains. 96 grid cells across (delta, DTE, profit-target, stop-loss). 16,024 trades that survived validation.

This post is the part most quant tutorials skip: the bugs, the lying simulators, and the one-line feature that humiliated my 3-layer composite signal. If you've ever shipped a backtest with great-looking numbers, you might want to read the bug log section.

The first lesson: mid-fill backtests are lying to you

The naive engine filled at the bid-ask mid. Numbers looked great. Then I implemented what an actual desk does - post a limit at combo_ask + $0.04, wait for someone to cross it, accept rejection - and CAGR dropped 30–60% across the entire grid. Several cells flipped from positive to negative.

Real fill stats from one run:

Run Posted Filled Fill rate Avg wait Edge captured
45Δ 30 DTE PT 50% No stop 479 112 23.4% 12.4 min −$0.04 to −$0.07
45Δ 30 DTE PT 50% SL 100% 633 155 24.5% 12.2 min −$0.04 to −$0.07
45Δ 30 DTE PT 50% SL 200% 383 64 16.7% 13.3 min −$0.04 to −$0.07

You fill ~20–25% of orders, after a ~12-minute wait, at 4–7 cents worse than mid. The MM doesn't make money at the fill - they make it over the hold, when theta beats realized vol. Any backtest filling at mid is silently gifting your strategy that 4–7 cents per trade.

If you remember nothing else from this post: build a real fill model.

The single biggest finding: SL=100% IS the strategy

Same cell. Same fills. Same period. Toggle the stop loss:

Configuration Trades Return CAGR MaxDD Calmar
10Δ 7 DTE PT 50% No stop - −100% wipeout breaker -
10Δ 7 DTE PT 50% SL 100% 460 +5,439% +66.0% 30.1% 2.19
10Δ 7 DTE PT 75% SL 100% 360 +2,947% +53.9% 31.1% 1.73
10Δ 7 DTE PT 25% SL 100% 649 +1,752% +44.6% 30.2% 1.48

+5,439% with a stop. −100% without. Same cell.

A single bad Monday on a no-stop short-vol position takes the account to zero. The stop loss isn't a parameter you sweep - at short DTE it's the entire risk model.

The trap nobody warns you about: SL=200%

I expected SL=200% to be the sensible compromise. Looser than 100% so I don't get noise-stopped, tighter than no-SL so a tail doesn't kill me. Wrong:

SL setting Trades Return CAGR Sharpe MaxDD
No stop 112 +30.6% +3.8% +0.23 30.1%
SL 100% 155 +28.0% +3.5% +0.22 29.3%
SL 200% ← trap 64 −16.5% −2.5% −0.17 31.2%

Both no-stop and SL=100% made money. SL=200% lost.

Mechanics: by the time the loss has grown to 200% of credit, you're deep ITM and gamma is doing the marking, not theta. You stop out at the worst possible price, on the worst possible day, after letting the position breathe past the point of recovery. SL=100% stops you before gamma takes over. No SL at least gives you the chance to be bailed out by a recovery.

Pick tight or pick none. Never the middle.

My fancy signal got beaten by a one-liner

I built a 3-layer composite - Premium / Danger / Stabilization scores, z-scored macro inputs, continuous Kelly multiplier. Then I ran t-tests across all 16,024 trades.

The strongest predictor in the entire feature set wasn't my composite. It was a single boolean flag on a free macro series - the kind of thing you write in three lines of pandas:

# pseudocode - the actual flag stays with me
signal_on = (macro_series.diff(5) < 0) & (macro_series < macro_series.rolling(20).mean())

Enter fullscreen mode Exit fullscreen mode

t-stat over 8, on 5,000+ trades. Bonferroni-correct it across the entire feature space and it still wins.

The lesson generalizes: if your "edge" is a 47-feature gradient-boosted model, replace it with the most economically obvious single flag and check how much you actually lose. Often that flag does 80% of the work and your model is overfitting the residual.

Two related findings worth knowing:

  1. The market pays the most right before it bites. Top-quintile VRP days had 66% winrate vs 74% baseline. By the time premium is that rich, something is actually wrong.
  2. Don't sell into rising fear with an inverted term curve. Wait for the curve to normalize OR for the fear to fade. Either is fine. Both being wrong is the worst regime in the data.

Multi-DTE pooling cost me 9pp of CAGR

Seemed obvious: instead of committing to one tenor, rank candidates across 30/45/60-DTE chains every entry, pick the best EV-per-dollar-at-risk:

Tenor selection Trades Return CAGR Sharpe MaxDD
Pool 30/45/60 DTE No stop 112 +30.6% +3.8% +0.23 30.1%
Pool 30/45/60 DTE SL 100% 155 +28.0% +3.5% +0.22 29.3%
Focused 30 DTE No stop 82 +70% +12.5% +0.72 27.5%

The ranker correctly picked 30-DTE ~68% of the time. The other ~32% it picked 45-DTE specifically because the 30-DTE chain looked worse than usual that bar - which is the textbook definition of adverse selection.

More degrees of freedom = more ways for the optimizer to be wrong, not more ways to be right.

The bug log

This is the part most quant blogs skip. Every one of these bugs would have inflated the headline numbers. Most were caught only after a code review:

Bug What it did Damage
Mid-fill assumption Filled at bid-ask average always Flipped multiple losing strategies positive
Look-ahead in signal Day-D signal used end-of-D data at 10:05 AM entry Inflated CAGR ~5–10pp on most cells
Stale-quote acceptance "Fills" at quotes that were no longer real liquidity ~30% of fills had negative edge captured
EV-sorted tiebreak Higher-EV candidate "filled" first when two crossed same bar Subtle but real per-trade lift
Warmup sizing bug Full Kelly applied before signal had any history Cratered 2018 results
Validation walk-back mismatch Validator used exact-date lookup, engine walked back 7 days Bogus regression stats on weekend dates
Walk-the-limit (rejected) Drop limit a penny each minute if unfilled Caught before merge - adverse selection

The pre-fix engine on the same data returned −1% to −8% CAGR across every cell. So when post-fix numbers turned positive, that wasn't simulator noise - it was what the bias was masking.

If your backtest looks great on the first run, you have a bug. Find it.

The sizing layer

SIZING = {
    "kelly_default": 0.05,         # half-Kelly, conservative on purpose
    "kelly_max": 0.25,
    "kelly_f_hard_cap": 1.0,       # leveraged math can multiply to 1.25 without it
    "drawdown_breaker_pct": 0.30,  # halts the run, not the position
    "absolute_floor_pct": 0.50,    # secondary backstop
    "warmup_multiplier": 0.0,      # cratered 2018 when this was 1.0
    "vrp_on_mult": 1.0,            # 2.5 in the leveraged stress test
}

Enter fullscreen mode Exit fullscreen mode

Half-Kelly is conservative on purpose. Mean-variance Kelly assumes Gaussian returns; short-vol returns are skewed left with fat tails. The "true" Kelly under fat tails is below the mean-variance Kelly, so half-Kelly isn't lazy - it's roughly correct.

The 30% drawdown breaker doesn't reduce position size or pause for a day. It halts the entire run. If your strategy needs 30% drawdown to work, you don't have a strategy, you have a martingale.

TL;DR

  • Mid-fill backtests overstate CAGR by 30–60%. Build a real fill model.
  • Stop loss at 100% of credit IS the game at short DTE. +5,400% with, −100% without.
  • SL=200% is worse than no stop. Pick tight or pick none.
  • The strongest signal in 16k trades was a one-line boolean flag.
  • Multi-DTE pooling cost 9pp of CAGR. Adverse selection.
  • Higher delta moves equity vol, not alpha.
  • The market pays the most right before it bites.
  • If your backtest looks great on the first run, find the bug.

The full write-up with all 96 cells, the leveraged stress preset, and where the Calmar-leader cell sits in the grid is on FlashAlpha: original article.

The actual constraint on reproducing this isn't the engine (the engine is bookkeeping) - it's having minute-resolution SPY chains going back to 2018 with surface-consistent IVs. That's what FlashAlpha's Alpha tier historical API is for.