A brief introduction to quantitative algorithmic trading for the financial markets — 1

Ben Diagi
7 min readApr 1, 2019

--

This post is part of a longer series, and is meant to serve as a basic introduction to algorithmic trading for the foreign exchange and commodities markets.

Trading?

This section is aimed at you if you’re completely new to the markets & trading. It doesn’t cover the topic extensively, but only gives an idea.

The foreign exchange market is the domain where currencies are traded globally. Currencies are an important marker of the strength of a country’s economy. If you live in Nigeria(NGN), chances are that you’d need to import a vehicle from the United States(USD) at some point. The need to exchange currencies daily is what makes the forex(short for foreign exchange) market the largest, most liquid market in the world trading about U.S. $2,000 billion per day.

Forex spot trading involves buying and selling currencies according to the current price. That price, determined by supply and demand, is a reflection of many things, including current interest rates, economic performance, sentiment towards ongoing political situations (both locally and internationally), as well as the perception of the future performance of one currency against another.

CFD(Contract For Difference) means that the trader doesn’t actually need to have ownership of the underlying asset/currency. in order to trade it. This means that the trader can speculate, and buy if she thinks the market will go up or sell if she thinks the market will go down.

What is Quantitative Analysis?

Quantitative analysis (QA) is a technique that seeks to understand behavior by using mathematical and statistical modeling, measurement, and research. The purpose of quantitative analysis is to digest a large number of variables, such as asset prices and trading volumes but also how real-world events may affect asset prices.

What is Algorithmic Trading?

Algorithmic trading is the practice of using computer programs to execute trades according to a predefined set of trading rules and guidelines(an algorithm). The general idea is that, algorithms & bots are considerably faster than humans and are immune to human emotions and weaknesses.

Why Algorithmic Trading?

Algorithmic trading is better than traditional manual trading in a number of ways.

  • Trades are executed at the best prices; accurate up to 4–5 decimal points (called pips)
  • Trades are timed correctly and instantly to avoid significant price changes.
  • Trades can be modified and adjusted in nano-seconds.
  • Simultaneous automated checks on thousands of market conditions in seconds.
  • Reduced risk of manual errors when placing trades.
  • Trading ideas and strategies can be backtested using available historical and real-time data to see if they are profitable and consistent.
  • Reduced probability of mistakes by human traders due to emotional and psychological factors.

Algorithmic Trading Concepts

I would discuss some of the concepts that I have personally been involved in, over the past 3 years as an algo trader and programmer.

  1. HFT(High Frequency Trading): This involves placing a large number of trade orders at rapid speeds across multiple markets with the sole aim of profiting from small moves in the market using huge positions. I tried this out for a while, but I was limited by speed. Internet speed in Nigeria is generally slow, and although using a VPS helps to reduce latency, I can’t measure up to big banks and institutions that exist meters away from the New York Stock Exchange for example.
  2. Indicator Based Strategies: These are the easiest and simplest strategies to implement through algorithmic trading because these strategies do not involve making any predictions or price forecasts. Indicators are mathematical measurements, represented visually on the charts, which indicate the previous nature of the market. Essentially, indicators just show you what is already visible on the charts, it just helps you visualize them using lines, bars, icons etc. Some examples are: Simple Moving Average, Bollinger Bands, Relative Strength Index. I won’t go into these indicators in detail. With indicator based strategies, the trader would gather historical data as far back as possible, and look for recurring indicator based patterns. For Example, a widely popular and very basic indicator strategy is the MA(Moving Average) crossover. This involves buying the market when the short term MA crosses above the long term MA, and selling when the long term MA crosses below the short term MA. Note that indicators form slowly and are purely descriptive hence this is only a reactive strategy. I spent most of the early part of my quantitative analysis career building over 100 indicator based algorithms. I will talk more about the failures and successes in future posts in this series.
  3. Arbitrage Trading: This involves buying a dual-listed stock at a lower price in one market and simultaneously selling it at a higher price in another market which offers the price differential as risk-free profit or arbitrage. The same operation can be replicated for stocks vs. futures instruments as price differentials do exist from time to time. Implementing an algorithm to identify such price differentials and placing the orders efficiently allows profitable opportunities. Another form of arbitrage involves; creating 2 similar broker accounts, opening buy and sell positions simultaneously on the two. The idea is that one account will be wiped out, and one account should make at least 200% profit for this to work.
  4. Fundamental Strategies: There are 2 forms of doing market analysis; technical and fundamental. While Technicals involve analysis of price action, chart patterns, and market volume, Fundamentals involve analysis of economic, social, and political forces that may affect supply and demand. Fundamental opportunities involve news trading and are more difficult to discover. An example would be the London Breakout Strategy. More information on this in my future posts.

