<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by E Kartik on Medium]]></title>
        <description><![CDATA[Stories by E Kartik on Medium]]></description>
        <link>https://medium.com/@ekartik82?source=rss-d4407a413567------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5BO93Ze33GGN1CDUmZOwAw.jpeg</url>
            <title>Stories by E Kartik on Medium</title>
            <link>https://medium.com/@ekartik82?source=rss-d4407a413567------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 10:03:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ekartik82/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[When not to use AI in Trading]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ekartik82/when-not-to-use-ai-in-trading-47e2c103f88f?source=rss-d4407a413567------2"><img src="https://cdn-images-1.medium.com/max/2600/1*Q-q2lFabvFWLqA7CWgQ6Yw.jpeg" width="3072"></a></p><p class="medium-feed-snippet">A Decision Map for Where Models Help and Where They Hurt</p><p class="medium-feed-link"><a href="https://medium.com/@ekartik82/when-not-to-use-ai-in-trading-47e2c103f88f?source=rss-d4407a413567------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ekartik82/when-not-to-use-ai-in-trading-47e2c103f88f?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/47e2c103f88f</guid>
            <category><![CDATA[options-trading]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[risk-management]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Mon, 16 Nov 2026 08:28:48 GMT</pubDate>
            <atom:updated>2026-11-16T08:28:48.137Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Deep Learning: When Is It Worth It?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ekartik82/deep-learning-when-is-it-worth-it-e257402044c4?source=rss-d4407a413567------2"><img src="https://cdn-images-1.medium.com/max/2600/1*nZcfNFUUsvrQqYHyTJit0g.jpeg" width="3872"></a></p><p class="medium-feed-snippet">Part 9 of the series: Machine Learning for Systematic Traders</p><p class="medium-feed-link"><a href="https://medium.com/@ekartik82/deep-learning-when-is-it-worth-it-e257402044c4?source=rss-d4407a413567------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ekartik82/deep-learning-when-is-it-worth-it-e257402044c4?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/e257402044c4</guid>
            <category><![CDATA[systematic-trading]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 13:17:00 GMT</pubDate>
            <atom:updated>2026-10-30T13:17:00.450Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building a Broker-Connected Backtester with Claude Code: Architecture, Design & Implementation]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ekartik82/building-a-broker-connected-backtester-with-claude-code-architecture-design-implementation-45a7e753d151?source=rss-d4407a413567------2"><img src="https://cdn-images-1.medium.com/max/2400/1*GHfQfuqBZONwNikXRptA7g.png" width="2400"></a></p><p class="medium-feed-snippet">A phase-by-phase look at a Python and PostgreSQL backtester that syncs real market data, tests strategies with realistic costs, and shows&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@ekartik82/building-a-broker-connected-backtester-with-claude-code-architecture-design-implementation-45a7e753d151?source=rss-d4407a413567------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ekartik82/building-a-broker-connected-backtester-with-claude-code-architecture-design-implementation-45a7e753d151?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/45a7e753d151</guid>
            <category><![CDATA[systematic-trading]]></category>
            <category><![CDATA[backtesting]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 08:54:33 GMT</pubDate>
            <atom:updated>2026-10-28T08:54:33.082Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Time Series Forecasting with ML]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ekartik82/time-series-forecasting-with-ml-d694295136c0?source=rss-d4407a413567------2"><img src="https://cdn-images-1.medium.com/max/2600/1*DArtaGIFO6rZig0EInpN6w.jpeg" width="5760"></a></p><p class="medium-feed-snippet">Part 8 of the series: Machine Learning for Systematic Traders</p><p class="medium-feed-link"><a href="https://medium.com/@ekartik82/time-series-forecasting-with-ml-d694295136c0?source=rss-d4407a413567------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ekartik82/time-series-forecasting-with-ml-d694295136c0?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/d694295136c0</guid>
            <category><![CDATA[timeseries-forecasting]]></category>
            <category><![CDATA[systematic-trading]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 15:29:07 GMT</pubDate>
            <atom:updated>2026-10-29T15:45:53.648Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[AI and the New Statistical Toolkit for Traders]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ekartik82/ai-and-the-new-statistical-toolkit-for-traders-f53577d4a6d7?source=rss-d4407a413567------2"><img src="https://cdn-images-1.medium.com/max/2600/1*wtJOJhzuC9lSaaI_iOAReA.jpeg" width="4069"></a></p><p class="medium-feed-snippet">Machine Learning tools that help retail options traders estimate probabilities and the limits that come with them</p><p class="medium-feed-link"><a href="https://medium.com/@ekartik82/ai-and-the-new-statistical-toolkit-for-traders-f53577d4a6d7?source=rss-d4407a413567------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ekartik82/ai-and-the-new-statistical-toolkit-for-traders-f53577d4a6d7?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/f53577d4a6d7</guid>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[options-trading]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 12:32:04 GMT</pubDate>
            <atom:updated>2026-10-24T12:42:08.281Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Statistical Thinking for Options Traders]]></title>
            <link>https://medium.com/@ekartik82/statistical-thinking-for-options-traders-39781e64bf79?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/39781e64bf79</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[options-trading]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 16:28:48 GMT</pubDate>
            <atom:updated>2026-10-22T16:28:48.453Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A mindset shift from outcomes to probabilistic thinking</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIO_rQQrgRg2jS0_7uVvYA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@timothycdykes?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Timothy Dykes</a> on <a href="https://unsplash.com/photos/a-close-up-of-a-blue-and-red-dice-g4jLqdUh98M?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>The Problem with Judging Trades by Outcome</h3><p>Most options traders judge the quality of a trade by its outcome. A trade that closes green is labeled a good decision, while one that ends in red is often treated as a mistake—the strike selection is questioned, the entry timing second-guessed, or the market’s move dismissed as an unexpected turn against the thesis. In this type of framework, profit and loss becomes the final verdict, delivered the moment the position is closed.</p><p>This feels obvious. What else would decision quality be measured against, if not the result? And yet, this seemingly intuitive habit is one of the fastest ways to develop poor trading instincts. A trade can be exited exactly as planned, sized correctly, aligned with every rule in a well-tested system — and still lose money. Another trade can break every rule, ignore the setup entirely, get lucky, and print a profit. Viewed through a win/loss lens, the second trade might look better than the first. It isn’t, and most traders know this — yet keep scoring their own trades the same broken way the next morning.</p><p>Discipline is not the problem here. Neither is skill. Outcomes are noisy; a single trade is basically one sample pulled from a much wider range of things that could have happened. Judging decision quality by a single outcome is like judging a coin as unfair after a single flip — technically a data point, but practically meaningless.</p><p>There is a different way to keep score — one built on probability rather than outcomes, and it redefines what a ‘good trade’ even means.</p><h3>A Trade is a Bet on a Distribution</h3><p>An outcome does not exist before a trade is placed. What exists instead is a ‘range’ of outcomes, each having a certain likelihood. The price may rally sharply, drift sideways, or fall. Each of those scenarios has a different payoff. This spread of outcomes and their respective likelihoods is a probability distribution, and every trade is basically a bet on one.</p><p>From this perspective, a trade is not a prediction. A prediction says something like “the market will go up.” A probability distribution, on the other hand, says, “across the many ways this could unfold, the outcomes that pay off outweigh the ones that don’t.” This statement can hold even when the trade loses, in the same way a coin flip that lands heads 60% of the time still produces tails regularly. A single tail does not disprove the bias. It is just the other 40% showing up.</p><p>Three ideas carry the most importance here:</p><ol><li><strong>Distribution: </strong>The full range of possible outcomes, not just the one that happened.</li><li><strong>Edge: </strong>The tilt in the distribution that makes the average result favorable.</li><li><strong>Variance: </strong>How widely outcomes scatter around that average, which decides how bumpy the ride is.</li></ol><p>A ‘good’ trade could be one where the distribution was favorable at the moment of entry, regardless of the outcome.</p><p>Let’s look at an example options trade to see how this plays out.</p><h3>One Setup, Two Opposite Verdicts</h3><p>Consider a systematic trader who follows a specific, documented plan on a broad market index. If the index holds above a key level and volatility is subdued, the plan calls for buying a slightly OTM (out-of-the-money) call option, risking a fixed premium and exiting at a preset stop or target (all numbers here are illustrative).</p><p>Let’s say on the first day, the conditions line up. The call is bought at a premium of 100 points, with a stop at 60 and a target of 180. Within a couple of hours, the index dips due to selling pressure, and the option hits the stop. The loss is 40 points. The post-market review is short and familiar: wrong strike, poor timing, should have waited. The trade most likely ends up as a mistake in the journal.</p><p>Three weeks later, the same conditions appear. Same plan, same entry, same size. This time the index steadily rises higher, and the option reaches its target for a gain of 80 points. The journal entry would now read very differently: patient entry, good read, plan worked.</p><p>Nothing about the decision changed between those two days. Only the outcome did. Yet, the first trade was filed as an error in judgment, and the second as skill. Each carried a lesson the evidence never supported: second-guessing a sound plan after the loss, and a bit of extra confidence after the win.</p><h3>What the Trader Actually Knew</h3><p>Before either of those trades were placed, the outcome was unknowable, but the odds were not. A systematic trader following a specific plan usually has a record of how that setup has behaved in the past: the same conditions, entry, stop, and target, observed across several past occurrences. Let’s say this record covers 200 instances, and the results fall into three hypothetical buckets. In about 40% of the cases, the option reached its target for a gain of 70–80 points. In about 50% of the cases, it hit the stop-loss of 40 points. In the remaining 10%, the trade went nowhere and roughly exited at breakeven (all figures remain illustrative).</p><p>This record is the distribution. Weighting each bucket by its frequency gives the average result per trade: 0.40 x 80, minus 0.50 x 40, plus 0.10 x 0, which comes to +12 points. This number is the edge. It does not promise profit for any day. It describes where results may converge after several repetitions.</p><p>The same record describes variance as well. Half of all trades end at the stop. A run of five such consecutive losses has a probability of about 3%, which may sound remote until the setup repeats a few hundred times, at which point such a streak becomes a normal feature of the landscape rather than a sign that something broke. Five stops in a row can cost 200 points, and a backtested plan with a real, positive edge will still produce it from time to time.</p><p>Returning to those two days, the first trade drew from the 50% bucket and the second from the 40%. Both were legitimate samples from the same distribution. The decision for each day was identical: valid setup, the planned size, a preset stop and target. The only thing that differed was which part of the distribution chose to show itself.</p><p>This introduces a fundamental shift in what a journal entry should actually say. Instead of grading the outcome, the review might ask three questions. Did the setup meet the documented conditions? Was the position sized as per the pre-defined rules? Was the exit carried out as planned? A trade that passes these three gates is a good decision, whether it made 80 points or lost 40.</p><p>One question remains: if single outcomes convey so little, what might the evidence for an edge actually look like over many trades?</p><h3>Why the Edge Shows Up Over Many Trades</h3><p>A single trade is too small a sample to reveal anything about an edge. The process defines the edge, and it becomes visible only as trades accumulate. The illustrative setup makes this concrete. Each trade averages +12 points, with results scattering widely around that figure. Working through the 40/50/10 split, the standard deviation comes to roughly 57 points per trade, nearly five times the average gain. That kind of noise-to-edge ratio explains why short stretches of trading feel random.</p><p>The effect of sample size is easy to see:</p><ol><li><strong>After 10 trades, </strong>the expected total is around +120 points, with the scatter around 180 points. Roughly one in four such stretches still ends in a loss, even with a genuine edge.</li><li><strong>After 100 trades, </strong>the expected total climbs to +1,200 points against a scatter of 570. The odds of finishing negative fall to around 2%.</li><li><strong>After 200 trades, </strong>the expected total is around +2,400 points against a scatter of 800. A losing stretch becomes rare, well under 1%.</li></ol><p>(These figures assume a normal approximation and are illustrative)</p><p>The edge itself does not change across those three rows. What changes is how much room the noise has to hide it. The same logic explains why a trader can be on a losing streak with a sound plan, and why another can be on a winning streak with a flawed one. Ten trades say very little either way.</p><p>None of this is specific to options, of course. An equity trader buying pullbacks or breakouts faces the same arithmetic: a payoff profile, a win frequency, and a sample that has to grow before the evidence means anything. If the edge seems uncertain and the noise is large, the next question is how to measure both, and that is where the statistical toolkit comes in handy.</p><h3>The Shift in Practice</h3><p>The mindset shift that follows from all this may look small in appearance and large in effect. The question asked after a trade closes is no longer “did it make money?” but “was it a good decision given what was known?” A trade that followed the plan and lost is filed as a good decision with an unlucky draw. A trade that broke the rules and won is filed as a bad decision that happened to be rewarded.</p><p>Here’s an accessible toolkit that makes this habit practical:</p><ol><li><strong>Trade Journals &amp; spreadsheets </strong>turn every trade into a record of setup, size, exit, and outcome. This ensures the distribution comes from data and not memory.</li><li><strong>Python and basic statistics libraries </strong>make it easier to compute expectancy, scatter, drawdowns, and confidence ranges from that record.</li><li><strong>Monte Carlo simulation </strong>replays a plan thousands of times, showing how long losing streaks can get before the edge shows up.</li><li><strong>Walk-Forward testing </strong>checks whether an edge holds on data the plan has never seen, which guards against fooling oneself with a flattering backtest.</li><li><strong>Machine learning models </strong>can estimate volatility, classify market regimes, and flag when current conditions no longer resemble the historical record.</li><li><strong>AI assistants </strong>can speed up the surrounding work: writing analysis code, reviewing journals for patterns, and stress-testing assumptions.</li></ol><p>This is the real shift: from asking what the market will do next to asking what the odds are, how confident the estimate is, and what a trade is worth when repeated several times. Tools make that question answerable at scale, and the next step is learning to use them well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39781e64bf79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Water Finds Its Level: A Complete Intuition for Gradient Descent]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ekartik82/how-water-finds-its-level-a-complete-intuition-for-gradient-descent-f858c4bdcde2?source=rss-d4407a413567------2"><img src="https://cdn-images-1.medium.com/max/2600/1*BowVVo_kflyR6WpryADMvw.jpeg" width="4898"></a></p><p class="medium-feed-snippet">The most fundamental algorithm in machine learning, explained without a single equation</p><p class="medium-feed-link"><a href="https://medium.com/@ekartik82/how-water-finds-its-level-a-complete-intuition-for-gradient-descent-f858c4bdcde2?source=rss-d4407a413567------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ekartik82/how-water-finds-its-level-a-complete-intuition-for-gradient-descent-f858c4bdcde2?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/f858c4bdcde2</guid>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 17:26:12 GMT</pubDate>
            <atom:updated>2026-08-04T17:26:12.762Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Unsupervised Learning: Finding Structure in Markets]]></title>
            <link>https://medium.com/@ekartik82/unsupervised-learning-finding-structure-in-markets-7b46cff64e78?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b46cff64e78</guid>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[systematic-trading]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Sun, 12 Jul 2026 05:23:06 GMT</pubDate>
            <atom:updated>2026-07-12T05:24:52.740Z</atom:updated>
            <content:encoded><![CDATA[<p>Part 7 of the series: Machine Learning for Systematic Traders</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8N-k28tm3Oa2umthjxFxw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@hdbernd?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Bernd 📷 Dittrich</a> on <a href="https://unsplash.com/photos/a-bird-is-perched-on-a-fence-post-EGW1Fy8BmeI?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Disclaimer: This article is for educational purposes only and does not constitute financial advice. All examples use hypothetical market data constructed for illustrative purposes. Always consult a qualified financial adviser before making investment decisions.</em></p><p><em>Note: This article builds conceptual intuition for unsupervised learning techniques and does not include code. Implemented walkthroughs will follow later in this series.</em></p><p>Most systematic traders run into a peculiar situation sooner or later — a strategy that performed well, right up until it didn’t. The rules were solid. Backtests were good. Validations were rigorous. Yet, for weeks or months, the strategy underperformed in a way that does not feel random. Then, market conditions shifted, and the whole thing came back to life.</p><p>The explanation, in most cases, is market regime. The market entered a specific phase the strategy wasn’t designed to navigate. Once that phase passed, the strategy recovered. The edge never disappeared. It was being applied in the wrong environment.</p><p>This is a problem unsupervised learning is well-positioned to solve. Not by predicting returns, but by identifying structure — the underlying conditions the market is operating in — giving strategies a way to adapt as those conditions change.</p><h3>The difference between Supervised and Unsupervised Learning</h3><p>Parts 4 &amp; 5 worked with supervised learning: models trained on labelled examples, where every input had a known correct output. The model learns patterns by comparing its predictions to those labels and adjusting till it starts performing better.</p><p>Unsupervised learning does not work with labels. There is no correct answer to train against. There is just data and a need to understand it. The model’s task is to find structure in the data — groupings, patterns, or relationships that were not specified in advance.</p><p>Clustering is the most useful form of unsupervised learning for systematic trading. It is mainly the process of grouping historical market observations into segments that share similar characteristics. Those segments, once identified, can be interpreted as market regimes: distinct conditions that require different strategy responses.</p><p>The regimes are not defined in advance, and that is a key distinction from supervised learning. An unsupervised approach lets the data define what the regimes are — and sometimes discovers structure that a human analyst may have missed. A supervised approach, on the other hand, would label each day as “trending” or “mean-reverting” based on some pre-determined rule, and then have a classifier trained to predict which label applies.</p><h3>Introducing the hypothetical dataset: MarketSim</h3><p>To illustrate market regime detection, this article uses MarketSim — a hypothetical broad market index with 750 days of simulated daily data. The data is constructed to exhibit realistic regime behaviour: periods of sustained trend, periods of choppy, sideways movement, and periods of elevated volatility with mean-reverting characteristics.</p><p>Raw features extracted from MarketSim for each trading day are:</p><ul><li><strong>20-day return: </strong>captures medium-term directional momentum</li><li><strong>20-day volatility: </strong>rolling standard deviation of daily returns</li><li><strong>Average True Range ratio: </strong>intraday range relative to recent history</li><li><strong>Volume trend: </strong>five-day volume relative to 20-day average</li><li><strong>Return autocorrelation: </strong>tendency of recent returns to continue or reverse</li></ul><p>These five features describe the market’s current behavior across multiple dimensions. The goal is to group days with similar feature profiles into clusters — and interpret those clusters as regimes.</p><p>Here’s a sample of what MarketSim’s feature matrix looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*SigwGbOMjTiqBqFKc7eq-w.png" /><figcaption>MarketSim — Feature Matrix Table generated by AI-written Code</figcaption></figure><p>The patterns start to become clearer— Day 1 &amp; 2 look similar to each other, and are quite different from Day 3 &amp; 4. Day 5 sits somewhere in between. Clustering helps in formalising these intuitive similarities into consistent groups across all 750 days.</p><h3>The dimensionality problem</h3><p>Five features are manageable. But regime detection in practice involves several features — multiple momentum signals across different horizons, various volatility measures, cross-asset indicators, sentiment proxies. As the number of features grows, clustering becomes progressively harder.</p><p>One of the core challenges is high dimensionality. In such a space, every data point is approximately equidistant from every other point. The notion of “similar” — on which clustering depends — breaks down. Two days belonging to the same regime may look no more similar to each other than to any random day in the dataset. This is because the distance calculation spans too many dimensions.</p><p>A practical solution is dimensionality reduction: transforming a high-dimensional feature space into a lower-dimensional representation that preserves the most important structure in the data. The most widely used technique for this is Principal Component Analysis (PCA).</p><h3>PCA: finding directions that matter</h3><p>PCA identifies directions in the feature space along which the data varies most. These directions are called principal components, and they are linear combinations of the original features. The first principal component captures the largest source of variation in the data. The second captures the largest remaining variation that is orthogonal to the first one. And so on.</p><p>The practical value of PCA is that a small set of principal components — often two or three — can capture most of the meaningful variation in a dataset while preserving as much of the original structure as possible. The remaining components capture progressively less variance and are discarded without much information loss.</p><p>Applied to MarketSim’s five-feature dataset, PCA gives the following variance explained by each component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*-CjdLU-_4xVuOffY9_h-kg.png" /><figcaption>MarketSim — PCA Table generated by AI-written Code</figcaption></figure><p>Here’s one approach: As per the table, the first two components together explain 74.5% of the total variance. The first three explain 89.6%. If we reduce the number of features from five to three — discarding PC4 and PC5 — only about 10% of the information in the dataset is lost, while the dimensionality is reduced by 40%.</p><p>Then, we move on to understand what each component represents:</p><p><strong>PC1 </strong>loads strongly on 20-day return and return autocorrelation — it primarily captures directional trend strength. High PC1 scores correspond to strongly trending days; low PC1 scores mark days that are flat or beginning to turn.</p><p><strong>PC2 </strong>captures the volatility regime. High PC2 scores correspond to high-volatility, wide-ranging days; low scores to calm, narrow-range conditions.</p><p><strong>PC3 </strong>captures volume trend — participation. High PC3 scores suggest above-average volume accompanying price moves; low scores suggest low-conviction activity.</p><p>This kind of interpretation requires domain knowledge that maps the components back to market intuitions. But this mapping is often clean, which provides confidence that the dimensionality reduction has preserved genuine structure rather than discarding it.</p><h3>K-means clustering: grouping regimes</h3><p>With 750 days of MarketSim data represented in the reduced three-component space, the next step is clustering — grouping days with similar component profiles into regimes.</p><p>K-means is the most widely used clustering algorithm and is a natural starting point for regime detection. It works iteratively: it assigns every data point to the nearest cluster centre, recalculates the cluster centres as the mean of all assigned points, and repeats this process till the assignments stabilise (or “converge”, as practitioners like to call it).</p><p>K must be chosen in advance, and there’s no definitive rule for what it should be. Unlike supervised learning — where labels dictate the number of classes — K-means requires the analyst to decide how many groups to look for, and that choice shapes the outcome.</p><p>One standard approach to selecting K is the elbow method: plotting the total inter-cluster variance as a function of K and looking for the point at which adding more clusters produces diminishing returns. Applied to MarketSim:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*eG4vzp8f04vePobNFTiX4A.png" /><figcaption>Selecting K for MarketSim — Table generated by AI-written Code</figcaption></figure><p>The largest marginal reduction occurs between K=2 and K=3. The improvement between K=3 and K=4 is meaningful, but smaller. Beyond K=4, the gains are minimal. This specific pattern — an elbow at K=3 or K=4 — suggests that three or four regimes capture the dominant structure in MarketSim’s data.</p><p>Selecting K=3 and applying K-means produces the following cluster profiles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*pTYoDczhZ9aAsdUlxN4YsA.png" /><figcaption>MarketSim — Regime Profile Table generated by AI-written Code</figcaption></figure><p>Three distinct regimes show up clearly, and this is how we can interpret them: Regime A captures sustained upward-trending conditions with low volatility and positive autocorrelation — momentum strategies may perform well here. Regime B captures high-volatility, mean-reverting conditions — momentum strategies may struggle here, while mean-reverting approaches may find good opportunities. Regime C captures low-conviction, sideways movement that constitutes the majority of trading days.</p><p>These interpretations are not imposed on the data. They emerge from the cluster profiles and are then interpreted through a trading lens. This distinction matters — the model finds the structure, the trader interprets it.</p><h3>From regimes to strategy adaptation</h3><p>Identifying regimes is not useful unless it changes trading behaviour. A direct application is strategy switching: maintaining specific parameter sets — or entirely separate strategies — for different regimes, and selecting an active approach based on the current regime classification. A momentum strategy runs during Regime A. A mean-reversion strategy runs during Regime B. Exposure is reduced during Regime C, where the edge is weak.</p><p>Another subtle application could be position sizing by regime: running a single strategy across all regimes, but scaling position sizes based on historical performance in each regime. Large positions in regimes where the strategy historically performed well, smaller or flat exposures in regimes where it has not.</p><p>The common requirement for both approaches is that the regime must be identified from current data, using information that was available at the time of trading. The clustering model is trained on historical data, but regime classification for today’s trading decision comes from today’s feature values — fed into the trained model to produce a regime label.</p><p>An important caveat: regimes identified historically may no longer exist. Market structure is dynamic and transforms over time. This does not invalidate the approach, but it indicates that regime models, like all ML models in financial applications, require periodic training and re-validation. This process should ideally be automated and monitored via MLOps.</p><h3>PCA and K-means together: a practical pipeline</h3><p>The combination of PCA and K-means provides a natural pipeline for regime detection:</p><ol><li>Engineer features from raw market data — returns, volatility, volume, cross-asset signals.</li><li>Standardise features to a common scale.</li><li>Apply PCA to reduce dimensionality, retaining components that explain the majority of variance.</li><li>Apply K-means to the reduced representation, selecting K using the elbow method.</li><li>Interpret the resulting clusters through domain knowledge and a trading perspective.</li><li>Deploy the trained pipeline to classify current market conditions in real time (MLOps).</li></ol><p>Each step requires specific decisions: what features to include, how many components to retain, what value of K to use, how to interpret resulting clusters, and what would be the minimum viable infrastructure that would serve results in real time. A regime that cannot be associated with a coherent market interpretation is a statistical artifact rather than a structural discovery.</p><h3>What comes next</h3><p>Part 8 returns to supervised learning with a focus on time-series forecasting — the challenges involved with predicting sequential data where the order of observations matters, and standard ML assumptions cease to hold. Gradient boosting methods, specifically XGBoost and LightGBM, are the workhorses of applied ML in finance, and Part 8 will examine why they outperform simpler models in time-series contexts and how to apply them correctly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b46cff64e78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLOps, Explained From First Principles]]></title>
            <link>https://medium.com/@ekartik82/mlops-explained-from-first-principles-ed3a04303bde?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed3a04303bde</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 17:47:13 GMT</pubDate>
            <atom:updated>2026-07-06T17:47:13.851Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>A conceptual introduction to operating machine learning systems — without tying it to any particular platform.</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AuS3odnvRsq5rHT8Up9rAQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Compagnons</a> on <a href="https://unsplash.com/photos/black-and-gray-metal-pipe-4CNNH2KEjhc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>The gap between a Model that works and a Model that ships</h3><p>Most machine learning projects that fail are not because of bad models. They fail because the business never sees a return on them.</p><p>Industry surveys over the years have indicated that a large number of machine learning projects never reach production — and among the few that do, many are abandoned or quietly sunset within 10–12 months.</p><p>Consider a bank building a fraud detection model. A data science team spends three months on this critical problem. The final model, trained on 26 months of historical transaction data, achieves scores that beat benchmarks. On paper, the bank has a reliable and efficient fraud detection capability.</p><p>But then reality is far more complicated. The model lives in a Jupyter notebook. Predictions can be made only by loading and running the notebook manually, against the data the model was already trained on. There is no way to score real-time transactions or to serve predictions to the bank’s live payment infrastructure. There’s no way to know, maybe six months from now, whether the model still beats benchmarks or silently degrades by 30% because fraudsters have adopted new patterns.</p><p>A notebook-ready model is not a production-grade fraud detection system, and the distance between them cannot be closed through another modelling effort — but through operational maturity that organisations have to invest in.</p><p>The costs of not closing this gap are substantial. Every day the model is not deployed as a service is a day fraudulent transactions go undetected — resulting in financial losses that accumulate quickly. Every month the model runs in production without monitoring is a month it may be silently drifting, either failing to catch new fraud patterns, or blocking legitimate transactions and eroding trust.</p><p>This is not a bank problem. It is a machine learning problem, and structurally, it looks the same across domains — credit risk, insurance pricing, medical diagnosis, systematic trading, and recommendation systems. The reason is consistent: the model was fine; the organisation could not operationalise it.</p><p>This is the gap MLOps aims to address. Not as a technical discipline in isolation, but as an operational layer that allows a business to convert its investment in machine learning into reliable, measurable outcomes. This article is a conceptual introduction to that layer — why it matters, and where a practical implementation should start.</p><h3>Why “DevOps for ML” undersells the problem</h3><p>MLOps is often described as “DevOps for machine learning”. Sounds convenient — but the phrasing itself undersells the problem in a way that leads to inconsistent implementations.</p><p>DevOps solves a specific problem: how to reliably ship software into production, keep it running, and update it quickly. This works because software is deterministic. Given the same input, a piece of code will produce the same output today, tomorrow, and next year. A unit test that passes today will keep passing until the code changes. If code breaks in production, the cause is likely in something that was deployed recently. This determinism makes CI/CD, infrastructure as code, and automated testing possible in the first place.</p><p>Machine learning breaks this assumption. A machine learning system in production is not only code — it is code, data, and a trained model — three components that move independently. The code might not change for months, and the model might not be retrained for weeks. But the data flowing through the system changes constantly, and with it, the model’s behavior. A fraud detection system that performed at 92% precision during deployment can drift to 70% six months later without a single line of code being modified. The world moved, but the model did not. This is the defining challenge that separates MLOps from conventional DevOps practices. It is the operational reality that DevOps was not built to handle.</p><p>Data pipelines can silently corrupt without alerting anyone. Feature definitions can change upstream and break assumptions no test was written to catch. Model performance can degrade in ways that slip past every monitoring dashboard. A successful deployment can still generate bad results for causes that lie beyond the scope of pipeline checks.</p><p>MLOps inherits everything from DevOps — CI/CD pipelines, version control, infrastructure as code, monitoring, and deployment automation. All of that is necessary. But MLOps adds a second layer of discipline — one that DevOps never had to worry about: data versioning, model versioning, drift detection, feedback loops, retraining pipelines, and the governance of learned behavior. This second layer is not optional — it is the reason MLOps exists as a distinct operational requirement in the first place.</p><h3><strong>The MLOps lifecycle</strong></h3><p>To run a machine learning system, it helps to understand the full shape of what’s being operated. Most teams start with the assumption that the ML lifecycle is linear — data goes in one end, a model comes out the other, and deployment happens at the far right. This assumption is incomplete — the lifecycle is not a line; it is a loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MENQjSCErbEmNh3i9Am2gA.png" /><figcaption>Image generated by AI</figcaption></figure><p><strong>Data ingestion </strong>brings raw inputs into the system — transactions, customer interactions, sensor readings, whatever the business domain provides.</p><p><strong>Data validation </strong>checks that this incoming data conforms to expected schemas, distributions, and quality thresholds.</p><p><strong>Feature engineering </strong>transforms the raw data into inputs a model can learn from — aggregations, encodings, and derived signals.</p><p><strong>Model training </strong>consumes these features to produce a candidate model.</p><p><strong>Evaluation </strong>measures that candidate against held-out data and the current production model.</p><p><strong>Deployment </strong>promotes the winning model into the serving environment, where it begins making predictions on live data. Systems like fraud detectors and recommenders often deploy a newly trained model sequentially — first routing a small slice of user traffic to it, evaluating its behavior, and only then replacing the previous model.</p><p><strong>Monitoring </strong>tracks those predictions and the data flowing into them, watching for degradation.</p><p><strong>Feedback </strong>captures prediction outcomes — was the flagged transaction actually fraudulent? Did the recommended product get purchased? — and feeds those outcomes back to the beginning of the loop, informing the next round of training.</p><p>These stages are not optional. Skipping a stage introduces a specific class of failure. For example, skip monitoring, and drift goes undetected until a business consequence forces an investigation. Skip the feedback loop entirely, and the system stops adapting to a world that hasn’t stopped changing.</p><p>The loop is important. A traditional software system is deployed once and then maintained: the code that shipped during the last deployment is the one running today. A machine learning system, by contrast, must be continuously re-derived from data, because that is the fundamental building block for the system. If the loop breaks, the system begins to decay — not immediately, and not visibly. The first sign of trouble is a business consequence.</p><p>Each stage of the loop also produces artefacts: datasets, feature definitions, trained models, evaluation results, and prediction logs. Each of these has to be versioned and tracked.</p><p>MLOps is the operational machinery that keeps the loop running, the artefacts versioned, and the entire system explainable to stakeholders.</p><h3>The four pillars of MLOps</h3><p>A robust MLOps implementation rests on four operational aspects. A mature system depends on all four, yet they can be picked up one at a time — a practical advantage for organisations just getting started. The four pillars are — reproducibility, automation, monitoring, and governance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MR-HH6QB5SOGoY1HK-epow.png" /><figcaption>Image generated by AI</figcaption></figure><p><strong>Reproducibility </strong>is the foundation. It is the ability to take any past model that ran in production and recreate it exactly — same training data, same feature definitions, same code, same environment, same random seeds, same result. This can sound academic till a production model drifts badly and a team needs to debug it. Without reproducibility, the debugging can be challenging. Which version of the dataset was the model trained on? What features were engineered? Which library versions were installed? Without concrete answers to these questions, it would be mostly guesswork instead of debugging. Reproducibility is achieved by: data versioning (tracking which snapshot of data was used), experiment tracking (recording every training run with its parameters and results), and environment pinning (locking down the exact versions of every library the training run depended on). This is tedious and necessary, as it builds the foundation for all other pillars.</p><p><strong>Automation </strong>aims to reduce human involvement in specific parts of the system. Manual training runs, hand-deployed models, and hand-edited configuration files make an ML system fragile. Automation replaces each of these with a pipeline: continuous integration that validates code changes before merging, continuous training that produces new models on a schedule or on trigger, continuous deployment that promotes models to production after specific checks, and a model registry that maintains a canonical record of every model version and status. Speed is not the only goal here. Automation removes single points of failure that emerge when a critical step is performed manually and depends on a specific person to do it correctly.</p><p><strong>Monitoring </strong>is where MLOps differs significantly from DevOps. Software monitoring watches infrastructure metrics: CPU utilization, memory usage, request latency, and error rates. All of this is necessary for ML systems, but none of it can detect failure modes that matter the most in production. A model can serve predictions at minimal latency with zero errors and still be wrong. ML monitoring must therefore watch the model itself. This involves tracking input data distributions and alerting when they drift from the training distributions. Tracking live model performance against ground truth as it becomes available — for a fraud detection model, this would mean comparing predictions against confirmed fraud outcomes and watching evaluation metrics in production as they evolve. Monitoring turns a black box into a system that can be operated with knowledge rather than hope.</p><p><strong>Governance </strong>gets less attention in introductory MLOps material. It basically covers a model’s provenance, behavior, and accountability: complete lineage of which data trained which model, which model produced what prediction, and who approved which deployment. It covers explainability — the ability to answer why the model produced a specific prediction. It covers access control and audit trails. It covers documentation of known limitations and biases, and failure modes. Governance is not optional in critical systems. In financial services, regulatory compliance is mandatory. In healthcare, any model that informs diagnosis is treated as a medical device and must meet corresponding standards. A model that cannot explain itself, cannot be audited, and cannot be traced from prediction back to training data is a model that should not be deployed by a regulated business — regardless of how well it performs.</p><p>These four pillars are the operational vocabulary of MLOps.</p><h3>MLOps maturity: what ‘good’ actually looks like</h3><p>Having laid out the four pillars, it is natural to assume that a mature MLOps implementation requires all of them working perfectly from day one. This is not how an organisation gets there. A mature MLOps implementation is not built in a single day or a single quarter — it is accumulated in layers that have a natural order.</p><p>A widely referenced framing of this structure comes from Google’s MLOps maturity model, which describes three broad levels. The specific labels may vary across the industry, but the underlying stages serve as a mental model for where an organisation sits and what should come next.</p><p><strong>Level 0 — Manual process. </strong>At this level, everything is executed by hand. A data scientist trains a model in a Jupyter notebook, iteratively tunes it, exports the trained artefact, and hands it off to the engineering team for deployment. They wrap the artefact in a service, deploy it, and move on. Retraining, if planned, is a fresh project. Monitoring, when it exists, is limited to infrastructure metrics. Reproducibility would depend on whether the data scientist documented the training data versions. This is where most organisations would begin, and that is perfectly okay. What matters at this level is recognising that the system cannot be scaled beyond a handful of models.</p><p><strong>Level 1 — ML pipeline automation. </strong>At this level, the training process becomes a pipeline. Rather than a data scientist running notebooks manually, a scripted pipeline handles data preparation, feature engineering, training, evaluation, and model registration as an automated process. The pipeline can be triggered on a schedule, on arrival of new data, or on demand. A model registry becomes the single source of truth for which versions exist and which one is currently in production. Basic data validation is introduced — the pipeline blocks training on data that fails schema or distribution checks. Reproducibility becomes real at this level: any past training run can be reconstructed because the pipeline itself is versioned code, not a sequence of manual actions. Most organisations that take MLOps seriously eventually reach Level 1. It is also where the majority of production ML systems operate today.</p><p><strong>Level 2 — CI/CD pipeline automation. </strong>At this level, the pipeline itself is treated as a first-class software artefact. Any changes to the training pipeline are tested, reviewed, and deployed through the same CI/CD infrastructure that manages any production software. Continuous training is introduced — the model is automatically retrained in response to triggers, whether that is a schedule, a data drift alert, or a performance degradation signal. Continuous deployment promotes newly trained models from staging to production. Monitoring is comprehensive: infrastructure, data, predictions, and live performance are all logged, and the outputs feed back into retraining triggers. This is the level where the ML system becomes self-updating in response to the world it operates in. Reaching this level matters to organisations where model staleness has immediate business consequences — high-frequency personalisation, fraud, real-time bidding.</p><p>Progression across these levels is sequential. Most of the actual value of MLOps is captured in moving from Level 0 to Level 1. This transition is where a system stops being a fragile artefact maintained by one person and becomes a repeatable process sustained by a team. Moving from Level 1 to Level 2 delivers additional value, but also introduces additional complexity. It may not be the right investment for every organisation or every model.</p><p>For a team just starting, the practical implication is simple: assess the current level honestly. If most model deployment is still manual, the first milestone is to automate a single training pipeline end-to-end, including model registration and basic data validation. Everything else follows from that foundation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*sSUExwqtIlcctRCd0b6rSg.png" /><figcaption>The Layers of MLOPs</figcaption></figure><h3><strong>Where to start: The practical first move</strong></h3><p>For teams new to MLOps, the instinct is often to focus immediately on platforms and tools — but that’s rarely the right first step. The problem is that adopting a platform before defining the workflow it’s meant to support often leads to a system where the tooling is sophisticated, but the operational practices are not.</p><p>The first move is smaller, affordable, and more durable. Pick one pillar and instrument it.</p><p>Reproducibility is the right starting point because everything else depends on it. Automation cannot exist without reproducible pipelines. Monitoring cannot exist without reproducible baselines. Governance cannot exist without traceable lineage. A team that establishes reproducibility as the foundation eventually finds that automation becomes easy, because the work required to automate a process is already done when making it reproducible. The concrete first steps at this level are well-defined. Set up experiment tracking — MLflow, Weights &amp; Biases, or a comparable tool — so that every training run is recorded with its parameters, code version, dataset reference, and results. The code and training data can be versioned together, so that any past model can be reconnected to the exact inputs that produced it. Trained models can be stored in a registry with metadata that links them back to the training run that created them. None of this requires a specific platform. Open-source tooling and operational discipline are enough to get started.</p><p>Once reproducibility is tangible, the subsequent steps become clearer. Automation should be the next natural goal, because a reproducible process can be scripted, and a scripted process is one that can be automated. Monitoring follows automation — a stable pipeline will produce baselines against which drift and degradation can be detected. Governance emerges from all three.</p><p>This is a suggested sequence: reproducibility, then automation, monitoring, and governance. The effort required to build each one is most easily learned in this order.</p><p>MLOps is not a tool, nor a phase in a project. It is the basic understanding that a machine learning model in production is a system — with data flowing in, predictions flowing out, behavior that changes over time, and consequences that accumulate whether they are measured or not. Systems have to be operated properly.</p><p>Future articles in this series will examine more concepts in greater depth: how to practically implement each pillar, what tools work in production, and what operational reality looks like inside teams that have crossed from Level 0 to Level 1 and beyond.</p><p>For now, the practical first move is the one that every team can make this week. Pick reproducibility. Start tracking, versioning, and registering. Everything else follows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed3a04303bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overfitting and the Multiple Testing Problem]]></title>
            <link>https://medium.com/@ekartik82/overfitting-and-the-multiple-testing-problem-aca59576304f?source=rss-d4407a413567------2</link>
            <guid isPermaLink="false">https://medium.com/p/aca59576304f</guid>
            <category><![CDATA[systematic-trading]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[E Kartik]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 14:35:38 GMT</pubDate>
            <atom:updated>2026-07-04T14:35:38.802Z</atom:updated>
            <content:encoded><![CDATA[<p>Part 6 of the series: Machine Learning for Systematic Traders</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xvu70b93ZHg9QAp_DgX7g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@add_rien_20?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Adrien</a> on <a href="https://unsplash.com/photos/a-long-exposure-of-colored-lights-in-the-dark-obMUS2F3MzM?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Disclaimer: This article is for educational purposes only and does not constitute financial advice. Nothing in this article should be construed as a recommendation to buy, sell, or hold any financial instrument. Trading involves significant risk. Always consult a qualified financial advisor before making investment decisions</em></p><p>There is a specific type of challenge that systematic traders are familiar with. It arrives not during training, but after deployment.</p><p>The backtest was promising. The out-of-sample tests were encouraging. The logic was sound. And yet, in live trading, the strategy bleeds. Not even dramatically — but slowly and steadily. This happens in a way that suggests the edge wasn’t really there. There’s no option but to retire the strategy and start another research cycle.</p><p>This pattern repeats more often than any trader likes to admit, and it happens across experience levels, across asset classes, and across model types. The cause, in the majority of cases, is some form of overfitting. But this isn’t the obvious type of overfitting — this is the one that may survive multiple rounds of validation and is quite subtle to identify.</p><p>This article is about understanding overfitting in such a way that it may be identified earlier — and building habits that make accurate model evaluation the default rather than the exception.</p><h3>What overfitting actually is</h3><p>Overfitting is what happens when a model learns the training data too well. Every dataset contains two types of information: signals and noise. Signals are the stable, persistent patterns that will continue to exist in new data — the relationship between momentum and returns, for example. Noise is pretty much everything else — random fluctuations, one-off events, the coincidental correlations that existed in the historical sample but do not carry any information about the future.</p><p>A well-fitted model learns signals and ignores noise. An overfit model, on the other hand, learns both — it memorizes noise as if it were a signal, and its performance on the training data reflects that memorization rather than predictive ability. When it encounters new data, the memorized noise is gone, replaced by a different one, and the model’s performance deteriorates accordingly.</p><p>The challenge is that overfitting is invisible when working with the training dataset. A model that has memorized its training data will appear to perform well on that data. The deterioration becomes evident on new, unseen data — which in live trading means real capital is at stake before the problem reveals itself.</p><p>This is why the train/validation/test framework introduced in Part 2 is the minimum viable defence against overfitting. But this is also not sufficient on its own — and understanding why requires a deeper analysis of specific ways overfitting tends to manifest in financial data.</p><h3>Challenges with Financial Data</h3><p>Machine learning has been successfully applied to image recognition, language translation, medical diagnosis, and dozens of other domains. In most of these, overfitting is a manageable problem — detectable with standard techniques, and correctable with more data, better regularisation, or simpler models.</p><p>Financial markets are different in three important ways that make overfitting harder to detect.</p><p><strong>The signal-to-noise ratio is low. </strong>In image recognition, a model trying to identify cats has a strong, stable signal to work with — the features that define a cat are consistent across millions of images. In financial data, the predictive signal in any feature is weak, and often transient. A momentum signal that explains 4% of return variance can be meaningful in this context. Most features would explain less. A model with enough complexity will find ways to explain variance in the training data simply by memorizing coincidences.</p><p><strong>Financial data is non-stationary. </strong>The statistical properties of market data change over time. The relationship between volume profile and future returns in a bull market will differ from that in a bear market. A model trained on one type of regime may learn patterns that were real, but no longer exist. This makes the historical record a less reliable guide than it appears — and makes out-of-sample testing on a single period insufficient, because that period may not represent the range of conditions the strategy will face after deployment.</p><p><strong>The sample size is limited. </strong>A daily trading strategy with five years of history has approximately 1250 data points. A weekly strategy may have 260. These are small samples by machine learning standards — in most domains, models are trained on millions of examples. With 1250 samples and a modest model, the risk of memorizing noise is high. Adding features and model complexity tend to magnify this risk, while the underlying signal rarely grows to match.</p><h3>The multiple testing problem</h3><p>Out of all the ways overfitting occurs in systematic trading research, the multiple testing problem is the least discussed.</p><p>Here’s how it works — A researcher may test 50 different variations of a strategy. These variations would incorporate different combinations, lookback windows, entry and exit thresholds, and model types. Let’s say, by chance alone, approximately 10 of those variations may show statistically significant backtest performance at a significance level of 5%, even if none of them have a genuine edge. The researcher may then select the best-performing variation and move forward with it, unaware that the apparent significance is a statistical side-effect of testing several hypotheses on the same data.</p><p>This is not necessarily a problem. It is how research naturally proceeds — try things, see what works, refine what looks promising. However, the reality is that each additional test conducted on the same historical data increases the probability of finding something that may look good by chance. By the time a strategy has gone through twenty iterations of refinement and improvement, the backtest may reflect twenty rounds of implicit selection bias rather than twenty rounds of validation.</p><p>The correction for multiple testing is well established in Statistics — adjusting significance thresholds to account for the number of hypotheses tested. But this is rarely applied to trading research. Practically speaking, the implication is simpler than mathematics: every time a strategy is modified in response to backtest results, the backtest becomes less informative as an estimate of future performance.</p><p>A useful tip: before beginning a research process, write down the hypotheses being tested and the specific conditions under which the strategy will be considered validated. That kind of framework is important before seeing results. Strategies that emerge from such frameworks are more likely to have a genuine edge, rather than the ones that come from open-ended exploration of what worked historically.</p><h3>Practical rules for model evaluation</h3><p>In a domain as noisy as financial markets, overfitting cannot be completely eliminated. The following principles, however, can assist in detecting overfitting before live capital is at stake:</p><p><strong>Never touch the test set till the model is final. </strong>The test set exists to provide one unbiased estimate of out-of-sample performance. Resist the temptation to use it multiple times to either diagnose problems or improve the model. If the test set has been examined more than once, then it has been compromised. Set aside a new one before deployment.</p><p><strong>Use walk-forward validation, not a single split. </strong>A single train/test split can produce one performance estimate that could be specific to a single market regime. Walk-forward validation produces a distribution of estimates across multiple periods. A strategy that performs well across a set of diverse historical conditions should be preferred over one that performs exceptionally well in a single regime.</p><p><strong>Prefer simpler models for financial data. </strong>For datasets with a high signal-to-noise ratio, complex models may outperform simple ones simply because they have the capacity to learn patterns better than simpler models. For financial data, it works the other way round. Due to a low signal-to-noise ratio, complex models have a tendency to use their excess capacity to memorize noise. A ten-feature linear model may prove to be more valuable than a fifty-feature gradient boosting model that performs brilliantly in-sample.</p><p><strong>Require economic rationale before including any feature. </strong>If a feature shows good backtest performance but has no plausible economic explanation, it most probably is capturing noise. The absence of economic rationale may not suggest that the feature is useless — but it should raise the bar for inclusion significantly. Features that have statistical significance and economic rationale are likely to represent persistent edges.</p><p><strong>Be cautious of short backtests with a high Sharpe Ratio. </strong>A strategy that shows a Sharpe Ratio of 3.0 over two years of daily data has approximately 500 observations. That may not be enough data to distinguish edge from luck with any meaningful statistical confidence. Longer backtests, covering diverse market regimes, and modestly claimed performance are signs of a credible strategy.</p><p><strong>The meta-lesson</strong></p><p>Overfitting in systematic trading research is psychological, and not entirely technical.</p><p>Research is usually motivated by the desire to find something that works. An iteration that seems to improve backtests feels like progress. Every refinement that smooths out the equity curve feels like an improvement. The feedback loop between effort and visible results is encouraging — even if the results are fictional.</p><p>The discipline required to conduct honest research workflows runs against this natural motivation. It requires a backtest to be interrogated rather than a result to be celebrated. It may also require discarding a framework built over months when the validations reveal that the edge was not real. This is difficult. The backtest is not the strategy — it is evidence about the strategy. And this evidence should be treated with the same skepticism that is applied to any other noisy signal in a high-noise domain.</p><p>The practitioners who do it consistently are not more skilled than the ones who do not — they have simply understood the cost of deploying a strategy with spurious edge is far higher than the cost of discarding one with a real edge that the validation process could not confirm.</p><h3>What comes next</h3><p>Part 7 shifts from supervised learning to a different class of techniques: unsupervised learning for market regime detection. The goal is not to predict returns but to identify the conditions the market is currently in.</p><p><em>Follow this series to get each new article as it publishes. If you are a systematic trader building your own edge in your market, share this with someone who would find it useful.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aca59576304f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>