Algo trading on Forex: details about the automated trading style. Algorithms and stock trading: Hiding large trades and predicting stock prices Risks associated with algorithmic trading

The procedure for opening and closing transactions formulated by the trader, which is based on a clear algorithm for the operation of automatic or mechanical trading systems - ATS and MTS, respectively.

Specifics and application of algorithmic trading

Algo trading is a convenient opportunity to automate a trader’s routine manipulations, resulting in a reduction in the time required to analyze the stock market situation, perform operations, and perform mathematical calculations. ATS help to minimize the influence of the human factor - emotions, panic, haste, speculation, which often make even professional strategies unprofitable. Trading is based on the existing probability of quotes falling within a given range. Calculations are based on historical data regarding a specific asset and may include a whole set of working tools. Following the continuous changes in the market, algorithm developers are constantly searching for repeating models, on the basis of which they formulate rules for making transactions and select trading robots that help implement this mechanism. Methods for selecting models:

  • genetic - the creation of algorithms is entrusted to computer systems;
  • automatic - programs are used that can work with huge amounts of data and test strategies;
  • manual - the scientific approach takes into account mathematical and physical models.

Leading algorithmic trading companies use thousands of tools that significantly reduce the likelihood of errors and failures.

Types and potential

An algorithm is a set of precise instructions that achieve specific goals. Depending on the latter, there are 5 types of trading in the stock market:

  • statistical;
  • algorithmic execution trading;
  • automatic hedging;
  • direct access;
  • high frequency algorithmic trading.

The growing popularity of MTS and ATS among speculators is due to increased automation of processes, the transience of foreign exchange transactions, and reduced operating costs. Banks also began to use algorithms to provide up-to-date quotes on trading platforms, increase the speed of data updating, reduce the role of manual labor in calculating prices, and minimize transaction costs.

The essence of high frequency algorithmic trading

High-frequency algorithmic trading is also called HFT trading; it is the most popular among other forms of automated transactions. Its advantage is the ability to quickly conclude transactions with more than one instrument; here, work with positions (opening and closing) is performed in a fraction of a second. Operations are characterized by microvolumes, moreover, they are balanced by a large number of them. The results - losses and income - are recorded instantly, so a complex technical base and high-quality direct connection with communication gateways are needed. Key features of high frequency trading:

  • the use of innovative systems capable of executing positions in milliseconds;
  • carrying out high-speed transactions characterized by large volumes and the lowest possible profit;
  • exclusively intraday trading;
  • making a profit from margins and micro-fluctuations in prices;
  • use of all categories of arbitrage transactions.

The most common HFT strategies are market making, delay arbitrage and its statistical form, front running. The latter consists of searching for large purchase orders and placing your own small order, characterized by a higher price. As execution proceeds, the algorithm automatically places orders a little higher, counting on the manifestation of accompanying fluctuations. Robotic operations performed as part of algorithmic trading create about 55% of the liquidity of global stock exchanges. With the technological development of tools, the process of making a profit becomes more complicated and more expensive. Mid-level companies are gradually being forced out of the core market, as costs for modernizing the technical base and updating software are increasing.

An algorithm is a specific set of well-defined instructions designed to accomplish a task or process.

Algorithmic trading (automated trading, black box trading or simply algo trading) is the process of using computers programmed to execute a specific set of instructions to place a trade for profit at a speed and frequency that is impossible for a trafficker. Certain sets of rules are based on timing, price, quantity or any mathematical model. Apart from trading opportunities for traders, algo trading makes markets more liquid and makes trading more systematic by eliminating human emotional influences on trading activities. (For more details see Choosing the Right Algorithmic Trading Software .)

Let's assume a trader follows these simple trading criteria:

  • Buy 50 shares of a stock when its 50-day moving average exceeds its 200-day moving average
  • Sell ​​shares of a stock when its 50-day moving average goes below its 200-day moving average

Using this set of two simple instructions, it is easy to write a computer program that will automatically track the stock price (and moving average indicators) and place buy and sell orders when certain conditions are met. The trader no longer needs to monitor live prices and charts, or order manually. The algorithmic trading system automatically does this for him, correctly identifying trading opportunities. (For more on moving averages, see Simple moving averages. Trend output .)

