~~~ Algorithmic Trading - how it works ~~~


Also known as algotrading, robot trading, automated trading, or quantitative investing: Algorithmic trading simply means buying and selling financial assets based on some 'system' or algorithm. As opposed to 'manual trading' or 'discretionary trading' that's usually based on gut feeling. Or on some information about the traded asset that the trader hopes his competitors don't have.

Any algorithmic trading system has 3 components:

  • A trading algorithm or trading strategy that determines buy and sell rules based on market data;
  • a trading connection to online exchanges, brokers, or data sources for receiving price data and placing the orders;
  • and a backtesting method for determining the expected profit of the algorithm (or whether it is profitable at all).

The trading algorithm is normally realized by a software program or 'script'. But a computer is not always involved. The famous 'Turtle Trading' system of the 1980s was a manually executed algorithm, and backtesting was done with pen and paper. However, this simple system would not work anymore today. Since the markets have changed and large hedge funds have switched to algo trading, more complex algorithms are needed for achieving continuous profit with algorithmic trading. This does not mean that private traders are excluded. Advanced software tools such as Zorro allow algo trading with the same methods and algorithms that large hedge funds apply.
 

Algorithmic trading: Why and when does it work?

All methods of algorithmic trading seek to exploit a market inefficiency, usually for predicting a price trend or establishing a statistical advantage. Market inefficiencies cause price curve anomalies - deviations of the price curve from pure randomness. Obviously, trading strategies can only work when those inefficiencies really exist and are large enough to overcome transaction costs. In a perfect, efficient market, prices would only be affected by real events, such as the invention of a new technology or the publication of company results. All traders are 'informed', decide rationally and act immediately. The price curves in such a hypothetical market would be pure random-walk curves that contain no information for predicting future prices.

Fortunately for algo trading strategies, real markets are far from this theoretical ideal. Market inefficiencies are everywhere. They are caused by slow reaction on news, incomplete information, rumors, patterns of repetitive behavior, and irrational trading (such as following advices by 'analysts'). Such effects can be described by market models. The problem: the effects are small in relation to the ubiquitous 'noise', the randomness in price curves. They are normally not visible to the human eye.  Nor can they be reliably detected by classical "technical indicators". Serious statistical methods, such as spectral analysis, or machine learning algorithms are normally required for effectively exploiting market inefficiencies.

SPX price curve spectral analysis
SPX price curve spectral analysis

 

There are four main categories of trading algorithms:

Risk premium strategies

The most often used method by professional algo traders. They accept a certain amount of risk in exchange for a certain amount of profit. The expected profit, of course, should exceed the risk. The algorithms often accumulate small frequent profits with a low, or ideally negligible, risk of a rare high loss. The most trivial example is buying and holding a stock with a high historical performance. Classical risk premium examples are options selling systems and mean-variance optimization. Algo trading systems that exploit volatility anomalies, such as grid traders, can also fall in that category.

Model based strategies

These strategies are based on a model of behavior patterns of market participants, resulting in market inefficiencies and price curve anomalies.  A correct model allows limited price prediction and thus profitable trading. Model based strategies can exploit market regimes, market cycles, price borders or channels, price differences of correlated assets (statistical arbitrage), or price differences of similar assets at different exchanges (HFT arbitrage). More examples and details about building model based strategies can be found in an article series on the Financial Hacker blog. 

Data mining strategies

They have nothing to do with mining bitcoin, but evaluate the market with a machine learning algorithm for predicting short-term price trends. For this they use signals that are usually derived from the order book or the price curve, but sometimes also from fundamental data, like earnings reports or the Commitment Of Traders (COT) report. Even exotic data sources such as blockchain parameters or twitter keywords can be used for data mining algorithms. Just as model based system, data mining also exploits market inefficiencies and would not work on a totally random market. But the details of those inefficiencies and the derived trading rules are unknown to the developer - the system is a 'black box'. More information and an example of a deep learning forex system can be found in this Data Mining article.

Profit curve of a Zorro deep learning trading system
Profit curve (blue) of a deep learning system coded in C

Indicator soups

They are usually based on 'technical analysis' - the belief that technical indicators, geometric price curve properties, or price patterns can predict future prices. Indicator soups are often used by retail traders and found on trader forums or in trading books. They do not  always use indicators, but can also derive trade signals from traditional candle patterns or with exotic methods such as Elliott Waves or Harmonic Patterns. Although many studies have revealed that technical analysis is mostly useless, some complex indicator soups were in fact profitable in certain market situations, at least for a limited time. If you like playing roulette, you will probably also like algorithmic trading with technical analysis and a soup of indicators.


Fully automated or semi-automated algo trading?

Fully automated algo trading systems run permanently either on a computer at home or - better - on a rented VPS server. They observe  the markets and can anytime enter or exit positions without human intervention. Semi-automated systems are manually started, usually in regular intervals, like on the first trading day of a month. They enter an automated process of reading and analyzing recent market data, opening or closing trades, then shut down and until the next start. They are normally used for strategies that trade infrequently, like long-term portfolio rebalancing or options trading systems.

And how does an algo trading strategy look like? Here are some example scripts of indicator based, model based, data mining, and risk premium algo trading systems.

 

"Take Money From The Rich And Give It To The Poor"