How Do Stock Trading Algorithms Work?
The stock market can be a voracious beast to those that don't understand it, but nowadays, you don't even need to understand it to make money. The rise of the digital information age and AI has brought about a new way of stock trading called algorithmic trading.
Sometimes referred to as automated trading or blackbox trading, this is essentially a program that can trade stocks at high speeds and frequencies, perfectly in line with the market.
These programs are given constraints and instructions like timing, price, amount, etc. and a user can finetune how they exactly work. So how does this all work then...? Let's take a look.
The basics
Through algorithmic trading, you can make sure trades are executed at exactly the right time, order amounts are perfectly accurate, you can simultaneously check multiple market indicators, and you can reduce the risk of manual errors.
This trading technique became popular when stock exchanges around the world offered incentives to companies to make their stock more liquid, or easier to sell. The New York Stock Exchange, for example, has a group of companies that add competition and liquidity to stock quotes on the market. The NYSE pays a fee for providing more liquid stocks, which in turn helps the stock exchange broker more deals.
Having more liquid stocks also gives investors more security in their investment as they know that they'll be able to get out rapidly in the future if needed. This highliquidity is what allows highfrequency trading to happen, and it can be VERY profitable.
The key benefit to the introduction of HFT for all markets is that it increases the bidask spread, which allows for higher profits to investors. The biggest downside, though, is that since these algorithms make thousands of moves per minute, entire markets can rise or fall in an instant.
For example, on May 6, 2010, the DOW Jones dropped 1,000 points, 10% of its value, in just 20 minutes before it rose again. It was later found that a massive order caused a succession of algorithmic traders to selloff quickly.
Getting into the nittygritty of algorithmic trading a little more, we can start to look at strategies. The most common of which are trendfollowing strategies.
Trendfollowing strategies
Trend following algorithmic trading essentially means that these algorithms buy and sell based on moving averages, breakouts, price movements, and other highly technical indicators. These strategies are common because they're simple and rely on readily available data with little complex analysis. Comparing this strategy to mathematics, they would be like simple addition and division to computers.
This simplicity also means that your opportunity to make a lot of money isn't as high with these techniques, but they provide greater security.
Arbitrage trading
Another common technique of algorithmic trading is arbitrage — which means the difference in prices.
If one gas station was selling a candy bar for a dollar and the other was buying them for 2, you could buy tons of candy from the first and sell it to the latter at a profit of a dollar per bar. This is arbitrage trading.
Arbitrage trading algorithms buy a stock that is listed on different exchanges. Since each exchange is a different market, prices aren't always aligned, but they're usually close. Implementing an algorithm to identify price differences allows you to exploit these opportunities. Usually, these arbitrages change quickly and aren't very large, so a human could never do it fast enough, but a computer certainly can.
RELATED: TECHNOLOGY DRIVEN TRADING APP LETS ANYONE TRADE STOCKS
There are a ton of different strategies to algorithmic trading that extend far beyond the purpose of this introductory article. It's safe to assume that algorithms can be adjusted based on what specific results you want, how risky you want to be, and for which indicators you want to trade on.
Through machine learning, some algorithms are even being developed that can take trade data, determine whether an algorithm was behind those trades, figure out how that algorithm works, and then beat that competing algorithm at its own game or at least decrease its margin.
Setting up algorithmic trading
Setting up an algorithm to do your trading does require some technical prowess, and it's usually relegated to firms with the means to do so.
Not only do you have to develop computer code to build the algorithm, but then you need to implement the algorithm onto your computer. The biggest challenge is transforming the initial algorithm into one that can actually be integrated into your trading account.
Here's what you'll need:

Computer programming skills and knowledge of trading strategy or the ability to purchase a premade algorithm.

Active network connectivity to place orders.

Access to market data feeds integrated into your algorithms.

Infrastructure to backtest the system in prior markets to validate that it actually works without losing any money.
To close out this introduction to algorithm trading, let's work through a final theoretical example.
A given stock, let's say for Concerning Reality, abbreviated CORE, trades on the YouTube and Facebook Stock exchanges. These stock exchanges open at different times and in different currency values. You'll need an algorithm that trades in both currencies (likes versus subscribers) and one that can account for the time differences accordingly.
In order to make money through arbitrage, the difference of the stock's price on the difference exchanges, you'll need an algorithm that has a live feed of current market prices from both exchanges, an integrated exchange calculator, an orderplacing integration with a stockbroker/provider, and backtesting ability to see how CORE traded prior to implementing the algorithm.
The algorithm would read the incoming prices from both exchanges, convert them through exchange rates, determine if the arbitrage is large enough to make money (factoring in brokerage fees) and then buy and sell accordingly. If implemented properly, the algorithm will slowly amass more and more profit.
It all sounds simple in theory, but in practice, issues can arise. Prices can fluctuate on the millisecond, so if your algorithm is slow in processing data, then it could end up consistently losing money. You also have risks such as system errors and network outages that could cause your algorithm to spend too much money or just not be able to trade anymore.
Algorithm trading probably isn't in your future, but hopefully, now you understand a little bit more about the process that drives modern markets.