Algorithmic trading. Soulless Expert Advisors - robo-advising and algorithmic trading: the future of new technologies Algorithmic and automated trading
New York University mathematics professor and financial market expert Marco Avellaneda made a presentation in which he talked about how large investors “hide” their large transactions using algorithms, while other traders predict changes in stock prices.
In our today's material - the main points of this work.
Why do we need algorithms
Algorithmic trading has been a tool for large investors and hedge funds since its inception in the early 90s of the last century. Decimalization (transition on the New York Stock Exchange to use in stock trading on a decimal system - the minimum price step became equal to 1 cent, not 1/16 of the dollar), Direct Market Access (DMA) technologies, 100% electronic exchanges , the reduction in commissions of exchanges and brokers, the emergence of various exchange platforms in the US and in other countries - all this has led to an explosive growth in the number of traders using algorithms.Avellaneda describes the goals of using algorithms in stock trading as follows. According to the professor, in the case of large institutional investors, they are mainly used not to maximize the possible profit from a particular transaction, but to control market risk and order execution costs.
Simply put, usually large investors need to transact with a large volume of shares. Often the volume of the transaction is higher than the market can "digest" without changing the share price. The need to make a purchase of a huge number of shares will lead to a change in their price and the appearance of the so-called "slippage". Thus, it will not be possible to execute the entire order at one price - at first, transactions will take place at the right price, but gradually it will become less and less profitable.
To avoid this, it is necessary to break large orders into smaller ones, which are executed via the Internet within minutes, hours or days.
To make this as profitable as possible, the algorithm must control the average price of a share. You can evaluate it by comparing it with the market "benchmark" - the global average price per day, the closing or opening price, etc.
But the problem of determining exactly how to break a large order into smaller ones is not the only one. The algorithm must also decide how to market the order - as a limit or market order - and at what price. It is necessary to achieve the best price for each such child order.
The development of financial markets and the emergence of new trading instruments have made this task much more complex and interesting.
Gone are the days when clients could only submit orders to their brokers by phone or fax. Now there are different ways to connect to electronic trading. For example, it is possible to connect a trading robot to a brokerage system using the API - in this case, orders are sent to the brokerage system, and from there they go to the exchange (ITinvest has its own SmartCOM API).
In the case of algorithmic trading, as a rule, the speed of the strategy is important, so many traders prefer to use direct market access technology (DMA - ITinvest provides such access to Russian and foreign exchanges). If it is used, the trading robot interacts directly with the trading system of the exchange, bypassing the broker's system, which allows you to gain time.
But this is far from the most difficult trading option. The emergence of a large number of different trading platforms has led to the development of algorithms for "smart routing" of orders - such systems not only try to make the most profitable transactions on a particular exchange, but also analyze which of the available sites is currently better in order to send the order there .
Thus, there are three levels of development of modern algorithms.
- Macro trading algorithms- determine the trading strategy;
- Microtrading Algorithms- in fact, trading "engines" for placing orders;
- Smart Routing Algorithms- if the work is carried out on several exchanges at the same time.
Examples of trading algorithms
There are several types of algorithmic strategies. One of them is execution strategies that are aimed at solving the problem of buying or selling a large volume of a financial instrument (for example, shares) with a minimum deviation of the final weighted average transaction price from the current market price.Examples of algorithms that solve this problem are the TWAP and VWAP algorithms.
TWAP algorithm
The use of TWAP (Tie Weighted Average Price - time-weighted average price) implies a uniform execution of an order to buy or sell for a given number of iterations within a given period of time. To do this, market orders are constantly placed at the prices of the best bid or offer, adjusted for a given percentage deviation.For example, buying 100,000 shares in a day might look like this (five-minute consecutive intervals are used):
VWAP algorithm
VWAP (Volume weighted average price - volume-weighted average price) works according to the following scheme. The trading volume is usually higher at the beginning and end of the trading session, and in its middle it is less. In order to execute a large order with minimal costs, it is broken down into smaller orders, taking into account the time of day.For this:
- The algorithm estimates the average trading volume at five-minute intervals.
- Within each interval, transactions are carried out for the number of instruments proportional to the standard volume.
Percent Volume (POV)
The Percentage of Volume (POV) algorithm solves the same problem as VWAP, but using information about the volume of trading on a specific current day as a benchmark. The idea is to have a constant percentage of participation in the auction throughout the selected period.If it is necessary to “trade” more shares of volume Q, and the “participation coefficient” in trades is γ, then the algorithm calculates the volume of trades V traded in the period (t – ΔT, t) and executes orders for the number of financial instruments q = min(Q,V *γ).
V(t) = total trading volume that took place on the market at time t;
Q(t) = number of shares still to be bought/sold (Q(0) = initial quantity).
How else are algorithms used?
In addition to execution strategies, there are a number of strategies aimed at making profit using other models. Here is some of them:- Arbitrage Strategies- a subset of pair trading strategies that are based on the analysis of the price ratios of two highly correlated financial instruments. In the case of arbitrage, such a pair consists of the same or related assets, the correlation of which is close to one - for example, shares of the same company on different exchanges. For successful trading within arbitrage strategies, the speed of obtaining data and placing/changing buy or sell orders is critical.
- Providing liquidity (market making)- market making involves maintaining spreads for buying and selling a financial instrument. Market makers are the main providers of instant liquidity, so exchanges often involve them in working with illiquid instruments by providing preferential terms.
- Price Prediction- strategies that analyze various data (including using technical analysis indicators) to build hypotheses about which direction the price of a financial instrument can move in a given period of time.
Price Prediction in High Frequency Trading
In order to "predict" the price movement, the algorithm must simulate the hidden liquidity of the market given the liquidity of buy and sell orders. The "depletion" of the queue of orders to buy or sell may indicate an imminent price movement.A price change occurs when all orders to buy or sell disappear at one of the price levels, and the next bid and ask price level exists.
The probability that the ask queue runs out before the bid queue is depleted is calculated as follows:
The final formula for the probability of a price increase:
Where H is the hidden liquidity of the market, that is, transactions that are not known to the general public (for example, transactions of large financial organizations that are concluded outside the exchanges).
The evaluation procedure is as follows:
- At the first stage, the collected data is divided by exchanges, one trading day is analyzed at a time;
- Quotes of bid and ask values are arranged by deciles. For each such set (i,j), the price increase frequency u_ij is calculated.
- The number of occurrences of each value d_ij is counted.
- The model fit is analyzed using the least squares method:
Conclusion
On many stock exchanges (for example, in the USA and Russia), the turnover of algorithmic trading has been more than 50% for quite some time. At the same time, algorithms are often used not only to “get ahead” of competitors in the speed of transactions and make money on it.Large players can use this tool to break large transactions into smaller ones, which allow you to carry out a transaction with a given amount of a financial instrument without shifting its market price in one direction or another. For this, TWAP, VWAP and PoV algorithms are used.
In addition, algorithms are used to implement "quantum strategies" such as arbitrage or market making. In addition, there are opportunities to calculate the probability of a change in the price of specific financial instruments.
That's all for today, thank you for your attention!
The use of algorithms in trading (algo trading) is a trend of recent decades that has changed the market in many ways. Any automatic system can easily surpass a person in speed, productivity and endurance, while it will be almost impossible to compete with a machine.
The content of the article:
What is algorithmic trading, its features and use in various markets - further.
What is algorithmic trading (algorithmic trading)
Algorithmic trading (from English Algorithmic trading) can have two meanings:
- Algo trading- this is an automatic system that opens deals without the participation of a trader within the framework of a given algorithm;
- is a technique for executing a large order on the market, when it is automatically divided into parts and opened gradually according to the specified rules.
In the first sense, algorithms are needed to directly make a profit by automatically analyzing the market and opening positions. Such algorithms are also called " trading robots" or " advisers". The last name came from the Forex market.
In the second case, the system is used in order to facilitate the manual labor of traders in investment funds when making excessively large transactions that it is desirable to make less noticeably. For example, if the task is to buy 100,000 shares of the company, and you need to open positions 1-4 shares at a time, so as not to attract attention in the feed and order book.
About what algorithmic trading is, he writes:
“Algorithmic trading, or Algorithmic trading, is a method of executing a large order (too large to be executed at once), when, using special algorithmic instructions, a large order (parent order) is divided into several sub-orders (child orders). ) with its price and volume characteristics, and each of the sub-orders is sent to the market at a certain time for execution. Such algorithms were invented so that traders do not have to constantly monitor quotes and manually divide a large order into small ones.“
The main form of algorithmic trading is HFT trading (from English. High-frequency trading - "high-frequency algorithmic trading"). Its essence lies in making transactions in a fraction of a second. In other words, such systems use their main advantage - speed.
The essence of algorithmic trading
Quantum ( quants) traders, or as they are also called - algorithmic traders, use only the theory of the probability of prices falling into the desired range. Calculations are made on the basis of the previous price range, or several financial instruments. It is important to understand that the rules can change as market behavior changes. Algo traders are constantly looking for market inefficiencies, recurring patterns in the history of quotes and calculate the likelihood of their repetition in the future. Thus, the essence of algorithmic trading is in the selection of rules for opening positions and families of robots. This selection could be:
- manual- performed by the researcher on the basis of mathematics and physical models;
- automatic- needed for mass enumeration of rules and testing within the framework of the program;
- genetic- in this case, the rules are developed by a program with elements of artificial intelligence.
The rest of the ideas and utopias about algorithmic trading are just fiction, even a robot cannot predict the future with a guarantee. The market also cannot be so inefficient that there is one set of rules for a robot that works everywhere and always.
In such large investment companies as Renaissance Technology, Citadel, Virtu that use algorithms, there are hundreds of families (series) of trading robots, covering thousands of instruments. It is this approach that gives them daily profit, this is a kind of diversification of algorithms.
When and how did algorithmic trading appear
The official beginning of the use of algorithms is 1998, when SEC (Securities Commission) in the United States allowed the use of electronic platforms. After that, a real technological race started.
Key points:
- 2000s- the time of making automatic transactions in a few seconds, the share of robots in the US market is less than 10%;
- 2009 - transactions are carried out at a speed faster than a millisecond (fractions of microseconds), the market share is over 60%;
- 2012 and a later period - due to massive erroneous actions of algorithms, their market volume decreased to 50% of all transactions.
Thus, HFT algorithms are used to this day. Investment banks and hedge funds are the pioneers in this field, and they need to automate the execution of large orders more than anyone else. They successfully invested a lot of money in the development of such algorithms, as a result of which various systems appeared that influenced the market.
Algorithmic trading in the stock market
The stock market, as well as the derivatives market, open up wide opportunities for using automatic trading. However, algorithmic trading is more common in large funds than among private investors. There are several types of algorithmic trading in the stock market:
- Systems based on technical analysis- imply the use of market inefficiencies and the identification of trends using several indicators. In most cases, such strategies are aimed at extracting profits through the techniques of classical technical analysis.
- Pairs and Basket Trading- in such a system, a ratio of two or more instruments is used, which have a relatively high percentage of correlation, but not equal to one. Accordingly, if one of the instruments deviated from the set course, then it is highly likely that it will return to its group. By tracking such deviations, the algorithms carry out transactions and bring profit to their owners.
- Market making- a different kind of strategies aimed at maintaining market liquidity. Market makers satisfy the demand for various instruments even against their own benefit, for which they receive a reward from the exchange. However, this does not prevent such algorithms from profiting with a special strategy based on a fast flow and taking into account market data.
- front running- within the framework of such systems, the analysis of the volume of transactions for the instrument and the identification of large orders are used. The algorithms take into account that a large order will hold the price and provoke the appearance of counter transactions in the opposite direction. Thus, they catch fluctuations due to the speed of analyzing market data in order book and tape, trying to overtake other participants and taking small movements during the execution of very large orders.
- Arbitration- trade in financial instruments, the correlation between which is close to one. Usually, the deviation in such instruments is minimal, it can be a stock and a futures of the same company or the same stocks, but in different markets. The system monitors the price changes of related instruments and makes arbitrage deals that equalize the price.
- Volatility trading- the most difficult type of trading, based on the purchase of options of various types, with the expectation that the volatility of a particular instrument will increase. Such algorithmic trading requires high computing power and a team of specialists.
The main algorithmic trading strategies in the stock and futures markets have been listed above. Now consider the features associated with the currency.
Algorithmic Forex Trading
The use of automatic robots has become widespread in the interbank foreign exchange market. In particular, trading advisors have earned popularity thanks to the platform MetaTrader 4 and programming language MQL4, which allows even novice traders to conduct algorithmic Forex trading:
- the use of this language is within the power of an ordinary user, as a result, there is algorithmic trading for beginners in the reference book with a full description of the functions of the language;
- programmed Expert Advisors can be immediately compiled into the terminal format and put into operation;
- the created robots do not require large computing power, a stationary computer is enough;
- a wide range of tools for testing the robot over a long time interval is available in the terminal.
Thus, MetaTrader and MQL4 will be a great opportunity for beginners to try their hand at programming real algorithmic trading robots.
Poll: What type of trading do you prefer?
Poll Options are limited because JavaScript is disabled in your browser.
Position trading 17%, 24 vote
Overview of programs for algorithmic traders
There is a small list of software for algorithmic trading and writing code for robots.
TSLabTSLab is a domestic software in C# language, compatible with most Forex and stock brokers. It has a fairly simple and easy-to-learn interface thanks to special flowcharts.
You can use the program for free, test and optimize systems, but for real trading you will need to buy a subscription.
A program for developing algorithms in C#. With this program, you can write software for algorithmic trading using the Wealth Script library, which greatly simplifies the process of writing code. You can also connect quotes from various sources to the software. In addition to backtesting, it is also possible to launch on the financial markets for real trading.
R Studio- more advanced software for quants (not suitable for beginners). This software combines several languages, one of which uses a special R language for data processing and time series. In the program, you can not only create algorithms, but also test, optimize, create interfaces, get statistics and many other data. The R Studio program is free and quite serious, it describes complex mathematical and econometric models in a few lines, thanks to various built-in libraries, testers, models, etc.
TWAP (from English. Time Weighted Average Price - "time weighted average price") - such an algorithm opens orders at regular intervals at prices with the best bid or offer.
VWAP (from English. Volume Weighted Average Price) - is needed to evenly open a position in equal parts of a certain volume during a specific time, as well as at prices not higher than the weighted average from the moment of launch.
iceberg- used to place requests with a total volume not higher than the quantity specified in the parameters. On many exchanges, the algorithm is built into the core of the system, which allows you to specify the “visible” volume in the order parameters.
Execution Strategy- required to buy an asset at a weighted average price in large volume, usually used by large players (hedge funds and brokers).
Speculative strategy- a standard model for private traders, which seeks to achieve the most favorable price for entering a transaction in order to receive subsequent profit.
data mining is a search for new patterns for new algorithms. More than 75% of the mining date falls on the collection of data before the start of testing. The result of the search depends only on a professional and deep approach. The search itself is carried out by various algorithms for manual settings. For example, the Stock Pattern Viewer software - here you can upload quotes and find certain candlestick patterns (and not only candlestick patterns), after which a given market reaction occurs. For example, find a pattern after which the market rose 2000 times over three candles and fell only 200 times. After that, the found patterns are built into the algorithms of trading robots and successfully (or not so) traded.
Training and books on algorithmic trading
The scope of training and literature on automated trading is quite narrow. It is quite difficult to single out reliable and high-quality specialized studies. Usually it comes down to learning:
- mathematical models and economic modeling;
- programming languages - Python, C++, MQL4 ( for Forex);
- information about contracts on the exchange and features of instruments (stocks, options, futures).
Still, good books on algorithmic trading should be highlighted:
Barry Johnson and his book Algorithmic trading and direct access to the exchange» (Algorithmic Trading & DMA, Barry Johnson).
Ernest Chan « Quantum trading» (Quantitative Trading, Ernest Chan).
Lyu Yu-Dau « Methods and algorithms of financial mathematics» (Financial Engineering and Computation, Yuh-Dauh Lyuu).
Rishi Narang"Inside the Black Box" (Rishi K. Narang)
It is worth noting that most of the relevant literature in this area is in English. In Russia, the direction is still slightly developed. In addition to books with a bias in programming, it will be useful to read any exchange literature, in particular, on technical analysis.
Advantages and disadvantages of algorithmic trading
Algo trading can only be considered from the standpoint of opposing manual trading. Therefore, the disadvantages of hand trading will be the advantages of algorithms, and vice versa. So, the disadvantages of classic manual trading:
- Lack of knowledge and proper understanding of the market. This applies to the vast majority of beginners, not professional traders. 95% of people lose money trading hands, as a result, this fact cannot be missed.
- Psychology and non-systematic. A person by nature is prone to breakdowns, excitement and other emotional outbursts. Trading is a very psychologically expensive activity, it is difficult for people to follow their own system strictly, as it should be. The result is lost money.
- Physiological Limitations. People cannot follow the market 24/7 because they have to eat, sleep and rest.
- The Influence of Personal Characteristics on Trading Results. Unfortunately, each trader must have his own trading system that suits him specifically. It rarely happens that a whole group of people quietly trades on the same system. For the same strategy, two traders will always trade differently.
Accordingly, all of the above disadvantages are absent in algorithms and robots. They do not have physical limitations, are not subject to emotional breakdowns and personality traits, strictly follow their system (algorithm).
However, robots are also imperfect, let's pay attention to their shortcomings:
- The probability of error in the algorithm. If the robot developer makes an inaccuracy or other flaw in the code, the robot will still continue to work and lose money.
- Complexity of algorithms. To compile and program a robot, you need to understand not only the code (program language), but also trading itself. In general, this is a rather complicated procedure, and it requires considerable experience.
- Lack of information. It is almost impossible to learn algorithmic trading from any books or courses, information is simply not freely available.
- Lack of flexibility. It will be easier for a manual trader to adapt to changes in the market than for an algorithmic trader to rebuild the entire algorithm of the robot.
Thus, robots have their problems, but they are less significant than the disadvantages in manual trading, which lead most to huge losses in the financial markets. But not everything is so simple, in practice it often turns out that algorithmic trading brings losses. A clear example is Barclay's Systematic Trader Index
The chart shows that from 2010 to 2013, system traders were in a drawdown and lost a lot. The picture becomes clear when looking at the following chart, which is similar but only for manual (non-system) traders:
As you can see, they have been able to adapt to the market and are more stable than algorithms. After analyzing both graphs, you can see that in general, both approaches give approximately the same result. Therefore, the choice of trading style is a personal matter for everyone. For example, if you are not strong in programming, and the code is boring, then it is better not to mess with algorithms, but to work manually, and vice versa.
Famous myths about algorithmic trading
Automated trading causes a serious resonance among traders, in connection with which many myths about algorithms have appeared. Let's pay attention to some of them:
- Algorithmic trading does not give profit and is a scam. Unfortunately, many are subject to this opinion, especially those who have experienced the purchase of Expert Advisors that did not justify the investment. This is refuted by the above index of profitability of algorithmic traders who have been earning money for 20 years.
- Trading is psychology, not system trading for robots. As already noted, the market has inefficiencies, and there are algorithms to identify them.
- System testing not working. Many people say that back testing on history does not give any benefit, since the robot will lose anyway on a real account. This is also a delusion, if you approach the testing process correctly, taking into account all the features and nuances, then it plays an important role.
- Martingale systems and order grids are the only way to make money. They can really make a profit, but not for long. Such profitability is extremely unstable, and will certainly lead to a drain.
- Indicators don't work. Another misconception, indicators were created to help the trader visually gauge price action, not blindly rely on them. Therefore, with a reasonable approach, they will definitely give results.
The list is not exhaustive, these are only the most famous myths.
Conclusion
What is algorithmic trading on exchanges? Algo trading is trading using automated programmed systems to open trades. It can be used to extract profit from the market or to reduce the manual burden on the trader when opening a very large position.
There are different algorithmic trading strategies. It can be arbitrage or pair trading, as well as many other variations. This style of trading is available both on the stock exchange and on the Forex currency market.
If you find an error, please highlight a piece of text and click Ctrl+Enter.
The procedure for opening and closing transactions formulated by a trader, which is based on a clear algorithm for the operation of automatic or mechanical trading systems - ATS and MTS, respectively.
Specificity and application of algorithmic trading
Algorithmic trading is a convenient way to automate the daily manipulations of a trader, as a result, the time required to analyze the exchange situation, perform operations, and perform mathematical calculations is reduced. 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 into a given range. Calculations are based on historical data regarding a particular asset, and may include a whole set of working tools. Following the continuous market changes, algorithm developers are constantly looking for repeating models, on the basis of which they formulate the rules for making transactions, select trading robots that help implement this mechanism. Model selection methods:
- 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 to achieve specific goals. Depending on the latter, 5 types of trading are distinguished in the stock market:
- statistical;
- execution algorithm trading;
- automatic hedging;
- direct access;
- high-frequency algorithmic trading.
The growing popularity of MTS and ATS among speculators is due to an increase in process automation, the transience of foreign exchange transactions, and a reduction in operating costs. Banks also began to use algorithms to provide up-to-date quotes on trading floors, increase the speed of data updates, reduce the role of manual labor in pricing, and minimize transaction costs.
The essence of high-frequency algorithmic trading
High-frequency algorithmic trading is also called HFT trading, it is the most demanded among other forms of automated transactions. Its advantage is the ability to quickly conclude deals with more than one instrument, here work with positions (opening and closing) is performed in a split second. Operations are characterized by microvolumes, moreover, they are balanced by their large number. The results - losses and incomes - are fixed instantly, so a complex technical base and high-quality direct connection with communication gateways are needed here. Key Features of High Frequency Trading:
- the use of innovative systems capable of executing positions in milliseconds;
- implementation of high-speed transactions, characterized by large volumes and the lowest possible profit;
- exclusively intraday trading;
- profit from margin and price micro-fluctuations;
- 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 in searching for large bids for the purchase and placing your own small, characterized by a higher price. As the execution progresses, the algorithm automatically places orders a little higher, counting on the manifestation of accompanying fluctuations. Robotic operations performed as part of algo trading create about 55% of the liquidity of the world's 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 squeezed out of the core market, as the costs of modernizing the technical base and updating software are increasing.
Very often, algorithmic speculative strategies are used, the purpose of which is not to sell an asset, but to profit from fluctuations in the price of a trading instrument. Unlike execution strategies, which aim to sell a large amount of assets as quietly as possible for their own purposes, while not affecting market prices, speculative strategies often contribute to market intervention in order to obtain additional profit. There are 8 main groups of speculative strategies. However, some groups of speculative strategies are based on other groups, or act as derivatives of them.
Speculative Market Making Strategies (market- making)
In fact, the Market Maker strategy involves intervention in the market, and obtaining additional profit from this. According to the Market-making strategy, a large institutional participant in the financial market puts up large positions (from hundreds of thousands to millions and even billions of dollars) both for buying and selling at the same time. Simultaneous placement of opposite positions does not bring profit (in fact, this is locking), and in itself does not affect the change in the price of an asset, but only increases the volume of trade in the market. Thus, market makers help maintain high liquidity of financial assets. Moreover, exchanges and OTC organizations are interested in market makers on illiquid assets, where they are attracted by offering preferential trading conditions, and sometimes “turning a blind eye” to their intervention in the market.
The intervention of market makers in the market is as follows.
When the price of an asset starts to rise, the market maker closes partially or completely the buy position, thus moving the price down. When the price collapses, having earned on the sell position, the market maker can close the sell position, moving the price back up. In this way, the market maker can know exactly when a trend reversal will occur, allowing them to place additional positions and earn additional profits. About that, you can read in a separate article.
"Trend-following" speculative strategies (Trend following)
These strategies are based on the simple principle of trend following. Algorithmic trading on speculative trend-following strategies uses various technical analysis indicators to obtain trading signals ( it should be noted that large institutional market participants use indicators of their own design, which you will not find available for an ordinary trader). The advantage of trend-following strategies is their versatility, as they can be used on any type of trading assets and on any timeframes.
Influence on the market, when using trend-following speculative strategies on the part of institutional market participants, can be expressed in an increase in the trend: if a participant opens a large position along the trend, he thereby increases demand, which moves the price even further.
Speculative Pair Trading Strategies
Speculative pair trading strategies work on the ratios of trading instruments with high cross-correlation, such as, for example, gold mining stocks and gold futures.
The principle of the pair strategy is as follows:
Two correlated (interrelated) assets are selected, let's say gold and shares of gold mining companies. If world prices for gold rise, then the prices for shares of gold mining companies rise as well. However, price charts may vary. The deviation of price charts from moving averages is analyzed. With a significant increase in the price of one of the assets, it is sold, and at the same time the asset that has fallen is bought. Thus, the so-called Beta Neutral Portfolio , in which the result of such a transaction will depend not on the market trend, but on the ratio of the price of one asset to another. When the price charts return to the moving averages, the positions are closed. For analysis of pair trading on small timeframes, algorithms of technical analysis indicators are used. On large timeframes, fundamental market analysis is used, with indicators of market multipliers and various financial ratios. This strategy is often used by large investment funds and hedge funds that make large transactions through TWAP, VWAP, Iceberg or POV algorithms.
Speculative Basket Trading Strategies
Basket trading works according to a practically similar algorithm with pair trading, with the difference that algorithmic trading is carried out not with two correlated assets, but with two baskets of correlated assets (from the English Basket - basket). Thus, diversification takes place, which allows minimizing trading risks. Algorithmic trading in basket trading is carried out, as a rule, within one trading session by market orders, and highly liquid assets are included in the baskets.
Arbitrage Speculative Strategies (Arbitage)
Arbitrage trading is somewhat similar to pair trading, with the difference that it is conducted by several similar trading instruments (identical or correlated). Arbitrage trading involves profiting from the difference in prices of similar (identical) assets, and not from price movements. When related or identical instruments demonstrate a difference in quotes, an arbitrage situation arises.
Arbitrage strategies can be divided into the following subtypes, depending on the assets used:
- Spatial Arbitrage Strategy— absolutely identical trading assets are used, but in different financial markets. For example, algorithmic trading of shares of the same company on different stock exchanges. For example, if on one exchange platform the quotes of the company's shares are $100 for sale (Bid) and $101 for purchase (Ask), and on another site it is offered at prices of $102 for sale and $103 for purchase, then a trader can buy on one exchange shares at $101 and sell them for another at $102, earning $1 from each share.
- Equivalent Arbitrage Strategy— trading instruments connected with each other that have a linear relationship with each other are used. For example: shares of a company and futures on shares of a company. That is, it happens that the price of shares has risen, but futures for them have remained in the same place, or even lowered a little. In this case, you should sell shares, and buy futures for these shares, and then expect their prices to converge. Similarly, you can trade in the opposite direction.
- Index Arbitrage Strategy— is a subspecies of basket trading, and is based on the connection of a futures on an index and a basket of assets that are included in this index.
Arbitrage trading contributes to the synchronization and alignment of prices, as algorithmic arbitrageurs react very quickly to any imbalance in the financial markets.
In algorithmic arbitrage trading, the supply of quotes, the speed and quality of data transfer play an important role. Therefore, institutional market participants connect a significant material and technical base to ensure arbitrage trading.
Algorithmic strategies for trading volatility (Volatility trading
Volatility trading is carried out on derivative financial instruments, especially on options. The principle of trading is reduced to the dependence of the value of an option contract on the volatility of the trading instrument in the period up to the expiration date. In simple terms, volatility trading assumes that the value of an option is affected by taking into account the risks of price movement.
Volatility- an indicator that displays the probability of a price change. The higher the volatility, the higher the likelihood that the price will change.
An option with the expectation of higher volatility is bought because its price will rise. An option with an expectation of lower volatility is sold as its value will fall. When purchasing an option, you must hedging positions of the opposite trade.
Volatility trading calculations are very complex, the mathematical calculations of which work according to automated algorithms of institutional participants in financial markets.
Speculative low cost strategies (Low-latency trading)
Low-cost algorithmic strategies are similar to trend-following strategies, as they involve trading with the trend, and pair trading, as they use correlated instruments. However, algorithmic trading involves the use of several instruments, while the market movement is determined by the underlying asset, and transactions are directly made on another instrument. The key point of low cost strategies is that on highly correlated trading instruments, one asset (underlying) with more liquidity reacts faster than other (working) assets with lower liquidity. For example, at first the price of oil (basis) falls, which pulls down the shares of oil producing and oil refining companies (working trading instruments). Trends in the underlying asset are analyzed on the smallest timeframes, taking into account each change in quotes. As soon as the underlying asset begins to show a sharp change in price, a transaction is made on working trading instruments in the direction of the change in the underlying asset. When algorithmically trading with low cost strategies, it is essential to have ultra-fast access to the market and market information in order to implement all trading signals.
Speculative front-running strategies (front running)
Front-running involves the analysis of current liquidity and the average volume of asset positions in a specific period of time. If the market determines the best bid and ask price of one or more orders, where the total volume exceeds by a certain amount the average volume of orders for a specific period of time, then an order is placed at a price several points higher (when buying) or lower (when selling) from the price large applications. It turns out that the placed order will be placed before large orders. When this order is executed, the opposite order is immediately placed a few more points higher if the Buy order is filled, or a few points lower if the Sell order is filled. It all sounds complicated, but the idea is simple: large positions, as a rule, are filled for a certain time, during which several opposite trades can occur. When a large position is executed, the price can move significantly, which will bring profit on the first order. For algorithmic front-running trading, trading assets with high liquidity are used. Front running becomes possible only with high-speed access to the market and market information.
Conclusion
Algorithmic trading allows large institutional market participants to sell large amounts of assets, as well as receive additional profit from speculation on the exchange and over-the-counter markets. Sophisticated algorithms automatically analyze and execute transactions that can affect the situation on the market.
Most of the trading robots that are used in algorithmic trading are not available to ordinary traders, as they are proprietary developments of large trading participants. Algorithm trading requires high accuracy of execution and direct access to market liquidity and information, which is provided by direct access to liquidity providers.
With Yuri Maslov, who at ITinvest is developing the infrastructure for working on the stock exchange using trading robots. In the blog on Habré, we publish excerpts from this conversation, dedicated to answers to frequently asked questions regarding the technologies used in the stock market in Russia.
Pros of Algorithmic Trading
An increase in the number of traders using special robots to trade on the stock exchange is a global trend. Not everyone is happy with this fact, many consider algorithmic trading to be harmful speculation, but it allows you to maintain liquidity in the markets. The number of high-frequency traders (HFT) and their impact on the market is determined by general market laws - we wrote about this in a topic dedicated to the prospects of algorithmic trading in Russia:In addition, the use of technology in trading allows you to get rid of one of the main problems that arise when working in the financial market - the predominance of emotions over reason, which can lead to mistakes and loss of money. In addition, the situation on the stock market often changes so rapidly that a person may not have time to react to it - the robot is not so slow.
For example, a long time ago, in 2002-2003. people were trading simple hard arbitrage Gazprom vs Gazprom futures with their hands. Received insane interest per annum. But in 2008, this niche was already completely occupied by algorithms. After September 2011, this niche was completely occupied by high-frequency algorithms.
How much money do you need to trade a robot
It is possible to algorithmize trading strategies even if there is not a very large amount of funds for trading on the stock exchange. At the same time, it is necessary to be aware that there are various areas of algorithmic trading. There are varieties of it that do not impose an increased requirement for speed - for example, intelligent strategies that benefit from understanding the market. If you need high-frequency trading (strategies that overtake everyone on the market) or you intend to use microstructural models, then the entrance ticket is more expensive, since you need a serious infrastructure and the cost of supporting it.Yuri Maslov
Before rushing into the real market, it is necessary to test the strategy and calculate its profitability (in principle, this can be done even in MS Excel). This profitability should, ideally, cover the costs of developing and maintaining a trading robot - paying for the services of a programmer or, in case of self-development, time costs.
There are people on the market who started with 100 thousand rubles. Maybe they just started at a better time. Today, the amount from 500 thousand rubles to 1 million rubles is the entry threshold at which it is already possible to start working with algorithmic strategies. At the same time, there are convenient tools that can be used to algorithmize a strategy even for 20,000 rubles. There are more and more of them on the market. They allow you to make algorithms without significant development costs.
These solutions include TS Lab systems or Cofite products. There are more and more such solutions - their essence lies in the use of scripting languages that simplify development in time. They are "sharpened" for the rapid implementation of algorithms. An example of such a scripting language is TradeScript, created by the Americans from Modulus Financial Engineering. This technology has been licensed (OEM) to create the SmartX terminal. This language is very simple and allows you to describe a trading strategy in a short time, just by reading the manual (or publications on Habré - one, two)
Roundtrip applications
The speed of the trading robot depends on various factors. One of the most important is the data transfer protocol used.Let's take the protocols that are used to work with the Moscow Exchange on the spot market. There are different ways to connect: "native" exchange protocol, it is also called native, FIX-connection and work through a brokerage trading system. People who try to be the first in the “glasses” use a FIX connection, less often a native protocol.
When connecting through a brokerage system, the speed is usually lower. If we talk about FIX on the MICEX stock market, then the roundtrip, in the exchange part, is about 300-350 microseconds, the full path of the order, taking into account the delay of communication channels and on client equipment, can be expressed in significantly larger values.
These figures are the same for all brokers, they depend to a greater extent on the quality of the channel to the exchange, the installed equipment and the processing speed of the application in the core. In the case of using the "native" exchange protocol TEAP, the typical delay is higher and ranges from 420 µs.
The time for placing orders passing through the ITinvest trading system (from the moment when it is received from the client to the gateway (gateway) until the moment when the client receives a response to it - you need to understand that when working via the Internet there may be unpredictable delays in the area from broker gateway to client equipment) is from 1.5 to 2.5ms. At the same time, there is a solution for high-frequency traders that involves working on the FIX protocol and connecting to ITinvest risk management servers. It takes a few microseconds to control risks, and they are invisible in the total amount of the exchange roundtrip.
Development Technologies
Experience shows that universal processors are the best technological solution for creating trading robots in the Russian market. The range of application of various solutions is limited - you can build a fast strategy on the FPGA, but for complex calculations it is better to use a universal processor. GPUs have their drawbacks, such as slow memory handling and high power consumption. Robot optimization for a universal processor in the local market is currently the leading solution.When it comes to operating systems, the more a person wants performance, the more interested they are in using Linux. If there is any working business idea, then increasing the speed can allow you to earn more. But the cost of developing and employing a top notch programmer may not be worth the cost. In principle, fairly quick solutions can be created on Windows as well. Linux is good because it is customized to the emerging needs of the user-trader - new kernels with new chips are released. Windows is more conservative in these matters.
C# is popular lately. It is very easy to develop, and a person who does not even have a specialized education and has only basic development skills can master C # and write a robot algorithm. For more serious developments in the financial market, C and C ++ are used, which allow you to get acceptable speed at optimal costs (in severe cases, it comes to Assembler). Beginning exchange software developers usually use C#.
Do I need to use boxed products to create robots
On the one hand, the advantage of such solutions is that they save development time. On the other hand, it is a “black box” with its own logic, and it is really difficult to understand some products without consulting their creators. But the fact that they facilitate the development of trading robots is beyond doubt. Most brokers have a user-friendly interface that allows you to write an application quickly and conveniently. For example, ITinvest has the SmartCom API.His manual contains examples, and a person who knows C # will be able to write his robot quickly enough. At the same time, high-frequency traders almost always write trading systems for themselves - this method allows you to get a unique product and count on a bigger win on the market.
That's all for today, thank you all for your attention. We would also like to ask Habr users what topics related to the stock market they would be interested in reading about. Applications and questions are accepted in the comments!
P.S. If you notice a typo or mistake - write a personal message, and we will promptly correct everything.