Fundamentals of Algorithmic Trading: Concepts and Examples

Algorithmic trading (also known as automated trading, black box trading, or algorithmic trading) uses a computer program that follows a defined set of instructions (algorithms) for trading. In theory, this type of transaction can generate profits at a speed and frequency that human traders cannot match.

The defined instruction set is based on time, price, quantity or any mathematical model. In addition to profit opportunities for traders, algorithmic trading eliminates the influence of human emotions on trading activities, making the market more liquid and trading more systematic.

Algorithmic trading in practice

Assume that the trader follows the following simple trading standards:

  • When the 50-day moving average is higher than the 200-day moving average, buy 50 stocks. (The moving average is the average of past data points, which can eliminate daily price fluctuations and determine the trend.)
  • Sell ​​the stock when its 50-day moving average is below the 200-day moving average.

Using these two simple instructions, the computer program will automatically monitor the stock price (and the moving average indicator) and place buy and sell orders when the defined conditions are met. Traders no longer need to monitor real-time prices and charts or place orders manually. Algorithmic trading systems automatically perform this operation by correctly identifying trading opportunities.

Fundamentals of Algorithmic Trading

Benefits of algorithmic trading

Algorithmic trading provides the following benefits:

  • The transaction is executed at the best possible price.
  • The placing of trading orders is instant and accurate (it is likely to be executed at the required level).
  • The trading time is correct and instant to avoid major price changes.
  • lower the transaction cost.
  • Automatically check multiple market conditions at the same time.
  • Reduce the risk of manual errors when trading.
  • You can use the available historical and real-time data to backtest algorithmic trading to see if it is a viable trading strategy.
  • Reduce the possibility of human traders making mistakes based on emotional and psychological factors.

Most algorithmic trading today is high-frequency trading (HFT), which attempts to quickly place a large number of orders in multiple markets and multiple decision parameters based on pre-programmed instructions.

Algorithmic trading is used in various forms of trading and investment activities, including:

  • Mid- to long-term investors or buying companies-pension funds, mutual funds, insurance companies-use algorithmic trading to buy stocks in large quantities when they do not want to influence stock prices through discrete large-scale investments.
  • Short-term traders and seller participants-market makers (such as brokerage companies), speculators and arbitrageurs-benefit from automated trading execution; in addition, algorithmic trading helps to create sufficient liquidity for sellers in the market.
  • System traders-trend followers, hedge funds, or pair traders (a market-neutral trading strategy that associates a long position with a pair of highly correlated instruments (such as two stocks, exchange-traded funds (ETF), or currencies) Match their short positions) — found that it would be more efficient to program their trading rules and let the program automatically trade.

Compared with the method based on the trader’s intuition or instinct, algorithmic trading provides a more systematic method for active trading.

Algorithmic trading strategy

Any algorithmic trading strategy requires a certain opportunity to be profitable in terms of increasing profits or reducing costs. The following are commonly used trading strategies in algorithmic trading:

Trend tracking strategy

The most common algorithmic trading strategies follow the trend of moving averages, channel breakthroughs, price level changes and related technical indicators. These are the simplest and simplest strategies implemented through algorithmic trading, because these strategies do not involve making any predictions or price predictions. Trading is initiated based on the emergence of an ideal trend and can be easily and directly implemented through algorithms without the complexity of predictive analysis. Using 50-day and 200-day moving averages is a popular trend following strategy.

Arbitrage opportunities

Buying dual-listed stocks at a lower price in one market while selling them at a higher price in another market provides a price difference as a risk-free profit or arbitrage. Since price differences exist from time to time, the same operations can be replicated for stocks and futures instruments. Implementing algorithms to identify such price differences and effectively placing orders can provide profit opportunities.

Index fund rebalancing

Index funds define the period of rebalancing so that their holdings are equal to their respective benchmark indexes. This creates profit opportunities for algorithmic traders, who use expected trading to provide 20 to 80 basis points of profit, depending on the number of stocks in the index fund before the index fund rebalances. This type of transaction is initiated through an algorithmic trading system in order to execute in time and obtain the best price.

Strategies based on mathematical models

Proven mathematical models, such as delta neutral trading strategies, allow trading of combinations of options and underlying securities. (Delta neutral is a portfolio strategy consisting of multiple positions, which offsets positive and negative deltas—the ratio of changes in asset prices, usually securities, to the corresponding changes in the price of their derivatives—such The total delta of the overall related assets is zero.)

Trading range (mean reversion)

