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

推荐订阅源

量子位
B
Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
Google DeepMind News
Google DeepMind News
U
Unit 42
雷峰网
雷峰网
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
美团技术团队
Y
Y Combinator Blog
腾讯CDC
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements

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
Why Your Backtest Is Lying to You: Data Biases That Ruin ...
pickuma · 2026-05-19 · via DEV Community

pickuma

You built a backtest. It returns 18% annualized over the last
decade. The Sharpe is 1.4. The drawdown is acceptable. You're
already mentally apartment-shopping in the city you'll move to
after the strategy makes you wealthy.

It's probably wrong. Not because your code has bugs — backtest
code can be flawless and still produce numbers that have almost
nothing to do with what would have happened if you'd traded the
strategy live. The reasons are subtle and they have names.

Survivorship bias

The most famous one. If your historical universe is "S&P 500
today, backtested over ten years," you've quietly excluded every
company that was in the S&P 500 at some point and got booted out
— usually because it failed.

The companies that died don't show up in the dataset. Your
historical "S&P 500" is actually "the winning subset of the
S&P 500 visible from the future." Returns are biased upward,
sometimes by several percentage points a year for small-cap or
emerging-market strategies.

Fix: use a point-in-time index membership database, or build
one. CRSP and similar paid datasets handle this; free options
require more work and willingness to scrape historical index
constituent lists.

Look-ahead bias

You computed the trailing-twelve-month P/E using today's reported
financials. Trouble: those financials weren't available at the
time. Earnings get reported 30–90 days after a quarter ends, and
restatements happen after that.

If you're ranking companies on March 31, 2018, you should be
using financials that were actually filed and disclosed by
March 31, 2018
— not the latest revision visible today.

Fix: use point-in-time fundamentals. EDGAR preserves the
original filing dates, so it can be done, but it requires care.
Most price-data vendors hand you the latest-available value with
no timestamp — that's the bias source.

Universe selection bias

A close cousin of survivorship. If you backtest on "stocks that
have at least 10 years of clean fundamental data," you've
selected for stability — companies that didn't go bankrupt,
didn't merge, didn't get acquired, didn't change reporting
standards. Your universe is structurally biased toward survivors.

Fix: define your universe as a point-in-time set ("Russell
3000 as of the rebalance date") and accept that some constituents
will have noisy or incomplete data.

Slippage and transaction costs

You assumed you traded at the closing price with zero cost. In
reality, large orders move the market, bid-ask spreads exist,
and small-cap stocks can be impossible to fill at the quoted
price.

A strategy that backtests at 15% gross return after slippage and
costs is often 8–10% net. The smaller your average market cap
and the higher your turnover, the worse the gap.

Fix: model slippage explicitly. A reasonable starting point
is 20–50 basis points per round-trip for liquid stocks, 100+ bps
for small caps. Charge it to every trade.

Backtest overfitting

You ran 200 parameter combinations and the best one delivered
22%. Congratulations: you've discovered noise in your dataset,
not signal. By construction, the best of 200 trials on the same
data will look impressive even if the underlying strategy has no
edge.

Fix: walk-forward testing. Develop on one window, test on a
later out-of-sample window you never touched during parameter
selection. If the out-of-sample period underperforms
substantially, the rule was likely overfit. Bonferroni-style
corrections for multiple-testing apply here too.

Calendar and currency cleanup

Subtler than the rest, but important:

  • Time zones. "Closing price on date X" depends on which exchange and which time zone X refers to. Cross-listed names bite first.
  • Corporate actions. Stock splits and dividends have to be back-adjusted consistently. Yahoo Finance gives you adjusted prices; sometimes the adjustments are off for small caps or delisted names.
  • Currency. A non-USD strategy backtest needs FX adjustment at the same point in time as the prices, not at today's rate.

If your backtest dramatically outperforms the broad market over
a long window, treat that as a red flag, not a celebration.
Persistent strategy edges are uncommon and small. A 5%-per-year
alpha is exceptional. A 15%-per-year alpha is almost always a
data bias.

The honest closing

A backtest is a hypothesis, not a result. The version of you who
will trade the strategy live doesn't have access to next year's
returns — only to today's beliefs. The point of correcting for
biases isn't to make the backtest look worse; it's to make the
backtest tell you something true about what to expect.

If after correcting for all of the above, your strategy still
shows a clean edge: trade a small amount of real money for six
months and see if the live numbers match. If they don't, you've
learned the cheap version of the lesson everyone else learns the
expensive way.


Originally published at pickuma.com. Subscribe to the RSS or follow @pickuma.bsky.social for new reviews.