My first steps into Trading Algorithms

Dec 13, 2025

+++

My journey into Trading Algos

Introduction

I was always interested in stock trading and investments. However, besides my small interaction during the Covid Gamestop craze and some passive investments in mutual funds and ETFs, I never dived deep into the topic. After graduating from university, and working as a software developer for a few years in Malta, my girlfriend and I decided to go work abroad and landed in Luxembourg.

As a country, Luxembourg’s main industry is banking and finance, more specifically, the fund industry, where I landed a job as a data engineer in the realm of financial reporting. In financial reporting, I got to work directly with many financial experts to deal with large volumes of financial data from many different fund admins and asset managers. The goal is to transform this data using tools like Apache Spark to generate financial reports.

This naturally got me more aware of certain financial terms and attributes related to funds and piqued my curiosity into how I can take my software engineering skills to new level. In this blog, under the Finance category I will share with you what I learn/read and research with the goal of building a trading algorithm that perhaps could even generate some very small passive income.

I started by reading the book The Man Who Solved the Market by Gregory Zuckerman. A book about Jim Simons, who was a mathematician and computer scientist and built what was arguably the greatest hedge fund of all time. The secret of this hedge fund was to build computer algorithms based on statistics and probability and trust it to buy and sell currencies/stocks and bonds without any human intervention, and managed to score an average of 66% return on the stock market between 1988 and 2018. This book did not give any financial advice or any knowledge on this subject, but certainly was of inspiration to dive deep in this topic.

Long Trading Algorithms

I will first try a different approach than most people. Instead of going into the realm of trading bots and medium/high frequency trading, I will try to learn Long term trading algorithms. High frequency trading bots are very interesting, however, after reading a bit about the subject, I face many things that I cannot relate to such as, high capital, infrastructure, and are more like a game. On the other hand long term trading strategies are easier to reason about, more realistic and could honestly benefit me personally as I can learn more about finance itself as they are less probability and machine-learning dependant and more based on value, dividends, and fundamental data.

After some research, and some chatgpting, I will explore the following algorithms, each with it’s own blog post (The following list is generated using an A.I):

1.️ Value Investing Algorithm

Goal:

Buy undervalued companies based on fundamental ratios. Famous by Warren Buffet.

Data needed:

  • Years of financial statements

Metrics:

  • P/E
  • P/B
  • P/FCF
  • EV/EBITDA
  • ROIC
  • Intrinsic value (DCF or Graham formula)

Implementation style:

  • Mostly rule-based
  • Some ML optional (forecast earnings or detect anomalies)

Why it’s good:

  • Works on long horizons (1–5 years)
  • Stable, low turnover

Difficulty:

⭐⭐ Medium

Feasibility:

⭐⭐⭐⭐ High

2. Momentum Strategy Algorithm

Goal:

Buy assets that have been going up, sell those going down.

Data needed:

  • Daily or weekly prices
  • Rolling returns (3m, 6m, 12m)
  • Volatility measures (for risk-adjusted momentum)

Implementation:

  • Purely mathematical; no fundamentals
  • Compute total return momentum or risk-adjusted momentum
  • Rebalance monthly

Why it works:

  • Momentum has been an academically proven anomaly for 30+ years.

Difficulty:

⭐ Easy

Feasibility:

⭐⭐⭐⭐⭐ Very high

3. Quality Factor Strategy

Goal:

Buy strong, efficient, durable companies.

Data needed:

  • ROIC
  • Gross margins
  • Debt ratios
  • Earnings stability
  • Cash flow consistency

Implementation:

  • Compute “quality score”
  • Pick top decile

Why it works:

  • Quality companies outperform in most markets, especially during downturns.

Difficulty:

⭐⭐⭐ Medium

Feasibility:

⭐⭐⭐⭐ High

4. Low Volatility / Defensive Strategy

Goal:

Buy stocks with low historical volatility.

Data needed:

  • Daily price history
  • Rolling standard deviation
  • Beta relative to market

Implementation:

  • Rank stocks by volatility
  • Choose the lowest decile
  • Optionally optimize using minimum-variance portfolio matrix

Why it works:

Low-volatility stocks strangely outperform high-risk ones (the “low-vol anomaly”).

Difficulty:

⭐ Medium

Feasibility:

⭐⭐⭐⭐⭐ Very high

5. Dividend Growth Strategy

Goal:

Buy companies that grow dividends consistently.

Data needed:

  • Dividend history (10–20 years) -Payout ratio -Free cash flow coverage -Debt ratios

Implementation:

Score by dividend-growth consistency. Exclude high payout ratio or negative FCF companies

Why it works:

Dividend growers are mature, durable, undervalued.

Difficulty:

⭐⭐ Medium

Feasibility:

⭐⭐⭐⭐ High

6. Mean Reversion + Value Combo

Goal:

Buy stocks that temporarily fall below intrinsic value.

Data needed:

  • Intrinsic value estimate (fundamental)
  • Short-term price signals (technical)
  • Z-score deviations from mean

Implementation:

  • Detect short-term dips
  • Confirm long-term undervaluation
  • Execute reversal trades

Why it works:

Pairs fundamental mispricing with temporary volatility.

Difficulty:

⭐⭐⭐⭐ Medium-High

Feasibility:

⭐⭐⭐ High (More complex but powerful)

7. Pairs Trading Algorithm

Goal:

Trade two correlated stocks or ETFs that diverge temporarily.

Data needed:

  • Two assets with historical correlation
  • Price history
  • Rolling correlation
  • Z-score of price spread

Implementation:

  • Identify pair (e.g. Coke vs Pepsi)
  • When spread widens → short one, long the other
  • When it closes → exit

Why it works:

Statistical arbitrage: mean reversion of relationships.

Difficulty:

⭐⭐⭐⭐⭐ Highest complexity

Feasibility:

⭐⭐ Maybe (workable at small scale, but best with transaction cost advantages)