The mean reversion strategy is based on the concept that the high and low prices of assets are a temporary phenomenon that will periodically return to their mean value (average value). Identify and define the price range and implement algorithms based on it to allow automatic trading when the asset price enters and exceeds its defined range.

Volume weighted average price (VWAP)

The volume-weighted average price strategy breaks down large orders and releases them to the market using smaller order blocks dynamically determined using stock-specific historical volume profiles. The purpose is to execute orders close to the volume weighted average price (VWAP).

Time Weighted Average Price (TWAP)

The time-weighted average price strategy breaks down large orders and uses the equally divided time period between the start time and the end time to determine the smaller order block to the market dynamics. The purpose is to execute orders close to the average price between the start and end time, thereby minimizing market impact.

Percent by volume (POV)

Before the transaction order is completely filled, the algorithm will continue to send some orders based on the defined participation rate and market transaction volume. The related “step strategy” sends orders at a user-defined percentage of market volume and increases or decreases the participation rate when the stock price reaches a user-defined level.

Under-implemented

The execution gap strategy aims to minimize the execution cost of orders through the trade-off of real-time market conditions, thereby saving order costs and benefiting from the opportunity cost of delayed execution. This strategy will increase the target participation rate when the stock price is favorable, and reduce the target participation rate when the stock price is unfavorable.

Go beyond the usual trading algorithms

There are special categories of algorithms that try to identify “events” on the other end. These “sniffing algorithms” (for example, used by seller market makers) have built-in intelligence to identify whether there are any algorithms for large order buyers. Such detection through algorithms will help market makers identify large order opportunities and enable them to benefit by filling orders at higher prices. This is sometimes considered a high-tech lead. Generally, depending on the circumstances, the practice of preemptive transactions may be considered illegal and subject to strict supervision by FINRA (Financial Industry Regulatory Authority).

Algorithmic trading technical requirements

The use of computer programs to implement algorithms is the last component of algorithmic trading, accompanied by back-testing (try the algorithm in past historical periods of stock market performance to see if it will be profitable to use it). The challenge is to convert the determined strategy into an integrated computerized process that can access the following orders on the trading account. The following are the requirements for algorithmic trading:

  • Computer programming knowledge to write the required trading strategies, hired programmers or pre-made trading software.
  • Internet connection and access to the trading platform for the following orders.
  • Access market data feeds that will be monitored by algorithms to get an opportunity to place orders.
  • The ability and infrastructure to back-test the system after it is built and before it runs on the actual market.
  • The historical data available for backtesting depends on the complexity of the rules implemented in the algorithm.

An example of algorithmic trading

Royal Dutch Shell (RDS) is listed on the Amsterdam Stock Exchange (AEX) and the London Stock Exchange (LSE).We first build an algorithm to identify arbitrage opportunities. Here are some interesting observations:

  • AEX is traded in Euros, while LSE is traded in British Pounds.
  • Due to the one-hour time difference, AEX opened one hour earlier than LSE, and then the two exchanges traded at the same time in the next few hours, and then only traded on LSE during the last hour when AEX was closed.

Can we explore the possibility of arbitrage trading of Royal Dutch Shell stocks listed on these two markets in two different currencies?

Require:

  • A computer program that can read current market prices.
  • Price information from LSE and AEX.
  • The foreign exchange (foreign exchange) exchange rate for GBP-EUR.
  • The order can be routed to the correct exchange’s order placement function.
  • Backtesting ability of historical price feedback.

The computer program should do the following:

  • Read incoming prices of RDS stocks from two exchanges.
  • Use the available foreign exchange rates to convert the price of one currency to the price of another currency.
  • If there is a large enough price difference (discounted brokerage costs) that leads to profit opportunities, then the program should place a buy order on a lower price exchange and a sell order on a higher price exchange.
  • If the order is executed as expected, arbitrage profits will follow.

Simple and easy! However, the practice of algorithmic trading is not so easy to maintain and execute. Remember, if an investor can make algorithm-generated transactions, so can other market participants. Therefore, prices fluctuate in milliseconds or even microseconds. In the above example, if a buy transaction is executed but a sell transaction is not executed because the selling price changes when the order enters the market, what will happen? Traders will leave open positions, making arbitrage strategies worthless.

There are other risks and challenges, such as the risk of system failures, network connection errors, time delays between trading orders and execution, and most importantly, imperfect algorithms. The more complex the algorithm, the more rigorous backtesting is required before it can be implemented.

.

READ ALSO:   Write your own algorithmic trading robot
Share your love