[If you want to learn more about proven and accurate strategies that can ultimately be processed in an alorithmic trading system, check out the Investopedia Academy Online Traders Academy course.]

Benefits of Algorithmic Trading

Algo-trading provides the following advantages:

  • Trades performed at the best prices
  • Instant and accurate placement of a trade order (thus high chances of execution at desired levels)
  • Trades are timed correctly and instantly to avoid significant price changes
  • Reduced transaction costs (see example of scarcity below)
  • Simultaneous automatic checks on multiple market conditions
  • Reducing the risk of manual errors when placing trades
  • Reverse algorithm based on available historical and real-time data
  • Reducing the likelihood of traffickers making mistakes based on emotional and psychological factors

The largest part of today's algo trading is high-frequency trading (HFT), which attempts to benefit from placing large numbers of orders at very fast speeds across multiple markets and multiple decision parameters based on pre-programmed instructions. (For more on high-frequency trading, see Strategies and Secrets of High Frequency Trading (HFT) Firms .)

Algo-trading is used in many forms of trading and investment activities, including:

  • Intermediate and long-term investors or buy third-party firms (pension funds, mutual funds, insurance companies) that buy shares in large quantities but do not want to influence share prices with discrete large investments.
  • Short-term traders and sellers (market makers, speculators and arbitrageurs) benefit from automated trading execution; Additionally, algo trading helps create sufficient liquidity for sellers in the market.
  • Systematic traders (trend traders, pairs traders, hedge funds, etc.) find it much more effective to program their trading rules and let the program trade automatically.

Algorithmic trading provides a more systematic approach to active trading than methods based on the trader's intuition or instinct.

Algorithmic trading strategies

Any algorithmic trading strategy requires a certain capability that is beneficial in terms of increasing profits or reducing costs. The following are common trading strategies used in algo trading:

  • Strategies following the following strategies:

The most common algorithmic trading strategies follow trends in moving averages, channel breakouts, price level changes and related technical indicators. These are the simplest and easiest strategies to implement using algorithmic trading as these strategies do not involve forecasts or price predictions. Trades are initiated based on the appearance of desired trends, which are easy and simple to implement using algorithms, without delving into the complexity of predictive analysis. The above example of 50 and 200 day moving averages is a popular trend following strategy. (For more trading strategies, see below: Simple strategies for capitalizing on trends .)

  • Arbitration opportunities:

Buying a double list of shares at a lower price in one market and simultaneously selling at a higher price in another market offers the difference in price as a risk-free profit or arbitrage. The same operation can be replicated for equities against futures instruments as price differences exist from time to time. Implementing an algorithm to identify these price differences and place orders allows you to effectively take advantage of profitable opportunities.

  • Stock index refinancing :

Index funds have designated rebalancing periods to bring their holdings up to their respective benchmarks. This creates lucrative opportunities for algorithmic traders, who benefit from expected trades that offer profits of 20-80 basis points depending on the number of shares in the index fund, before the stock index is rebalanced. These trades are initiated using algorithmic trading systems for timely execution and best prices.

  • Strategies based on mathematical models:

A variety of proven mathematical models, such as the delta neutral trading strategy, which allows you to trade a combination of options and its underlying security, where trades are placed to offset positive and negative deltas so that the portfolio's delta is maintained at zero.

  • Trading range (average reversion):

The average reversion strategy is based on the idea that high and low asset prices are temporary phenomena that periodically revert to their mean. Defining and defining a price range and execution algorithm based on what allows trades to be placed automatically when the price of an asset breaks and moves outside of its defined range.

  • Volume Weighted Average Price (VWAP):

The current weighted average price strategy breaks up a large order and releases dynamically determined smaller chunks of the order into the market using historical inventory volume profiles. The goal is to fill the order close to the weighted average price (VWAP), thereby winning the average price.

  • Time Weighted Average (TWAP):

The time weighted average price strategy breaks up the large order and releases dynamically determined small chunks of the order to the market using evenly spaced time intervals between the start and end times. The goal is to fill the order close to the average price between the start and end times, thereby minimizing the impact on the market.

  • Percentage of Volume (POV):

