Learn Algorithmic Trading: 6 Key Components

The ancient city of Carthage stood against the Roman Empire for over a hundred years.

“Victorious warriors win first and then go to war, while defeated warriors go to war first and then seek to win.” – Sun Tze.

Finance, Mathematics and Programming.

That is what I used to tell my students when they ask what is required for building algorithmic trading systems. However, those 3 components are vague, and they do not add value to a beginner who wants to learn how to get started in algorithmic trading.

It is more useful to divide the knowledge for building algorithmic trading systems into 6 key components. You need to be acquainted with all of them in order to build effective trading systems.

Some of the terms used may be slightly technical, but you should be able to understand them by Googling.

Note: Some of these do not apply if you want to do High-Frequency Trading.

1. Market Theories

What is it?

Market theories refer to the way the markets work. This entails understanding market inefficiencies, market participants, relationships between assets/products/news/factors and price behaviour.

Why do we need to know it?

Trading ideas stem from market inefficiencies. You will need to know how to evaluate market inefficiencies that give you a trading edge versus those that don’t. You also need to learn how to take advantage of these market inefficiencies when they occur.

Keywords to Google

Market inefficiency, price/asset/market relationships, market participants, market microstructure, macroeconomics, market fundamentals, hard arbitrage, soft arbitrage, structured products, order limit book, depth of market, retail traders vs hedge funds/institutional investors, financial exchanges, exchange traded products, over-the-counter, price expectations vs reality, price action and price behaviour.

Medieval Warfare Analogy

This is akin to understanding the battlefield. Knowing what your opponent is doing in this particular battle considering the relevant factors (both your armies, terrain, goals and characteristics of each general).

2. Robot Design

What is it?

Design of an effective portfolio of trading strategies. This entails understanding how automated trading systems work individually and together.

On an individual level, an algorithmic trading strategy consists of 3 core components: 1) Entries, 2) Exits and 3) Position sizing. You’ll need to design these 3 components in relation to the market inefficiency you are capturing (and no, this is not a straightforward process).

On a portfolio level (aka multiple strategies running together), you’ll need to know how to manage a group of algorithmic trading strategies at the same time. Strategies can be complementary or conflicting – this may lead to unplanned increases in risk exposure or unwanted hedging. Capital allocation is important too – do you split capital equally during regular intervals or reward the winners with more capital?

Why do we need to know it?

Once we find market inefficiencies, we need to find the best way to exploit them. That will require you to have knowledge of how to design trading robots.

You don’t need to know advanced maths (although it will help if you aim to build more complex strategies). Good critical thinking skills and a decent grasp on statistics will take you very far.

Design involves testing for market inefficiencies (does the market inefficiency exist?) and building effective trading strategies (can I find a way to take advantage of them?). The former entails market (is it correlation or causation – or does it not matter?), statistical and infrastructural analysis. The latter entails idea generation, backtesting (testing expectancy and robustness) and optimisation (maximising performance with minimal curve fitting).

Keywords to Google

Entries, exits, position sizing, money management, idea generation, backtesting, robustness, strategies that adapts to the market, optimisation, curve fitting, walk-forward optimisation, math/statistics for finance, correlation, cointegration, execution cost, performance analysis, portfolio of trading strategies, hedging, risk management, risk exposure and capital allocation.

Medieval Warfare Analogy

Designing, training and equipping your army to beat a specific opponent.

A diverse strategy can handle a variety of market conditions.

A diverse strategy can handle a variety of market conditions.

3. Coding

What is it?

The method we use to build algorithmic trading strategies.

Why do we need to know it?

To build algorithmic trading strategies.

Choosing a programming language:

If you know which products you want to trade, you should find suitable brokers and platforms for these products. You then need to learn the programming languages for those platforms/backtesters.

If you are starting out and do not know what to trade, I recommend Metatrader 4 (FX and CFDs on equity indices, stocks, commodities and fixed income), Quantopian (stocks only) or Quantconnect (stocks and FX). The programming languages used are MQL4, Python and C# respectively.

Keywords to Google

Coding/programming trading strategies, MQL4, MQL5, EasyLanguage, AFL, Python/C#/C++/R/MATLAB/VBA for finance, Trading Technologies, CQG, MetaTrader 4, MetaTrader 5, Amibroker, NinjaTrader, MultiCharts, TradeStation and broker API.

