What Is an Algorithm?

An algorithm is a set of instructions for solving a problem or accomplishing a task. One common example of an algorithm is a recipe, which consists of specific instructions for preparing a dish or meal. Every computerized device uses algorithms to perform its functions in the form of hardware- or software-based routines.

In finance, algorithms have become important in developing automated and high-frequency trading (HFT) systems, as well as in the pricing of sophisticated financial instruments like derivatives.

Key Takeaways

  • An algorithm is a set of instructions for solving a problem or accomplishing a task. 
  • Every computerized device uses algorithms, which cut the time required to do things manually.
  • Algorithmic trading, also known as automated trading or black-box trading, uses a computer program to buy or sell securities at a pace not possible for humans.

Understanding Algorithms

Financial companies use algorithms in areas such as loan pricing, stock trading, asset-liability management, and many automated functions. For example, algorithmic trading, known as algo trading, is used for deciding the timing, pricing, and quantity of stock orders. Also referred to as automated trading or black-box trading, algo trading uses computer programs to buy or sell securities at a pace not possible for humans.

A large part of stock trading in the U.S. is done using algorithms, and they are also used widely in forex trading. A big part of that is high-frequency trading (HFT), often employed by hedge funds.

HFT involves using sophisticated computers and algorithms for trading. One side effect of algos is that the average holding period for stocks has decreased significantly—from four years in the 1940s to less than a minute a decade ago.

Computer algorithms make life easier by trimming the time it takes to manually do things. In the world of automation, algorithms allow workers to be more proficient and focused. Algorithms make slow processes more proficient. In many cases, especially in automation, algos can save companies money.

Since prices of stocks, bonds, and commodities appear in various formats online and in trading data, the process by which an algorithm digests scores of financial data becomes easy. The user of the program simply sets the parameters and gets the desired output when securities meet the trader's criteria.

Algos are used in trading to help reduce the emotional aspect of investing. Algorithms are used by investment banks, hedge funds, and the like; however, some algo-based programs and strategies can be purchased and implemented by retail investors. There are several types of algos based on the strategies they use, such as arbitrage and market timing. 

60% to 73%

Of all trading of global equities is algorithmic trading.

Types of Algorithmic Trading

Several types of trading algorithms help investors decide whether to buy or sell. The key types of algos are based on the strategies they employ. For example, a mean reversion algorithm examines short-term prices over the long-term average price, and if a stock goes much higher than the average, a trader may sell it for a quick profit. Other algorithm strategies may market timing, index fund rebalancing, or arbitrage. There are also other strategies, such as fund rebalancing and scalping.

Arbitrage

Arbitrage looks to take advantage of the price difference between the same asset in different markets. Algos can capitalize on this strategy by quickly analyzing data and identifying pricing differences, then quickly execute the buying or selling of those assets to capitalize on the price difference. 

An asset may trade for one price on a certain exchange, but a different price on another—the algo would capitalize by buying the asset at the lower price on one exchange and immediately sell it for the higher price on another exchange.

Market Timing

Market timing strategies use backtesting to simulate hypothetical trades to build a model for trading. These strategies are meant to predict how an asset will perform over time. The algorithm then trades based on the predicted best time to buy or sell. These strategies involve many datasets and lots of testing.

Mean Reversion

Mean revision strategies quickly calculate the average stock price of a stock over a time period or the trading range. If the stock price is outside of the average price—based on standard deviation and past indicators—the algo will trade accordingly. For example, if the stock price is below the average stock price, it might be a worthy trade based on the assumption that it will revert to its mean (e.g. rise in price). This type of strategy is popular among algos. 

Algorithm Trading Example

The following is an example of an algorithm for trading. A trader creates instructions within his automated account to sell 100 shares of a stock if the 50-day moving average goes below the 200-day moving average. Conversely, the trader could create instructions to buy 100 shares if the 50-day moving average of a stock rises above the 200-day moving average. Sophisticated algorithms consider hundreds of criteria before buying or selling securities. Computers quickly synthesize the automated account's instructions to produce the desired results. Without computers, complex trading would be time-consuming and likely impossible.

Algorithms in Computer Science

In computer science, a programmer must employ five basic parts of an algorithm to create a successful program:

  1. Describe the problem in mathematical terms
  2. Create the formulas and processes that create results
  3. Input the outcome parameters
  4. Execute the program repeatedly to test its accuracy
  5. The conclusion of the algorithm is the result given after the parameters go through the set of instructions in the program.

For financial algorithms, the more complex the program, the more data the software can use to make accurate assessments to buy or sell securities. Programmers test complex algorithms thoroughly to ensure the programs are without errors. Many algorithms can be used for one problem; however, some simplify the process better than others. 

Advantages and Disadvantages of Algos Trading

Algorithm trading has the advantages of removing the human element from trading, but it also comes with its disadvantages.

Advantages

Perhaps the biggest benefit to algorithm trading is that it takes out the human element. With algo trading, the emotional part of trading is neutralized. The potential for overtrading is also reduced with computer trading—or under-trading, where traders may get discouraged quickly if a certain strategy doesn’t yield results right away. Computers can also trade faster than humans, allowing them to adapt to changing markets quicker.

Disadvantages

The big issue with algorithmic trading is that it relies on computers. Without power (electricity) or the Internet, algos don’t work. Computer crashes can also hamper algorithmic trading. Also, while an algo-based strategy may perform well on paper or in simulations, there’s no guarantee it’ll actually work in actual trading. Traders may create a seemingly perfect model that works for past market conditions but fails in the current market.

Pros
    • Eliminates human elements, emotions
    • Creates consistency when testing a strategy
    • Over/under trading reduced 
    • Computers adapt to price and market changes quicker
Cons
    • Doesn't work without electricity or the Internet
    • Can look good on paper but underperform
    • Over optimization is possible
    • Requires lots of data, computer power, expertise, etc.

What Algos Do Hedge Funds Use?

Hedge funds use a variety of algos and algo-based strategies. This includes using big data sets (such as satellite images and point of sale systems) to analyze potential investments. Algos and machine learning are also being used to optimize office operations at hedge funds, including for reconciliations. 

Is Algorithmic Trading Hard?

Actual algorithmic trading on the surface is easy—you implement a strategy and the computer does all the hard work. However, the hard part is putting in enough work to understand the algo, or in building an algo for trading. 

Is Algo Trading Safe?

Algo trading is relatively safe, assuming you’ve built a profitable strategy to run. Some algorithms strategies can be purchased, but they still require enough computer power to run.

Do Banks Use Algorithmic Trading?

Banks, including institutional and retail traders, use algorithmic trading. This includes investment banks and hedge funds that use algorithmic trading to perform large trade orders or ensure fast trading. 

How Do Predatory Algos Work?

Trading and investing algos can be considered predatory as they may reduce stock liquidity or increase transaction costs. However, directly predatory algos are created to drive markets in a certain direction and allow traders to take advantage of liquidity issues.