Backtesting, Part 1 (2024 remix)

A good day as any to revisit Part 1 of our Backtesting project, with parts of the audio remixed for 2024.

Backtesting, Part 1 - First steps (2024 remix) - Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one's financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

tHE MATH BEHIND “Inevitably profitable”

The small message, seen on the right, a mathematical reality greets traders on our cover page. There’s more to this statement than it may first seem, so let’s spend a minute exploring these concepts.

  1. When we say we are traders, we don’t mean we are traders because we look to get lucky. Although we will get lucky and we will get unlucky at times as we go about the job, our success should not depend on luck. In fact, by doing the math below, we will work to minimize the role of luck.

  2. So let’s start by flipping a fair coin. If you’ve ever done this, you know, it can easily happen that we’ll have 4, 5, even 6 heads or tails in a row, if we just flip that coin long enough! This goes totally against our intuition, but that’s how the world works. “Runs” are a natural part of an otherwise random process. Now: what if you step into the room, and you see me flipping a coin, you might see 4, 5, even 6 tails in a row. Would you think “probably both sides of that coin are tails”? No, you wouldn’t, it’s still just a coin, and the outcome of heads and tails is random. And although we’ll run into “runs”, it will make no sense at all to play a game based on a random process, since that game, in the long run, cannot be won.

    Sadly, many traders get trapped here and they never get passed the euphoria of “entering the room, seeing a run”, getting excited and starting to trade a process which they never investigated, which may be random, in which case it will, over time, grind any account to zero.

  3. Let’s move on! What happens if we introduce a new rule, while we flip that coin: we’ll still be flipping a coin, a 50-50% random process, offering no advantage in itself whatsoever, but what if we say “if it’s heads, I’ll pay you a dollar. If it’s tails, you pay me 1.20.” I would play that game, but would you? You wouldn’t, because we all understand that the math is stacked against you: you can only lose your money if you do this. Also notice that we have now introduced a second factor, besides accuracy: the win/loss ratio. Now it’s easy to see: even a trading system with 50% accuracy can be profitable if the win/loss ratio is in our favour. Our account will, over the long run, will grow, because it cannot not to. (Also note that each run produced by the process will be different. And although different, they can be studied with statistical methods.)

    Click below to first simulate a coin flipping game with a 1:1 payout, which is a process that is mathematically unable to generate any rewards (a trading account that follows a process like this is bound to go to zero, due to friction/expenses). And now the important part: this random process is perfectly capable of producing a “trend”, but this “trend” has no profitable process behind it, it is 100% the result of luck aka randomness. That is not how we want to trade, it’s exactly the role of luck that we work hard to minimize!

 

Let’s continue: what if we change the win/loss ratio to something other than 1:1? Say 1.2 to 1. Enter your values in the yellow cells below, and see the results for yourself:

 

See, even though the process is still random (accuracy = 50%), due to the uneven payout, somebody will be making money, whether they want it or not, it’s a mathematical necessity! Keep refreshing the page to generate a new run: the curve is bound to be going up (but note: not in a straight line, remember the “runs” aka “streaks”).

4. Now what if we actually have an advantage in the accuracy as well as in the payout? Say the accuracy is 55% (e.g. the coin is somehow not fair), and the payout is, say 1.2:1. Run a few scenarios in the table below to see that the result of a process like this is inevitably bound to go up! It’s just math.

 

In summary, the interplay between the accuracy (how many percent of our trades are winners/losers) and the payout (win/loss) ratio can be summed up with this well-known equation, the equation of the edge:

 

where P is probability, W is wins, W̅ is average win, L is loss, L̅ is average loss

 

The above thought experiment takes care of the “with an edge” part in the quote at the top of this post.

So now we only have to consider why “a properly sized account” is required to be inevitably profitable. A question that takes us back to the fact that any data series, even a random data series will produce “runs” aka “streaks”, both winning and losing.

How long those streaks can be is a crucial area of research and will be the topic of an upcoming post. In the meantime, there’s nothing stopping you from visiting this page.

You may also be wondering: in our day and age, is it possible to devise a computer algorithm that is capable of capturing an edge on financial markets reliably and by constantly adapting to the ever-changing environment? These algorithms out there surely exist, although it’s unlikely we, mere mortals, will ever have the chance to put most of them to good use. Which made us think: perhaps we should build our own.

Questions, comments? Share your thoughts below!