Last Updated on 13 July, 2021 by Samuelsson
Curve fitting is when a strategy or edge is not fit to market behavior, but market noise, leading to failure in live trading.
1. Curve fitting, overoptimization and over fitting all refer to the same concept that is explained in this article.
2. Readers of this article are expected to know what an edge is. If you don’t, we recommend that you read our article on edges.
The danger of Curve fitting is ubiquitous when designing trading strategies. It has the potential to ruin our trading careers if not dealt with correctly, and can be hard to notice, even for traders with decades of experience. In this article we will learn what curve fitting is, and why you should try to avoid it.
Part I: What is curve fitting?
Backtesting in Search of Edges
When we perform backtests, we analyze data in search of recurrent patterns that have predictive potential. In other words, we want to know if the tested pattern can tell us when the market is prone to going up or down, so that we can be in the market only when it is favorable to us. If we succeed to find patterns that we think mirror market behavior, we have an edge.
Since our trading business is, or at least should be entirely reliant on edges, their quality and robustness dictate how well we cope with carving out profits in the market. Therefore, it is critical that our edges continue to work well also into the future, if we want to make any money.
A Thought Experiment
Insinuate that your observation of what you presume is an edge, is flawed and holds no merit. Insinuate that you cannot know if your edge will continue to deliver going forward, and that an overwhelming majority of patterns you call edges, will not work at all.
Quite scary, is it not, when you are about to risk your own money on those very edges?
Well, this is not a thought experiment. It is reality.
The Harsh Truth About Observations of Market Behavior
When we search for edges in the markets, most of what we assume is an edge, will be outright garbage! True edges are hard to find, and in your search, you will sometimes be completely certain that you have an edge ready to trade, only to see it fall apart completely once exposed to new market data. This is one of the aspects that makes trading so hard for beginners to succeed in, and that needs to be overcome before risking real money!
Asking a Question
Now that we know about the tendencies of the the markets to deceive us into believing in false edges , it is time for us to ask a question to understand why this is, and what is has to do with curve fitting.
The question reads as follows:
Since of all patterns we observe, only a few are true edges, how come that some of the observations we make are edges and others are not?
Or the same question veiled in other words:
How come that some observations are true edges and others are curve fit?
To answer this, let us begin by learning a few lessons:
Lesson 1: Markets Are Mostly Random
The first thing every trader needs to grasp to be able to understand the concept of curve fitting, is that a majority of market action is random noise. Most market activity simply cannot be derived from any form of analysis and needs to be accepted as nothing else than random market noise.
Lesson 2: Most People Want Explanations, Even to The Inexplicable
We as humans have an urge to explain everything we see and experience. By doing so we bring order to a chaotic world, at the cost of quite often lying to ourselves. This tendency among humans can often be observed when financial news media covers recent market activity. The expert may ascribe soaring markets to some recent event, which seems perfectly reasonable. However, once the market turns around, so do often the experts by explaining the downturn with the very same arguments.
In such cases, it is apparent that humans like to fit explanations to reality and not the other way around since both of our expert´s comments cannot be true at the same time.
The severe fallback of this inclination of the human mind is that reality is not very inclined to conform to our description of it. Curve fit edges will not hold, regardless of what reason we ascribe to its logic.
Lesson 3: Correlation Does Not Equal Causality. Market Behavior and Market Data Are Not The Same.
The third and last lesson we must learn before we can grasp the concept of curve fitting is that market data and market behavior are not the same. Market behavior is non-random price action that holds predictive value, while market data consists of market behavior AND market noise combined. The consequence of this is that what seems to work in in the backtest carried out on market data, cannot be taken for true market behavior before put under scrutiny. It may very well be a result of randomness, thus holding no value going forward.
So, What Is Curve Fitting?
Curve fitting is when random market noise forms haphazard patterns in price data, that is later viewed and considered an edge, despite being a product of sheer randomness.
To elaborate, when curve fitting, we don´t fit our models to market behavior. We fit them to market data. That is a huge difference, since market data consists not only of market behavior but also of random market noise. For that model to be profitable going forward, the random patterns observed in historical data must repeat themselves. However, the one main trait of random patterns is that they do not hold any predictive value, since they are random.
Therefore, curve fit models nearly always fall apart in live trading.
An Illustration of the Concept of Curve Fitting
For it all to become a little clearer, let us illustrate the concept of curve fitting with an example:
Alan is building a house in the outskirts of the desert to investigate local wildlife. Since his arrival, it has not rained once, so he finds it unnecessary to build a roof that can handle large rain masses. After all, this is desert, and who would expect rain to be abundant?
What he does not know, is that the period since his arrival has been the driest period for over 100 years. Quite soon after finishing his construction, he understands that his observation of the weather and the following conclusion that rain does not fall here was flawed. It was based on some random weather phenomenon that was not representative of normal weather behavior in the area. Soon, his house is flooded by the rain masses. His construction was curve fit to his observation of a random drought period.
Going back to trading
If we were to translate this story to fit with trading and curve fitting, we would get the following translations
Drought period = Market noise
Alan´s observation of the drought period = Our presumed edge in the market
The immediate failure of the construction = The failure of a curve fit edge
Alan curve fit his construction to a type of weather that was not typical of that region, despite believing it was. In the same way, traders curve fit their models to market data instead of market behavior.
“…After all, this is desert, and who would expect rain to be abundant?…”
Most likely he had found supporting arguments for the very opposite claim if that was what he chose to believe in. It is always important to remain vigilant as soon as one´s mind wanders away attempting to explain observed pattern. Those explanations may very well be flawed in themselves and should not be taken as evidence enough to trade any edge! As we know, we are inclined towards explaining even the inexplicable; or in other words; lying to ourselves. If such a lie would persuade us to trade curve fit edges, that could end less well.
Of course, many edges can be explained, which in such cases adds to their credibly. However, such explanations should only be taken into consideration after extensive robustness testing.
Curve Fitting of Robust Edges
Many times when designing strategies you will find yourself in the grey zone. You might consider adding one more filter to improve the results only a little, or choose a parameter value that has performed considerably better than the surrounding ones. For example, if your edge consists of a moving average, you might choose 14 for the average length, because 13 and 15 have performed much worse.
Maybe the differences are as significant as in the pictures below.
Given that your edge is robust, this type of optimization will most often lead to your edge being partly curve fit. This means that while it will most likely continue to perform going forward, it will do so with much poorer results than in the backtest. This could be devastating once you are about to determine your capitalization, meaning how much money is needed to trade. You could easily risk too much and face drawdowns that wipe you out completely!
You can read more about capitalization and why it is so important here. COMING SOON
Part II: What Can Be Done?
Until now we have only covered what curve fitting is, and why it is a pitfall that needs to be avoided. In this part of the article, we will briefly touch upon different methods that could be employed to validate an edge and discern true edges from curve fit ones. These methods are often referred to as “robustness testing” since what we do is to validate the robustness of our edges.
With most things in trading, there are no universal truths that apply under all circumstances. The same applies to what methods to use to mitigate curve fitting. Each trader will, as his experience grows, find his own way of applying some of the methods available. Therefore, in this section of the article, only the most common methods to avoid curve fitting will be touched upon.
We will cover the following topics, in the order presented below:
- Less is more
- Parameter Stability
- In sample and out of sample testing
- Walk forward testing
- Monte Carlo simulation
Each topic is only presented briefly. Feel free to deep dive into our articles on every method! They are all linked below!
Let us begin!
1. Less is more
In trading, you should always strive to make your edge as simple as possible. Overcomplicated edges with numerous conditions and rules tend to be curve fit.
Read more about Less is more here.
Parameter stability is a good indication of whether a strategy is curve fit or not. In general, we want as many parameter combinations to produce desirable results as possible.
Read more about parameter stability and how to measure it here. COMING SOON
3.In sample and out of sample testing
To avoid curve fitting, out of sample and in sample testing is a crucial part of every trader’s methodology, in one way or another.
By dividing our data into a training set and a validation set, we can test our idea on the training set, and later verify it on the validation set.
Read more about in sample and out of sample testing here.
To put it outright, incubation is out of sample testing, but with one major difference:
With typical out of sample testing, all data is historical. With incubation, we use future data that is not available yet.
It is easier than it seems! Read our article on incubation, and you will soon get a grasp of it! It is one of the best methods available for those wanting to discover curve fitting before it is too late!
Read more about Incubation here!
5.Walk forward testing
Walk forward testing is a concept that takes out of sample testing to the next new level. As all other methods discussed in this article, it is a great method of determining the robustness of a strategy and preventing curve fitting.
Read more about Walk forward testing here! COMING SOON!
Monte Carlo simulation
Monte Carlo simulation is a method that can be helpful in some cases. It works by reshuffling the order of the trades in a backtest and has the potential to expose weaknesses that otherwise had been hidden in the backtest.
Read more about Monte Carlo simulation here. COMING SOON!
Curve fitting is when our models are fit to random market noise and not true market behavior, leading to immediate failure upon live trading. However, edges could also be partially curve fit, resulting in massively degraded performance in live trading.
All in all, curve fitting is a major concern that every trader, beginner and experienced, actively needs to battle to be able to trade profitably. The difference between profitable and failing trader is not that some do not curve fit. It is that some have found methods like those presented in this article that they actively use to decide which edges are worth trading and not.
Here you can read more about algotrading in our archives.