Until the trade order is completely filled, this algorithm continues to send partial orders according to a certain participation rate and according to the volume traded in the markets. The associated "steps" strategy submits orders at a user-defined market share percentage and increases or decreases that participation rate when the stock price reaches user-defined levels.

  • Lack of implementation:

A sales gap strategy aims to minimize the cost of order fulfillment by trading with the market in real time, thereby saving on order costs and benefiting from the opportunity cost of delayed execution. The strategy will increase the target participation rate when the stock price moves favorably and decrease it when the stock price moves negatively.

  • In addition to the usual trading algorithms:

There are several special classes of algorithms that attempt to identify "events" on the other side. These "sniffing algorithms", used for example by a market maker on the sell side, have the built-in intelligence to identify the existence of any buy side algorithms of a large order. This detection through algorithms will help the market maker identify large order opportunities and give him the opportunity to win by filling orders at a higher price. This is sometimes called the high-tech front. (For more information on high-frequency trading and fraudulent practices, see: If you buy shares online, you are participating in HFT .)

Technical requirements for algorithmic trading

Implementing an algorithm using a computer program is the last part, filled with backtesting. The challenge is to translate the identified strategy into an integrated computerized process that accesses the trading account to place orders. The following is required:

  • Computer programming knowledge to program the required trading strategy, hired programmers or off-the-shelf trading software
  • Network connection and access to trading platforms for placing orders
  • Access to market data feeds that will be controlled by an algorithm to enable order placement
  • The ability and infrastructure to validate a system after it has been built before it reaches live markets
  • Available historical data for back-testing depending on the complexity of the rules implemented in the algorithm

AEX is traded in Euros while LSE is traded in GBP

  • Due to the difference in hours, AEX opens an hour earlier than LSE, after which both exchanges trade simultaneously for the next few hours and then only trades on LSE for the final hour when AEX closes
  • Can we explore the possibility of arbitrage trading on the Royal Dutch Shell stock markets listed in these two markets in two different currencies?

Requirements:

  • Correspondents from LSE and AEX
  • Forex exchange rate for GBP-EUR rate
  • Order placement capability that can route the order for correct exchange
  • Possibility of re-testing using historical price channels
  • The computer program must do the following:
  • Using available exchange rates, convert the price of one currency to another
  • If there is a large enough discrepancy in price (brokerage cost discounting) that results in a profitable opportunity, then place an order to buy at a lower rate to sell and sell at a better exchange > If orders are executed at will, arbitrage profits will follow
  • Plain and simple! However, the practice of algorithmic trading is not so easy to maintain and execute. Remember that if you can accommodate the trade generated by the algo, so can other market participants. Consequently, prices fluctuate in milli- and even microseconds. In the example above, what happens if your trade purchase is executed, but the sell trade is not the same as the sell prices change by the time your order hits the market? You will end up sitting with an open position, rendering your arbitrage strategy useless.
  • There are additional risks and problems: for example, risks of system failure, network connection errors, time delays between trade orders and execution, and, most importantly, imperfect algorithms. The more complex the algorithm, the more rigorous backtesting is required before it is put into use.

Bottom line

Quantitative analysis of algorithm performance plays an important role and should be examined critically. It is exciting to do automation using computers with the idea of ​​making money easily. But you need to make sure that the system is thoroughly tested and that restrictions are required. Analytical traders should consider studying the programs and construction systems themselves to ensure they are executing the right strategies correctly. Careful use and careful testing of algo trading can create profitable opportunities. (See How to Code Your Own Algo Trading Robot for more details.)

Now everyone is talking about how human consultants will be replaced by machines. How does this correspond to reality?

Robots are made by people, so someone will definitely remain alive... But seriously, let's first define what we actually call robots. There is robo-advising, there are algorithmic strategies, there is auto-following.

Let's start with robo-advising. What does this concept include?

Robo-advising is a program that allows you not only to create a portfolio for a client, but also to rebalance the portfolio without the client’s participation.