Into Algorithmic Trading

Implementing the algorithm using a computer program is the final component of algorithmic trading, accompanied by backtesting (trying out the algorithm on historical periods of past market performance to see if using it would have been profitable). The challenges are

(a) to transform the identified strategy into an integrated computerized process that has access to a trading account for placing orders

(b) to reduce the drawdown on the performance of the algorithm

(c) to attain better risk-to-reward ratio

The following are the requirements for algorithmic trading:

  • Software programming knowledge to program the required trading strategy. There are a host of options for this, but I use mql4, based on C++, on MetaTrader 4. If you are proficient in C or C++, this shouldn’t be a problem.
  • Network connectivity and access to trading platforms to place orders. You would want to have a very good internet connection on your trading terminal.
  • Access to market data feeds that will be monitored by the algorithm for opportunities to place orders. Direct data feeds from brokers, or APIs that feed date from news sources such as Reuters.
  • The ability and infrastructure to backtest the system once it is built before it goes live on real markets. I use the strategy tester on Meta Trader to backtest all my strategies.
  • Available historical data for backtesting depending on the complexity of rules implemented in the algorithm. Historical data is thankfully open source, and as such, can easily be gotten from brokers.

How big is Quantitative Trading?

For all the advancements in the ability for computers to analyze enormous quantities of date, the extent of Quantitative investing remains open to estimates and interpretation. According to Alex Foster, author of “The Edge of Foresight” and VP at Quantiacs, here are some data points.

Roundly, 90% of volume in the public markets in the United States is traded by quantitative means. This methodology is spreading at rates above average at 10.3% according to the report Global Algorithmic Trading Market 2016–2020. This same report claims that Quantitative Finance is a $1 trillion market.

Mixing Quant with Fundamental Analysis

Pure quantitative analysis has proven itself a useful evaluation tool. It is becoming more common for investment funds to include other factors that are more difficult to measure. This is where Qualitative Analysis steps in; focusing on meanings that involve sensitivity to context rather than the singular desire to obtain universal generalizations. Qualitative analysis works by establishing rich descriptions rather than quantifiable metrics. Qualitative analysis seeks to answer the “why” and “how” of human behavior.

“Qualitative analysis works by establishing rich descriptions rather than quantifiable metrics. Qualitative analysis seeks to answer the “why” and “how” of human behavior.”

Quantitative analysis is not the opposite of qualitative analysis; they are just different philosophies. Used together, they can provide useful information to make informed decisions that improve financial decisions.

FINALLY

“Be it fear or greed or just becoming overwhelmed by mountains of data, emotions serve only to stifle rational thinking and that usually leads to losses. Quantitative trading does not have these problems.”

Above, is the major argument for Quantitative Algorithmic Investing; It takes away the emotions, it is super fast and it does not mistakes.

Many traditional traders swear that algorithmic trading will never return profits consistently. Well, I have been disproving that fact consistently since 2015. The journey has begun, but I don’t know where or when it will end.

In future articles, I will be going in-depth into my experience with the different forms of algo investing.

Kindly leave a comment letting me know what you think, if you’re currently involved with quantitative trading or looking to get involved.

Let’s Connect

Ben.

--

--

Ben Diagi
Ben Diagi

Written by Ben Diagi

I’m a Product Manager & Designer. I write about Product, Design and Finance. In my spare time, I build trading algorithms and create UX prototypes.

No responses yet