Subscribe

Let's build an Agentic Trading System. Together

May 18, 2025

It all started 13 years ago, when I landed my first job as a quant analyst.

 

My role?

Basically building mathematical models to estimate market risk for all financial derivatives at one of the largest European banks.

 

Was it fun?

Yes, of course! It was my dream job back then (the fact that it was the first job out of Maths school probably helped).

I used to spend my days fitting statistical models to price and hedge financial derivatives, way before Machine Learning was cool.

It was all about MATLAB (not my cup of tea, but my best friend at the time. Is that too sad? xD).

Apart from maths and MATLAB, a big part of my job was talking to traders, the guys at the bank that were using these models to make trading decisions that fit their (and the bank's) risk appetite.

 

Then something happened 

I entered a trading floor for the first time in my life, and I got a glimpse of what actual trading looks like.

Bloomberg terminals, fax machines, phone booths.

Risk management, portfolio construction, and of course trading.

One of the things that caught my attention, was the amount of screens showing Bloomberg news 24/7.

Traders would constantly have one eye on their Bloomberg terminal, and the other on Bloomberg news.

 

Why?

Because they knew that some news can really move the market.

So they wanted to be the first to know, take action and profit.

Back then there was no such thing as Large Language Models. But there were a lot of smart tricks to extract sentiment from news.

Simple regular expressions, helped quant traders build C++ functions running on Bloomberg terminals, generating numeric scores for potential market moves.

These inputs were then used to make trading decisions (by traders), that had to be approved by risk management.

That was the Prehistory of Natural Language Processing.

Fast forward 13 years….

 

Sentiment analysis is a solved problem in 2025

Large Language Models are universal functions that can map any given text to any structured output you want.

For example, map a piece of market news to a JSON formatted list of sentiment scores.

Of course, you need to wrestle a bit with your prompts to get there.

And this is something I want to quickly show you if you have 5 minutes. Do you?

 

A 5-minutes straight-to-the-point prompt engineering example

All the source code I am showing you here is in this repo I put together.
> Link to the repo

We will be using BAML (Basically a Made up Language) to ensure our LLM generates the type of structured output we want.

 

Why BAML?

I personally prefer BAML to all-in-one frameworks like LangChain, as it makes fast prompt experimentation (the key to success for 99% of LLM problems) easier.

 

I also strongly recommend you use uv to package your project.

curl -LsSf https://astral.sh/uv/install.sh | sh

For example, to create the project structure you just need to run:

uv init crypto-sentiment-parser

Nice, let's now install the BAML client and the BAML cli.

uv add baml-py

To generate some boilerplate BAML code under `baml_src` run:

uv run baml-cli init

From these *.baml typed files, you can generate the equivalent Python code with:

uv run baml-cli generate

And here is where the magic starts to happen → In the BAML language a prompt is a function with strict types.

You define your types in BAML

class CryptoSentiment {
 coin Coin
 score Score
 reason string
}

enum Coin {
 Bitcoin
 Ethereum
}

enum Score {
 Positive @description("Positive sentiment")
 Negative @description("Negative sentiment")
 Neutral @description("Neutral sentiment")
}

and from there, you prompt becomes a typed function. Genius.

For example, here is our ExtractCryptoSentiment function, that maps a string to a list of CryptoSentiment objects.

From here, the BAML client will generate the Python code for you and put it in the baml_client folder.

So, whenever you need to invoke this very simple sentiment extraction agent, you just need to use a super simple function like this:

If you want to play around, check out this repository I put together. Feel free to adjust the code to your own needs.

 

So what now?

Building a sentiment extraction parser like we just did is very cool and all that.
But this is just one piece of the trading puzzle.

Trading in the real world takes more than that. WAY more.

Trading smartly is all about:

  • Finding a good trading idea

  • Testing with hard data if this idea is really a good idea

  • Executing the idea

So, the question that I kept asking myself last week was

Can we take things to the next level, and build not only a single news sentiment service, but a semi-autonomous fleet of agents that can find, test and execute trading strategies as the human traders I met 13 years ago did?

And you know what?

I think WE can.

And I say WE, because I want you to join me in this journey.

 

Want to build an Agentic Trading System. Together? 

On October 6th, I will start the first cohort of my new live course "Let's build an agentic trading platform. Together".

We will work super hard for 8-weeks and live code together 50+ hours, to build from scratch a semi-autonomous production-ready agentic system for trading, that we will deploy and operate on Kubernetes.

Along this 8-week journey, you will learn:

  • How to map a business problem to an AI system solution with a real world example.

  • Universal design patterns for building real time agentic systems.

  • Real time data processing, transport (Kafka), and storage (Real time DBs and VectorDBs).

  • Structured output generation and tool usage to guide agents to success.

  • Vanilla, RAG and Agentic RAG to increase model output quality.

  • Tool server design and implementation.

  • Containerization with Docker and deployment with Kubernetes.

  • Continuous Integration and Continuous Deployment with Kubernetes.

  • Production-ready LLM serving.

  • Tons of Python and Rust tricks.

 

And you know what?

We won't be alone. Marius Rugan, the most talented Infrastructure engineer I have met in my life, will be in charge of the Ops part of the course.

Marius brings to the table decades of experience buildingoperating and scaling infrastructure for top tier companies, both in finance and in retail.

He doesn't just know how systems should work. He's fixed them at 3 AM when they didn't.

 

I will lead the Software/AI/LLM/however-this-thing-will-be-called in 2026 engineering. Because my job is solving problems (maths, computer science, ml, sometimes even love) and then help others do the same.

 

Disclaimer

We are NOT here to teach you how to trade and earn money - we are here to teach you how to build production-ready agentic systems (in this case a semi-autonomous agentic trading system that assists the end user in the decision-making process and execution).

This is NOT a course for AI tourists.

This is a course for AI hard-core builders who want to understand both the big picture and the million low-level details to implement, deploy and operate a production-ready cost-effective agentic system on Kubernetes.

So it will be hard. Is that clear?

 

Gift 🎁 

As a subscriber to the Real World ML Newsletter you have exclusive access to a 50% discount if you enrol in the following 72 hours.

After that, gone. Hasta la vista. Ciao ciao. Vidimo se.

It will never get cheaper than this 😉

Get 50% OFF TODAY

See you on the other side,

Pau

Wanna learn more Real World ML?

Subscribe to my weekly newsletter

Every Saturday

For FREE

Join 26k+ ML engineers ↓