{"id":253,"date":"2023-07-18T08:25:34","date_gmt":"2023-07-18T12:25:34","guid":{"rendered":"https:\/\/www.tiingo.com\/blog\/?p=253"},"modified":"2026-07-24T21:46:07","modified_gmt":"2026-07-25T01:46:07","slug":"backtesting-stocks","status":"publish","type":"post","link":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/","title":{"rendered":"Backtesting Stocks: How to Test a Strategy Before You Risk Money"},"content":{"rendered":"<p>Backtesting stocks means replaying your trading rules over historical data to see how they would have behaved. You take a strategy &#8211; &#8220;buy when this happens, sell when that happens&#8221; &#8211; run it against the past, and look at what comes out the other side.<\/p>\n<p>It&#8217;s one of the most useful things a trader or investor can do, and it&#8217;s also one of the easiest things to fool yourself with. I love backtesting. I also don&#8217;t fully trust any single backtest, including my own, and holding both of those thoughts at once is basically the entire skill.<\/p>\n<p>So this guide is going to be straight with you. A backtest is evidence, not a promise. Done well, it can save you from losing real money on a bad idea. Done carelessly, it becomes an expensive way to confirm what you already wanted to believe. Let&#8217;s walk through how to do it well.<\/p>\n<h2>What backtesting stocks can and can&#8217;t tell you<\/h2>\n<p>Start with what a historical simulation genuinely gives you, because it&#8217;s a lot:<\/p>\n<ul>\n<li><strong>Whether an idea was ever viable.<\/strong> If your strategy loses money across decades of history, you&#8217;ve learned something important for the price of a little compute time instead of your savings. That alone makes backtesting worth doing.<\/li>\n<li><strong>How it behaved through different regimes.<\/strong> Markets have moods &#8211; long calm bull runs, sharp panics, sideways grinds, rate shocks. A strategy that only ever saw one regime is a strategy you know very little about. Context in markets is everything, and a long backtest is how you get context.<\/li>\n<li><strong>What the ride would have felt like.<\/strong> This one is underrated. A backtest shows you the drawdowns &#8211; the stretches where the strategy was underwater and stayed there. It&#8217;s easy to look at a smooth long-term line and say &#8220;I&#8217;d hold through that.&#8221; It&#8217;s much harder to actually sit through the losing years in real time. Knowing the depth and length of historical drawdowns tells you whether you could realistically stick with the strategy at all.<\/li>\n<\/ul>\n<p>Here&#8217;s what it cannot do: tell you the future. The market that generated your historical data is not obligated to keep behaving that way.<\/p>\n<p>This is where the process-versus-outcome distinction matters, and it&#8217;s worth internalizing. A good process can have a bad year. A bad process can get lucky for a while. A backtest helps you evaluate the <em>process<\/em> &#8211; was this a sound way to make decisions, across many environments? &#8211; rather than guaranteeing any particular outcome. If you find yourself treating a backtest as a forecast, step back. It&#8217;s a rearview mirror, and a slightly foggy one.<\/p>\n<h2>The five ways backtests lie to you<\/h2>\n<p>Most flattering backtests aren&#8217;t dishonest on purpose. They&#8217;re wrong in one of five specific, well-known ways. Learn these five and you&#8217;re ahead of most people who backtest a trading strategy.<\/p>\n<h3>1. Overfitting<\/h3>\n<p>Give a model enough knobs and history will confess to anything.<\/p>\n<p>If your strategy has a lookback window, an entry threshold, an exit threshold, a stop level, and a filter, and you tuned each one until the results looked great&#8230; the results will look great. That&#8217;s not evidence the strategy works. That&#8217;s evidence you searched until you found the parameter combination that happened to fit the random noise in one particular slice of history. The strategy has memorized the past instead of learning something true about markets.<\/p>\n<p>The tell: performance that collapses the moment you nudge a parameter. A robust idea should degrade gracefully &#8211; if moving a threshold slightly turns a winner into a loser, you didn&#8217;t find an edge, you found a coincidence.<\/p>\n<h3>2. Look-ahead bias<\/h3>\n<p>This is using information your strategy could not have had at that moment. It sneaks in quietly:<\/p>\n<ul>\n<li>Using a day&#8217;s <strong>closing price<\/strong> to make a decision &#8220;during&#8221; that day. At 11am you don&#8217;t know where the close will be, but a sloppy backtest happily pretends you do.<\/li>\n<li>Using <strong>restated fundamentals<\/strong>. Companies revise their financials after the fact. If your backtest uses the corrected numbers, it&#8217;s trading on data that didn&#8217;t exist when the trade would have happened.<\/li>\n<li>Using <strong>today&#8217;s index membership<\/strong> for historical trades. &#8220;Buy stocks in the index&#8221; tested with the current list means you knew, years in advance, which companies would grow into the index. That&#8217;s not a strategy, that&#8217;s time travel.<\/li>\n<\/ul>\n<p>Look-ahead bias is nasty because it always flatters you. Errors that hurt your results get noticed and fixed. Errors that help your results feel like edge.<\/p>\n<h3>3. Survivorship bias<\/h3>\n<p>If your test universe is &#8220;stocks that trade today,&#8221; you&#8217;ve quietly deleted every company that went bankrupt, got delisted, or faded away. The failures vanish from history, and your backtest only ever meets the winners.<\/p>\n<p>Think about what that does to almost any buy-and-hold-flavored strategy. The companies that would have destroyed your returns aren&#8217;t in the data to hurt you. You&#8217;re testing on a universe pre-filtered for survival, which is exactly the information you won&#8217;t have when trading forward. The result is inflated, sometimes wildly so, and the inflation is invisible unless you go looking for it.<\/p>\n<h3>4. Ignoring costs<\/h3>\n<p>Backtests trade for free. You don&#8217;t.<\/p>\n<p>Commissions, bid-ask spreads, and slippage (the gap between the price your backtest assumes and the price you actually get filled at) all take their cut on every single trade. For a strategy that trades occasionally, the drag is modest. For a strategy that trades constantly, costs can be the whole story &#8211; wonderful gross, a loser net. The more your edge depends on frequent trading, the more skeptical you should be until costs are modeled realistically.<\/p>\n<h3>5. Unadjusted data<\/h3>\n<p>This one is mechanical, and it will fabricate enormous fake returns if you miss it.<\/p>\n<p>When a stock splits 2-for-1, its price halves overnight. Nobody lost anything &#8211; shareholders got twice the shares &#8211; but a raw, unadjusted price series shows a massive one-day crash that never economically happened. A backtest on that series will &#8220;trade&#8221; phantom moves. Dividends cut the other way: prices dip on ex-dividend dates, so raw prices quietly erase the dividend portion of returns, which over decades is a very large portion indeed.<\/p>\n<p>The fix is to backtest on split- and dividend-adjusted prices, full stop. It sounds obvious. It&#8217;s also one of the most common data mistakes we see.<\/p>\n<h2>How to backtest a trading strategy properly<\/h2>\n<p>Knowing the traps is half the job. Here&#8217;s the working method for the other half:<\/p>\n<ol>\n<li><strong>Split your history into in-sample and out-of-sample.<\/strong> Develop, tune, and iterate only on the in-sample portion. The out-of-sample portion is sacred &#8211; you touch it once, at the end, as a genuine test. If the strategy only works in-sample, it doesn&#8217;t work.<\/li>\n<li><strong>Prefer walk-forward testing to a single split.<\/strong> Instead of one train\/test division, roll forward through time: develop on a window, test on the period just after it, slide forward, repeat. It&#8217;s closer to how you&#8217;d actually run the strategy, and it forces the idea to prove itself across many different periods instead of one lucky one.<\/li>\n<li><strong>Keep the parameter count small.<\/strong> Every knob you add is another chance to fit noise. A strategy with two or three parameters that performs decently is far more trustworthy than one with ten parameters that performs brilliantly. Simplicity here isn&#8217;t aesthetic &#8211; it&#8217;s statistical self-defense. (Though we do strive for beautiful minimalism at Tiingo, so maybe it&#8217;s a little aesthetic too.)<\/li>\n<li><strong>Model costs like a pessimist.<\/strong> Include commissions, spreads, and slippage at realistic or slightly worse-than-realistic levels. If the strategy survives pessimistic costs, wonderful. If it only survives free trading, you&#8217;ve learned that too.<\/li>\n<li><strong>Check what&#8217;s carrying the results.<\/strong> Remove the best few days or trades and rerun. If the entire edge came from a handful of moments, you&#8217;re not looking at a repeatable process &#8211; you&#8217;re looking at a couple of lottery tickets that happened to hit in your sample.<\/li>\n<\/ol>\n<p>Notice what every step has in common. None of it is mathematically hard. All of it is psychologically hard, because each step exists to take away your ability to fool yourself. The real skill in backtesting is being honest with yourself when the honest answer is disappointing, not coding or statistics.<\/p>\n<p>A backtest that kills your idea is a successful backtest. It just saved you real money.<\/p>\n<h2>What good backtest data requires<\/h2>\n<p>Your simulation can only be as honest as the data underneath it. Four things matter most:<\/p>\n<ul>\n<li><strong>Split- and dividend-adjusted prices.<\/strong> Non-negotiable, for the reasons above. Total return over long horizons depends heavily on dividends, and split artifacts will wreck any signal.<\/li>\n<li><strong>Enough history to cover multiple regimes.<\/strong> A few years of data means a few years of one market mood. Decades of data means your strategy has been through crashes, recoveries, and long boring stretches. The more regimes your test spans, the more your results mean.<\/li>\n<li><strong>Point-in-time consistency.<\/strong> The data should reflect what was knowable at each moment, not what was corrected later. This matters most for fundamentals, but it applies broadly.<\/li>\n<li><strong>Coverage of delisted and renamed tickers, where possible.<\/strong> This is the survivorship problem again. Truly survivorship-free universes are genuinely hard to build &#8211; names change, companies merge, records get messy &#8211; and few data sources solve it completely. If your universe doesn&#8217;t include the dead companies, you don&#8217;t necessarily need to abandon the test, but you do need to hold the results more loosely and know which direction the bias points: up.<\/li>\n<\/ul>\n<h2>Getting the data<\/h2>\n<p>Backtesting used to be gated behind institutional data budgets, and that always bothered me. Testing an idea before risking money on it shouldn&#8217;t be a privilege. It&#8217;s a big part of why Tiingo exists &#8211; we&#8217;ve been making high-end market data accessible and affordable since 2014, priced by asking how much we can give rather than how much we can charge. No outside investors, profitable for 8+ years, so we get to keep it that way.<\/p>\n<p>For backtesting stocks, the practical answer is our end-of-day API. Here&#8217;s the entire setup:<\/p>\n<pre><code>import requests\n\nurl = \"https:\/\/api.tiingo.com\/tiingo\/daily\/aapl\/prices\"\nparams = {\"token\": \"YOUR_TOKEN\", \"startDate\": \"2010-01-01\"}\nbars = requests.get(url, params=params).json()\n<\/code><\/pre>\n<p>Each bar gives you <code>date<\/code>, <code>open<\/code>, <code>high<\/code>, <code>low<\/code>, <code>close<\/code>, and <code>volume<\/code>, plus the fields you actually want for a backtest: <code>adjClose<\/code>, <code>adjOpen<\/code>, <code>adjHigh<\/code>, <code>adjLow<\/code>, and <code>adjVolume<\/code>, all split- and dividend-adjusted. We error-check the distributions and splits as well as the prices themselves, because an adjustment built on a wrong dividend is just a different flavor of bad data. Clean data should be boring, and we work hard to keep it that way.<\/p>\n<p>On depth: our end-of-day history goes back to 1962, so your walk-forward tests can span every regime from the 1960s onward. The free tier gets you 30+ years of price history, 500 unique symbols a month, and 1,000 requests a day at $0 &#8211; genuinely enough to research and test strategies properly, not a teaser. If you outgrow it, Power is $30\/month ($300\/year). The full details are in the <a href=\"https:\/\/www.tiingo.com\/documentation\/end-of-day\">end-of-day API documentation<\/a> and on our <a href=\"https:\/\/www.tiingo.com\/pricing\">pricing page<\/a>.<\/p>\n<h2>The bottom line<\/h2>\n<p>A backtest done well is one of the best tools you have. It tells you whether an idea was ever viable, shows you the drawdowns you&#8217;d have had to live through, and kills bad strategies before they can cost you real money. A backtest done to confirm what you already believe is just expensive self-flattery with extra steps.<\/p>\n<p>The difference between the two is discipline, not software or math: to hold out data you never peek at, to model costs like a pessimist, and to accept a disappointing answer when the data gives you one. Every honest &#8220;no&#8221; from a backtest is money still in your pocket.<\/p>\n<p>If you want to start testing against clean, adjusted history going back decades, <a href=\"https:\/\/www.tiingo.com\/\">grab a free API token<\/a> and dig in. And if you find something interesting in the data, we&#8217;d love to hear about it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Backtesting stocks means replaying your trading rules over historical data to see how they would have behaved. You take a strategy &#8211; &#8220;buy when this happens, sell when that happens&#8221; &#8211; run it against the past, and look at what comes out the other side. It&#8217;s one of the most useful things a trader or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":690,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"osom_blocks_metabox":"","inline_featured_image":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-253","post","type-post","status-publish","format-standard","has-post-thumbnail","category-engineering","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.1 (Yoast SEO v28.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Backtesting Stocks: How to Test a Strategy Properly - Tiingo Blog<\/title>\n<meta name=\"description\" content=\"How to backtest stocks properly: what a backtest can and cannot tell you, the five ways backtests mislead you, and the method that keeps you honest.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Backtesting Stocks: How to Test a Strategy Before You Risk Money\" \/>\n<meta property=\"og:description\" content=\"How to backtest stocks properly: what a backtest can and cannot tell you, the five ways backtests mislead you, and the method that keeps you honest.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/\" \/>\n<meta property=\"og:site_name\" content=\"Tiingo Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tiingofinance\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T12:25:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-25T01:46:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rishi S.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@tiingofinance\" \/>\n<meta name=\"twitter:site\" content=\"@tiingofinance\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rishi S.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/\"},\"author\":{\"name\":\"Rishi S.\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#\\\/schema\\\/person\\\/54fc93e1626ed221a37fcfddb597c3d6\"},\"headline\":\"Backtesting Stocks: How to Test a Strategy Before You Risk Money\",\"datePublished\":\"2023-07-18T12:25:34+00:00\",\"dateModified\":\"2026-07-25T01:46:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/\"},\"wordCount\":1987,\"publisher\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/h253.png\",\"articleSection\":[\"Engineering\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/\",\"url\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/\",\"name\":\"Backtesting Stocks: How to Test a Strategy Properly - Tiingo Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/h253.png\",\"datePublished\":\"2023-07-18T12:25:34+00:00\",\"dateModified\":\"2026-07-25T01:46:07+00:00\",\"description\":\"How to backtest stocks properly: what a backtest can and cannot tell you, the five ways backtests mislead you, and the method that keeps you honest.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/h253.png\",\"contentUrl\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/h253.png\",\"width\":1200,\"height\":630,\"caption\":\"Flat illustration of a calendar grid split into a filled in-sample period and a hollow out-of-sample period\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/backtesting-stocks\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Backtesting Stocks: How to Test a Strategy Before You Risk Money\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/\",\"name\":\"Tiingo API Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#organization\",\"name\":\"Tiingo.com\",\"url\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/api.tiingo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/purple-for-light-bg.svg\",\"contentUrl\":\"https:\\\/\\\/api.tiingo.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/purple-for-light-bg.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"Tiingo.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/tiingofinance\\\/\",\"https:\\\/\\\/x.com\\\/tiingofinance\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/#\\\/schema\\\/person\\\/54fc93e1626ed221a37fcfddb597c3d6\",\"name\":\"Rishi S.\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/28ae16ae1fe9df62492ab4b742241b19a6a12395109570074a7b8194c6709ec4?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/28ae16ae1fe9df62492ab4b742241b19a6a12395109570074a7b8194c6709ec4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/28ae16ae1fe9df62492ab4b742241b19a6a12395109570074a7b8194c6709ec4?s=96&d=mm&r=g\",\"caption\":\"Rishi S.\"},\"description\":\"Rishi Singh is the CEO of Tiingo.com. A prior algorithmic and quant researcher, Rishi started Tiingo.com to modernize the financial data vertical by focusing on data acquisition, cleansing, aggregation, innovation, and distribution of data.\",\"sameAs\":[\"http:\\\/\\\/www.tiingo.com\"],\"url\":\"https:\\\/\\\/www.tiingo.com\\\/blog\\\/author\\\/rishi-s\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Backtesting Stocks: How to Test a Strategy Properly - Tiingo Blog","description":"How to backtest stocks properly: what a backtest can and cannot tell you, the five ways backtests mislead you, and the method that keeps you honest.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/","og_locale":"en_US","og_type":"article","og_title":"Backtesting Stocks: How to Test a Strategy Before You Risk Money","og_description":"How to backtest stocks properly: what a backtest can and cannot tell you, the five ways backtests mislead you, and the method that keeps you honest.","og_url":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/","og_site_name":"Tiingo Blog","article_publisher":"https:\/\/www.facebook.com\/tiingofinance\/","article_published_time":"2023-07-18T12:25:34+00:00","article_modified_time":"2026-07-25T01:46:07+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253.png","type":"image\/png"}],"author":"Rishi S.","twitter_card":"summary_large_image","twitter_creator":"@tiingofinance","twitter_site":"@tiingofinance","twitter_misc":{"Written by":"Rishi S.","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#article","isPartOf":{"@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/"},"author":{"name":"Rishi S.","@id":"https:\/\/www.tiingo.com\/blog\/#\/schema\/person\/54fc93e1626ed221a37fcfddb597c3d6"},"headline":"Backtesting Stocks: How to Test a Strategy Before You Risk Money","datePublished":"2023-07-18T12:25:34+00:00","dateModified":"2026-07-25T01:46:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/"},"wordCount":1987,"publisher":{"@id":"https:\/\/www.tiingo.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#primaryimage"},"thumbnailUrl":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253.png","articleSection":["Engineering"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/","url":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/","name":"Backtesting Stocks: How to Test a Strategy Properly - Tiingo Blog","isPartOf":{"@id":"https:\/\/www.tiingo.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#primaryimage"},"image":{"@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#primaryimage"},"thumbnailUrl":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253.png","datePublished":"2023-07-18T12:25:34+00:00","dateModified":"2026-07-25T01:46:07+00:00","description":"How to backtest stocks properly: what a backtest can and cannot tell you, the five ways backtests mislead you, and the method that keeps you honest.","breadcrumb":{"@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#primaryimage","url":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253.png","contentUrl":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253.png","width":1200,"height":630,"caption":"Flat illustration of a calendar grid split into a filled in-sample period and a hollow out-of-sample period"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tiingo.com\/blog\/backtesting-stocks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.tiingo.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Backtesting Stocks: How to Test a Strategy Before You Risk Money"}]},{"@type":"WebSite","@id":"https:\/\/www.tiingo.com\/blog\/#website","url":"https:\/\/www.tiingo.com\/blog\/","name":"Tiingo API Blog","description":"","publisher":{"@id":"https:\/\/www.tiingo.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.tiingo.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.tiingo.com\/blog\/#organization","name":"Tiingo.com","url":"https:\/\/www.tiingo.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.tiingo.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/api.tiingo.com\/blog\/wp-content\/uploads\/2023\/05\/purple-for-light-bg.svg","contentUrl":"https:\/\/api.tiingo.com\/blog\/wp-content\/uploads\/2023\/05\/purple-for-light-bg.svg","width":"1024","height":"1024","caption":"Tiingo.com"},"image":{"@id":"https:\/\/www.tiingo.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tiingofinance\/","https:\/\/x.com\/tiingofinance"]},{"@type":"Person","@id":"https:\/\/www.tiingo.com\/blog\/#\/schema\/person\/54fc93e1626ed221a37fcfddb597c3d6","name":"Rishi S.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/28ae16ae1fe9df62492ab4b742241b19a6a12395109570074a7b8194c6709ec4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/28ae16ae1fe9df62492ab4b742241b19a6a12395109570074a7b8194c6709ec4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28ae16ae1fe9df62492ab4b742241b19a6a12395109570074a7b8194c6709ec4?s=96&d=mm&r=g","caption":"Rishi S."},"description":"Rishi Singh is the CEO of Tiingo.com. A prior algorithmic and quant researcher, Rishi started Tiingo.com to modernize the financial data vertical by focusing on data acquisition, cleansing, aggregation, innovation, and distribution of data.","sameAs":["http:\/\/www.tiingo.com"],"url":"https:\/\/www.tiingo.com\/blog\/author\/rishi-s\/"}]}},"featured_image_src":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253-600x400.png","featured_image_src_square":"https:\/\/www.tiingo.com\/blog\/wp-content\/uploads\/2023\/07\/h253-600x600.png","author_info":{"display_name":"Rishi S.","author_link":"https:\/\/www.tiingo.com\/blog\/author\/rishi-s\/"},"_links":{"self":[{"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/posts\/253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/comments?post=253"}],"version-history":[{"count":4,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/posts\/253\/revisions"}],"predecessor-version":[{"id":778,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/posts\/253\/revisions\/778"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/media\/690"}],"wp:attachment":[{"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/media?parent=253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/categories?post=253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tiingo.com\/blog\/wp-json\/wp\/v2\/tags?post=253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}