Trading the Breaking

Trading the Breaking

Alpha Lab

[WITH CODE] Models: What are models? and algorithms?

Cracking the DNA of financial predictions and how algorithms translate market noise into signals

๐š€๐šž๐šŠ๐š—๐š ๐™ฑ๐šŽ๐šŒ๐š”๐š–๐šŠ๐š—'s avatar
๐š€๐šž๐šŠ๐š—๐š ๐™ฑ๐šŽ๐šŒ๐š”๐š–๐šŠ๐š—
Mar 11, 2025
โˆ™ Paid
11
2
3
Share

Table of contents:

  1. Introduction.

  2. What are models?

    1. What is a logistic regression?

    2. What is a threshold-based signal model?

  3. What are algorithms?

  4. 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:

  1. Logistic regression.

  2. 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:

Logistic Regression
832KB โˆ™ PDF file
Download
Download

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:

\(P(z_t = 1 \mid X_t) = \frac{1}{1 + \exp(-\theta^T X_t)},\)

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

\(\sigma(x) = \frac{1}{1+\exp(-x)},\)

maps any real input x to the interval (0,1). Its derivative is given by:

\(\sigma'(x) = \sigma(x)(1-\sigma(x)).\)

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:

This post is for paid subscribers

Already a paid subscriber? Sign in
ยฉ 2025 Quant Beckman
Privacy โˆ™ Terms โˆ™ Collection notice
Start your SubstackGet the app
Substack is the home for great culture