The Journey of a Quantitative Trading Strategy Development (Part 1)

A no-code overview

Diego Pesco Alcalde
7 min readJun 4, 2023
Source: Freepik.com

This is the part one of a series of articles on quantitative trading. My goal is to present the steps of a quant strategy development as simple as possible, in a way that any trader or investor can follow. Instead of drowning into codes we will discuss concepts and results. The scripts and frameworks developed to this series are on my Github.

In this article, I will discuss the motivation for quant trading, and the groundwork to get a quant trading project started. In the following articles I write about hidden costs, key metrics, backtesting, forward testing, overfitting and much more. Here are the links:

Disclaimer: This article was developed for informational purposes only, it is not a trading recommendation.

Disclaimer 2: All charts presented in this article were developed by myself.

Why Quant

Predicting the future is a quite challenging task. Animals in their evolving process learned how to correlate specific information in the present with future happenings, as this can be the difference between life and death in some cases. Birds can detect future shortage of resources in a specific region and change to another, where they predict those resources will increase. Other species can somehow predict natural disasters, such as earthquakes and tsunamis, and leave endangered areas to save themselves. We humans were able to go a step further, and register our learnings, reproducing them over and over, what to me is the basic principle of science. In fact, some natural events are quite reproducible, such as physics laws and chemical reactions. However, predicting behaviors is far more difficult than predicting natural phenomena, especially collective behaviors. When an outcome is the response of a collective behavior, there are no governing principles on that, so things change frequently and unexpectedly. Markets are moved by its participants, so predicting price movements is actually predicting the actions of many market agents, what is indeed a risky activity. To me quant trading is acknowledging our limitations in predicting collective behavior, especially when we are biased with ego or fear, and letting statistics do the job. If that’s not enough, there are other advantages to it, such as benefiting from the speed of computers, processing different types of data, and so on. Quant trading is not a risk-proof methodology, as history shows us, but to me it is a more structured, intelligent and reliable way to stack the odds on your favour.

Why Cryptocurrencies

I actually believe crypto has the potential to bring a solution to many problems of our current financial system, but that is not why I chose them for this series. Cryptocurrencies are traded 24/7, in a digital environment where data is openly shared with participants, which will allow us to develop and analyze our strategies in a simple way. Also, crypto is a market in a mid maturity stage, showing a high volatility and a very good liquidity, what makes it a playground for traders. But it’s important to understand that quant trading is applicable and used today in any asset category, such as bonds, stocks, ForEx, energy, oil and many others. Jim Simmons and his team were able to apply quant trading in a time when data was very scarce and computing power was minimal, showing that anything is possible in this field.

Before you get started

This might look obvious, but quant trading needs data. So a good project will start with structured, reliable, clean and accessible data. We have to make sure we check the sources from data, adjust formatting, deal with missing values, time zones, decimal places, and so on. After all, we will be betting money on this, and there is no chance to profit from quant trading if the data is not good. Most assets can have their data retrieved from a broker API, so it is important to make sure that the broker API that we are using is returning what we think it is returning, since a price column can point towards many different things.

A Hypothesis

As in any science, quant trading starts with a hypothesis. Usually hypothesis come from observation of price fluctuations and discussions with market participants, and this step is common to both quant and discretionary traders. People are able to detect signs of correlation between a few variables and market movements, and start trading based on that perception. So let’s choose a hypothesis which we will be investigating during this series. I believe that there is a limited knowledge of market participants about cryptocurrencies today, so market is strongly moved by price trends more than fundamental data and information about cryptoassets projects. Based on this theory, I believe that a trend-following strategy can generate good returns.

What is a good return?

Trading differs from investing in the sense that agents are looking for additional profit than they would have by simply holding assets in their portfolio. That additional profit is called “excess return”, or simply “alpha”. If there is no alpha, there is no reason to invest time, energy and take additional risks in the market, and investors will eventually shift to risk-free assets that generate a similar return, so when developing a trading strategy we’re looking for excess returns compared to a market benchmark. For the sake of simplicity, in our example the market benchmark will be a long-only position on Bitcoin. Remember that Crypto markets are usually traded in pairs, meaning that you are buying one asset and selling the other. For this article let’s choose the spot market of BTC-USDT, being USDT a stablecoin that is backed by USD, following its price. So as a general rule you can read charts as the price of Bitcoin in USD. Let’s see how the price moved from January 2018 until September 2022.

To get an actual measurement of the compound returns let’s suppose the portfolio started with 100% of allocation in BTC, and check how that initial amount multiplied over the years. We will be calling this variable of Normalized Returns or simply Multiple during the series.

As we can see there was a huge volatility in that asset in the past years, and a long only position was somewhat profitable, reaching 30% of returns on September 1st, 2022. But the maximum return achieved was of 450%, which is an outstanding performance. After that a strong selling trend took over and a bearish market has established. So what if we could profit also from the price reduction events? That is what we want to target with our strategy.

Initial Analysis

I usually say that this is where quant trading actually starts. Discretionary traders also analyze data, but they don’t tend to test their ideas as rigorously as quant traders, and there is a good reason for that. Discretionary traders will enter, adjust and exit positions freely based on their analysis of many different aspects. Quant traders will enter, adjust and exit positions following rules and conditions that will be written in their algorithms. That rule has to be extensively tested, because once it’s implemented, it will be automatically followed by a computer. This initial step shouldn’t be fancy, but should make you confident enough that it’s worth to work in a backtesting framework.

Going back to our example, we want to analyze trend-following strategies, so let’s start with a Triple Moving Average strategy. Based on the hourly price data we can develop three price moving averages (short, mid and long-term) and the positions will be changing once they cross each other. When the short term average is above the mid term, and the mid term is above the long term, we will buy BTC and hold a long position. When the moving averages order is reversed, a short position should be taken, and anything else will be the sign for a neutral position. To better understand the idea, let’s take a small piece of hourly historical data and analyze the price and averages trends. In this chart below the short term average is calculated on 15 time steps, the mid term on 50 and the long term on 200 time steps.

Now let’s assume we were trading by this rule at that point, and colour the chart background based on the position we would be taking. Red is a short position, yellow is neutral and green is a long position. This is how our chart looks:

Naturally we won’t know if the strategy is a winner only by visually inspecting charts, we will develop a backtesting algorithm to help us with that. However, looking at charts helps us to get more insights and to build better backtesting scripts as well.

Thank you for taking the time to read this article. In part 2 of this series we will continue our journey in crypto quant trading, talking about backtesting! Feel free to contact me on LinkedIn for any questions or suggetions.

--

--