There are not many similar services in Russia, but if we talk about Western practices, There is a clear division between passive and active control:

  • active control consists of deciding which tool and when to buy;
  • passive control— when the portfolio has already been formed and is intended for clients who do not want to go into details.

Algo trading

Algotrading is understood as a type of trading in which the trader’s actions are completely formalized in the form of an algorithm, by implementing which the trader expects to make a profit. In simple words, algorithmic trading is a predetermined, conscious algorithm of a trader’s actions during trading.

What is the future of algorithmic trading in Russia? There is high interest in this service both from clients and from professional market participants.

The share of such services will grow - this is obvious.

The development of the segment poses new challenges for both the regulator and the market. There is an active discussion regarding the future of these services for individuals. A large number of people use such services, and The regulator cannot ignore this.

Advantages and disadvantages

The client needs to receive full information about the conditions of a specific strategy, including, for example, taxes, commission amounts.

At the same time, the prices at which the client makes transactions do not always coincide with the prices at which the author of the strategy makes transactions. Sometimes this leads to the client being disappointed in the service. But ultimately The market for autofollowing and algorithmic trading services should become clear to both brokers and clients.

There are two advantages: speed and low cost. Robot services are several times cheaper than consultants. Even with a modest amount of $5 thousand. you can get a balanced portfolio. But such a service will not take root in Russia. We like to “look into the eyes” of those who manage money.

Investing is a slow and careful process.

A robo-advising service is aimed at lazy speculators who want to earn money by shifting the burden of decision-making to someone else. This doesn't lead to anything good.

But the number of people who want to earn money without making independent decisions is very large. That's why Robo-advising will be in demand in any case.

The problems of robo-advising in Russia are associated with the weakness of the market itself - low, depreciation of the importance of the brand and name of the developer company, and the possibility of price manipulation.

Another problem is the number of active investors. The product will become interesting when Private Banking leaves the market. But this requires a unique service that takes into account the interests of a particular investor.

Given the widespread adoption of chatbots and the pace of development of such services, the widespread adoption of such technologies is a matter of the near future. In Russia, the main players are in a state of serious competition, introducing new products and services, and improving service.

We believe that robo-advising will soon be affordable for medium-sized and niche players who will be happy to compete for clients’ funds.

Additionally, watch a short video about what algorithmic trading is:

Traders on world exchanges from Australia to New York are trading less and less with markets and increasingly using trading algorithms. On the Moscow Exchange, more than 50% of trading volume comes from algorithmic strategies. And the share of their applications in the total volume exceeded 80%.

The one who was actively clicking the mouse yesterday has today formalized his strategy and programmed it himself or from a friend who knows C++ or Python.

Why are trading robots so popular?

The robot has no emotions: it is not happy when it earns 10% and is not upset when it loses 50%. He doesn't know what fear and greed are. A robot has a set of rules and commands that it follows. If you need to buy, the robot buys, if you need to sell, it sells. A robot can execute commands faster than a human. A robot can simultaneously monitor signals on many instruments, while a person only monitors what he sees on the monitor.

In the head of every robot there is an algorithm that was invented by a person. The most difficult thing is to come up with this algorithm. To do this, you need to analyze the data, put forward a hypothesis, formulate rules, analyze the result on historical data, adjust the hypothesis and rules, and run the algorithm again on history. To do this, you need to be proficient in mathematics and statistics and know how to apply this knowledge in financial markets.

Requirements for students:

The course "Algorithmic trading. Scientific approach" is designed for trained students who remember higher mathematics, which is taught in economic universities. The course will not contain dry theory, but a little bit of “liquid theory” and a lot of “thick practice” using the example of several trading strategies that have been working for 10 years.

How does this course differ from previous ones:

The first lecture of the course systematically and without complex formulas sets out the principles of constructing trading algorithms, which will allow anyone to understand them and apply them in practice when constructing their own algorithms “at random”.

Alexander also abandoned a separate section on the basic concepts of probability theory and mathematical statistics, limiting himself to recalling definitions as they became necessary in the material.

A number of mathematical results of purely theoretical interest were excluded from the course, and only the results that were used by Alexander in constructing his own trading algorithms were retained, the presentation of which is still the subject of the last three lectures of the course.

