Trading the Breaking

Trading the Breaking

Share this post

Trading the Breaking
Trading the Breaking
[WITH CODE] Models: What are models? and algorithms?
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
10

Share this post

Trading the Breaking
Trading the Breaking
[WITH CODE] Models: What are models? and algorithms?
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 writingGet the app
Substack is the home for great culture

Share