Medieval Warfare Analogy

Skills to forge swords, craft bows and build catapults.

4. Data Management

What is it?

This entails sourcing and cleaning data to ensure we have accurate data for backtesting and that this data reflects the live trading environment as much as possible.

Why do we need to know it?

Garbage in == garbage out. Inaccurate data leads to inaccurate test results. We need reasonably clean data for accurate testing. Cleaning data is a trade-off between cost and accuracy. If you want more accurate data, you need to spend more resources cleaning/obtaining it.

Issues that lead to dirty data include missing data, duplicate data, wrong data (bad ticks). Other issues that can generate misleading data include dividends, stock splits, mergers, spin-offs, gaps and futures rollovers etc.

Keywords to Google

Data management, data cleaning, data providers, finance data sources, I hate cleaning equities data, data storage, data organisation and maintaining trading data.

Medieval Warfare Analogy

Making sure the intel on the enemy is correct.

5. Risk Management

What is it? (This has slight overlap with 2. Robot Design)

There are 2 main types of risk: Market risk and Operational risk. Market risk involves risk related to your trading strategy. Have you hedged away unwanted risk? Is your position sizing too large? Is your risk exposure to a particular element too high? Does it consider worst case scenarios? What if a black swan event like World War 3 happens?

In addition to managing market risk, you need to look at operational risk. System crashes, loss of internet connection, poor execution algorithm (leading to poorly executed prices or missed trades due to an inability to handle requotes), counter-party risk, broker insolvency and theft by hackers are very real issues.

Why do we need to know it?

We need to protect our downsides. Minimising risk whilst maximising returns is key.

Keywords to Google

Risk management, drawdowns, black swan events, fat-tailed events, hedging, risk exposure, operation risk, software security, secure VPS, auto restart [insert trading software’s name], downtime prevention, poor trade execution, slippage, requotes, counter-party risk and broker insolvency.

Medieval Warfare Analogy

Market risk: Reducing loopholes in the war strategy.

Operation risk: Making sure everything that is supposed to work, works.

Boom!

6. Live Execution

What is it?

Backtesting and live trading are very different. You’ll need to select proper brokers (MM vs STP vs ECN). Forexpeacearmy.com is your best friend when it comes to retail broker reviews (this also applies to brokers offering non-forex products), so make sure you read the reviews there before deciding on a broker.

You need proper infrastructure (secure VPS and downtime handling etc) and evaluation procedures (monitor your robots’ performance and analyse them in relation to market inefficiencies/backtests/optimisations) to manage your robot throughout its lifetime.

You need to know when to intervene (modify/update/shutdown/turn on your robots) and when not to.

Why do we need to know it?

The past does not predict the future perfectly. There are many issues that can crop up when trading live money. It’s essential that you create protocols to regularly monitor the market and your strategies’ performance. You also need to be prepared to improve/update your strategies and fix problems when they arise.

Keywords to Google

Live trading, trade psychology, trade management, trade execution, VPS (virtual private server), monitoring trading robots, remote access to your trading platform, live performance evaluation, trading broker selection, broker reviews, does my broker screw me over, spread widening, stop hunting, funds get deposited quickly but takes forever to withdraw, broker types, market makers, straight-through processing, electronic communication networks, A-books, B-books, liquidity pools and dark pools.

Medieval Warfare Analogy

How you manage the battle when it actually happens.

It’s a Never-Ending War!

Algorithmic trading (or any kind of trading) is a marathon, not a sprint. Keep learning and improving. The trading/investment space is getting incredibly competitive. Many strategies that used to work don’t any more. Personally, I think profitable trading systems have a lifespan of about 2-3 years (in general) before others catch on to it. You need to constantly innovate to stay ahead of the game, and innovation takes experience, wits, time, infrastructure and money.


AlgoTrading101 is an Investopedia-featured algorithmic trading course that doesn’t suck. Learn more about us at AlgoTrading101.

Keep up to date


Lucas Liew

This dude runs AlgoTrading101.com, an algorithmic trading academy with over 13,000 students. Click on the "Author" link above to learn more about him.