Video course program

Lesson 1. Principles of constructing trading algorithms and necessary concepts of probability theory and mathematical statistics

  • Let's find out what randomness or determinism is
  • Let's learn about probability, as a measure of the numerical assessment of the chances of future events occurring.
  • We discover a trading algorithm as a statistical forecast of future price increments
  • We study one-dimensional random variables:
    • distribution function
    • mathematical expectation of a function of a random variable
    • quantiles (percentiles)
    • stochastic dominance
  • We define what a binary model of price increments is, trend and countertrend, optimal algorithm
  • We study multidimensional random variables:
    • independence
    • conditional distributions
    • statistical forecast problem
    • regression
  • Let's learn how to select indicators for the trading algorithm "at random"
  • Let us recall the sequences of random variables:
    • stationarity
    • autocorrelation and spectral functions
    • random walk
    • Hurst exponent (criticism)
  • We use mathematical statistics:
    • sample
    • sample statistics
    • sufficient statistics
    • distinguishing hypotheses
    • parameter estimation
    • parametric and nonparametric statistics

Lesson 2. Testing and optimization of trading algorithms, as a test of the quality of a statistical forecast of future price increments

  • We evaluate the share of “successes”
  • We reduce the autocorrelation function of counting dynamics to zero form
  • We filter out the parameters by:
    • sustainability
    • stochastic dominance
    • cross correlation
    • superiority of the “return-risk” of a passive strategy
  • We build an optimal portfolio from:
    • one trading algorithm with different parameters
    • several trading algorithms on one asset
    • portfolios of trading algorithms on different assets
  • We estimate future account drawdowns using the Monte Carlo method

Lesson 3. Practical lesson on testing trading algorithms

  • We use the acquired knowledge in practice

Lesson 4. Price models as the basis of trading algorithms

  • We analyze the competitive market, conditional normality, “piecewise” stationarity
  • We study the piecewise constant conditionally normal model, trends, minimax trend model
  • We recall the piecewise Markov conditionally normal model, trends and countertrends
  • Let's learn about the strongly “anti-persistent” model and step trends

Lesson 5-6. Examples of trend trading algorithms

  • We build models for a piecewise constant conditionally normal model
  • We consider models for a strongly “anti-persistent” model

Lesson 7. Filtering trend trading algorithms and examples of counter-trend trading algorithms

  • We analyze minimax trend models
  • We study the history of real trade and modification
  • Selecting trending trading algorithms
  • Piecewise Markov conditionally normal model as the basis for constructing a “saw filter”
  • “Filters” of shorts and shoulders, principles of construction, features of use
  • Let's look at examples of countertrend trading algorithms
  • “Saw filter” as an indicator of countertrend trading within the binary model of price increments
  • Maximum profit system for options (optional)

Algorithmic trading is an interesting field that allows IT professionals to apply their technical knowledge to the stock market and benefit from it. In our blog, we have repeatedly discussed various topics related to the creation of trading robots, but we have not paid enough attention to the theoretical issues that novice traders face.

Our material today contains a selection of books that will help you better prepare for starting to work in the stock market and writing mechanical trading systems. To achieve the greatest effectiveness of the material, we provide advice from experts who are engaged in algorithmic trading on Russian and foreign stock markets.

Michael Hulls-Moore, Quantitative trading expert (quote from blog post)

I believe that before one understands the basic concepts of stock trading and algorithmic trading, one should avoid diving into complex mathematics. In my opinion, the following books are good for learning the basics:

Due to my occupation, I read quite specific literature, mainly related to complex models of mathematical statistics. And since this topic is not very developed in the Russian Federation, my literature is mainly in English.

Of the more “popular” books in the genre, I read “Long-term secrets of short-term trading”, but never applied any of the ideas listed there in practice.

To all novice traders (no matter algorithmic or “simple”), I would recommend reading Nassim Taleb, especially the book “ Fooled by Randomness” - it is subtle, but it makes you look at many things in a new way.

From what really helped me, I can recommend the following materials:

  • Moscow Exchange manuals on futures and options (