[WITH CODE] Models: What are models? and algorithms?
Cracking the DNA of financial predictions and how algorithms translate market noise into signals
Table of contents:
Introduction.
What are models?
What is a logistic regression?
What is a threshold-based signal model?
What are algorithms?
How do trading models and algorithms interact?
Introduction
The other day, someone on X demanded to know, "What the hell does a quant actually do? And why do they get paid like theyโre curing cancer or something?" My flippant reply: Magic, models, and algorithms.
But jokes aside, letโs unpack the wizardry. Quants are the financial worldโs alchemists. They donโt just crunch numbers; they build crystal balls. Using advanced mathematics, machine learning, and code, they craft models that predict market movements, price derivatives, and optimize portfolios. Think of them as the architects of predictions on steroids .
And when your investments nosedive? Cue the quant-as-detective. Theyโre the ones sifting through terabytes of dataโmarket ticks, economic indicators, even satellite images of parking lotsโto crack the case. Why did the portfolio tank? Was it a black swan event? A flawed assumption in the risk model? A rogue algorithm? They dissect chaos like forensic scientists, turning noise into actionable insights.
As for the obscene salaries? Consider their toolkit: PhD-level expertise in stochastic calculus, coding chops to duel with AI, and the nerve to bet millions on a decimal point. Theyโre part mathematician, part coder, part gamblerโand when theyโre right, they mint money. When theyโre wrong? Letโs just say you donโt want to be the one explaining that to the board.
So yeah, let's see exactly what that magic-model is.
What are models?
Think of a model as your financial GPS. Itโs a simplified map of the marketโs messy realityโlike turning a hurricane into a breezy flowchart. Models answer: โWhatโs the market doing?
Basically, it is a mathematical abstractionโa simplified representationโthat is used to capture essential features of market behavior. Models allow us to express complex relationships in a tractable form. They answer the question: What does the market look like?
They are the theoretical frameworks that we use to express our assumptions about how markets behaveโbetter to have none or few. They serve as the foundation upon which trading strategies are built.
Okay, instead of assuming that returns follow a normal distribution or that the process is autoregressive, we may opt for alternative representations that better capture the reality of financial data. To illustrate this idea, let's consider these two classical models as an example:
Logistic regression.
Threshold-based signal models.
A word of caution about these models: none, I repeat, none, are going to work if you don't have the right variables ๐ Avoid price at all cost๐ Keep this in mind before plugging and playing.
What is a logistic regression?
Logistic regression is used to classify the market into distinct regimes, such as up and down states, based on a set of input variablesโif you want deeper knowledge about this method, read this:
This model does not predict the magnitude of returns directly; rather, it estimates the probability that the market is in a certain regime.
We model the probability that the market is in an up regime as follows:
where:
ztโ is a binary indicator such that:
\(z_t = \begin{cases} 1, & \text{if the market is in an up aka buy}, \\ 0, & \text{if the market is in a down aka sell}. \end{cases}\)XtโโRn is a vector of explanatory variables at time t. These include measures such as momentum, volatility, volume, etc.
ฮธโRn is the parameter vector that determines the influence of each variable.
The logistic function, defined as
maps any real input x to the interval (0,1). Its derivative is given by:
This property is vital during optimization as it allows the use of gradient-based methods to adjust ฮธ.
Well, keeping that in mind letโs code it: