Algorithmic and automated trading: Introduction
In our blog on habr, we repeatedly raised issues related to the creation of trading robots and algorithmic trading systems. Today we bring to your attention a post written by our reader - the purpose of this publication is to clarify the terminological confusion that surrounds algorithmic trading.
Zi Lu asked: “The Wei ruler intends to bring you to government. What will you do first? ”
The teacher replied: "It is necessary to begin with the correction of names."
To begin, let's introduce the main participants in the exchange trading process:
- The client is an investor, makes investment decisions and gives orders (warrants) to an intermediary broker
- An intermediary broker is a member of the exchange and takes orders from the client and transfers them for execution to the exchange, receives results from the exchange and transfers them to the client ( an example of such a broker is just ITinvest - approx. Ed. )
- Exchange - receives orders from broker members, carries out tenders, sends trading reports to brokers
We consider the case when the broker is a net agent, i.e. means of transferring client orders to the exchange and reports - back. Agent brokers earn exclusively on the commission paid by the client to the broker for the execution of orders.
Electronic commerce
Before the advent of computers and networks, orders were moved between clients, brokers and exchanges using the telephone, and before the telephone appeared using the telegraph, and until the telegraph in gray bearded times, by couriers and messengers and even carrier pigeons.
Currently, the movement of an order (“order flow”) from a client through a broker to an exchange at all brokers is completely computerized, although there are cases when some lazy clients with thick wallets prefer to transfer their orders personally by phone, without touching the computer, but their orders anyway, they are entered into the broker computer by the broker, and then they are transferred to the exchange via the network as it should be in the 21st century.
Investor, his goal and strategy
The investor is committed to making an investment decision on the purchase and sale of an asset or a portfolio of assets. His goal is to make money.
An investor can make decisions independently, guided by instinct, knowledge, insider information, whispers of mermaids, the location of planets and the flight of birds, the configuration of “Japanese candles” (“technical analysis”) or quarterly reports of companies (“fundamental analysis”). In making such investment decisions for data analysis and calculations, many investors have long been using computers. Trading based on such calculations is called “quantitative trading”.
Having received the “sell” / “buy” signals from the calculations, the investor generates an order request for the purchase (sale), which is sent to the broker for execution. If an investor works with a whole portfolio of assets, there may be several hundred simultaneous buy and sell orders.
Automated Trading
If an investor can express his investment intuition, vision, strategy in the form of computer code, he can fully automate the adoption of investment decisions by instructing the computer everything from analyzing incoming market data and calculating potential profit and loss to generating buy and sell orders. The investor leaves only verification, monitoring and a relaxed game of golf.
In those hot moments when the investor is shaking hands and gnawing doubts, the computer will implicitly issue a buy-sell verdict and buy and sell in strict accordance with the set of rules laid down in it. And make a profit. Unless, of course, the set of rules is correct.
This trading style is called "automated" (automated trading). Other names for such trading: "rule-based trading" (trading by the rules), "systematic trading" (trading by the system). The computer program in this case is called an “automated trading system” (automated trading system) or a “trading robot” (trading robot).
If the set of rules by which the investment decision is made is kept in a special secret by the developer from those who use it, such a system is called a “black box”, and trading with its help is called “black-box trading”.
The goal of automated trading, like any other proprietary trading, is to make money. The set of rules for an automated trading system can also be called an algorithm, of course, but from this, “automated trading” does not become “algorithmic”.
When you write "robots" in trading terminals or in Visual Basic, and start them to trade on the exchange, you are not engaged in algorithmic trading, but in automated proprietary trading.
Algorithmic trading
The term “algorithmic trading” is used to refer to another specific process in which investment decisions are not made. In algorithmic trading, algorithms are used to execute large orders with minimal losses.
The goal of algorithmic trading is to effectively reduce the costs of order execution (execution costs), reducing the effect of the order on the market (reduce market impact).
The word "trading" in this term is not entirely successful. It is too broad and is associated with purchase and sale activities in the majority, therefore it is correct to call this process “algorithmic order execution”.
Where exactly the order comes from in the algorithmic engine is not important, the main thing is that it is not the algorithmic engine that creates it. Most often, the broker's engine engine is working on a large order received from a client.
Order Execution
Before the advent of algorithmic trading, large client orders in brokerage houses were processed manually. Traders (working the order) are called to work on an order, carefully “pushing” it into the market in parts (slicing), guided by instinct, experience and reaction.
Such orders were called “high touch”, since such orders required a lot of attention and care. The brokers call the flow of these client orders “high touch order flow”, and the brokers have a special department dealing with such orders “high touch trading desk”. For "manual work" with the order, clients pay the broker the highest commission.
Why it is so important to carefully work with large client orders, read the section “A large order moves the market” at the end of the article.
With the growing flow of applications, traders no longer had time to pay due attention to each large order and the idea came up to use computers for this. This is understandable, since the orders are sent to the broker electronically and are already located on the computer, why not program the computer with the simplest rules for executing orders and entrust them with routine work?
So algorithmic engines were created that did the same thing as a regular trader did with a large order manually, namely: a large parent order (parent order) was divided, using a special algorithm with the given parameters, into small orders (child orders) and each small order was sent to the market at a predetermined point in time. Computers can very easily process thousands of client orders simultaneously and divide them into hundreds of “little cubs”, leaving the trader time and the opportunity to work on other more complex orders manually.
As you can see, in the beginning, the algorithmic engines were just an auxiliary tool for the brokers of the brokerage company, to which they resorted when the execution of the client order did not require special attention, and it was just necessary to discipline the execution of a certain strategy.
Direct market access
Direct Market Acess - “direct market access”, this is when a broker passes an order through his trading system to the market in a fully automatic mode without additional manual intervention.
If the order from the client is accepted electronically and is already on the computer, why not program the computer to perform certain checks and then immediately send the order to the exchange? This simple idea was realized in the early 2000s, when exchanges everywhere became electronic, and brokers began to offer DMA service to their customers.
Unlike “high touch” orders, in the DMA service no one touches client orders, no one processes them or checks them manually. Therefore, they are called “low touch”. “Low” because some processing is still underway: the order passes through the broker's trading system, where it is checked for validation and compliance with various limits and risks (risk checks). Only after this, the broker's trading system sends an order to the exchange. All checks of the order are completed in fractions of a second, but nevertheless they contribute to the difference between the time the order was received by the broker and the order is received on the market.
This delay (“latency”) was not liked by all customers, and brokers went for an even bolder service - providing “naked DMA” or “sponsored DMA”. In naked DMA, the client itself connects to the exchange directly, creating its own infrastructure, and sends its orders from its trading system directly to the exchange, bypassing the broker's infrastructure, but using its identifier.
A client needs a broker identifier because only members of the exchange, which is a broker, but not a client, can trade on the exchange. Those. All orders sent by the client through naked DMA are sent on behalf of the broker (he acts as a sponsor, renting his identifier and his reputation) at the client’s responsibility. The broker, on the other hand, receives information about client orders post factum in the form of a protocol (drop-copy) from the exchange. Such orders are called “zero-touch” because the broker does not touch them at all. Recently, naked DMA began to be pressed by government regulatory authorities, especially in the United States.
For using the DMA service, customers also pay a broker a commission, albeit a miserable one.
Direct strategy access
Digression: For some brokers, execution algorithms are called the word “strategy”. It just sounds more beautiful. This introduces confusion, because the word "strategy", for example, in the phrase "investment strategy" takes on perfect meaning.
Somewhere around 2004, large brokers began to provide customers with access to their algorithmic engines in addition to the DMA service. Now the client could send an order with parameters, which indicated which broker algorithm he chooses, how aggressively it is necessary to execute the order, when it is necessary to start the execution of the order and when to finish. This special order inside the brokerage infrastructure is redirected to the algorithmic engine, which then “works” on the order, sending it to the exchange in small pieces.
I wrote above that algorithms are sometimes called strategies for beauty and advertising, so direct access to them is called “direct strategy access”, i.e. literally "direct access to strategies." Orders are called DSA orders, and the flow of such orders is called DSA flow.
The client pays the broker an additional commission for using the broker's algorithms.
Investor and Algorithmic Trading
Since the client-investor already has direct access to the market through a DMA service from a broker, nothing prevents him (if there is a budget) from creating his own custom engine, tailored to his own needs, which will execute his large orders generated its automated trading system.
An investor can buy a ready-made (of-the-shelf) algorithmic engine from a third-party office (vendor), or hire programmers to write him their own (custom built).
In any case, the investor's algorithm engine becomes part of its automated trading system, but is still a module for the execution of orders. The generation of orders is the investment part of the trading system.
Big order moves the market
The main task of the broker-agent is to serve the client, i.e. to execute a client’s order in a quality manner so that the client, when buying, does not overpay, and when selling - does not lose. But if he overpaid, then not too much. And here against the broker-agent comes the main market law of supply and demand feedback. If a client passes a very large order for processing, say, to sell 100,000 shares (we are talking about an order worth at least a million cu), then you can’t just take it and put it on the market. This will instantly lead to an imbalance of the market, and this will lead to the fact that those who want to buy will lower their price, seeing that someone needs to sell so many more shares. It looks like this - the seller sees on the market the current stock quotes XYZ buy / sell 100 - 110. And he sends an order: sell 100,000 at 100 cu, planning to gain 10,000,000 cu Inept broker dumps the entire order on the market, and what does he see? Those who until recently wanted to buy at 100 cu will instantly withdraw their applications and submit new applications: no, we don’t want to buy at 100, we want to buy at 90. The broker will scratch his head and redefine his order: okay, I sell 100,000 for 90 cu If buyers do not repeat their feint, the broker will execute the order, bringing the client on a plate instead of 10,000,000 cu only 9,000,000. Those. on the execution of the order, the client lost 10% of the capital, due to a curved hasty broker. Yes, I paid a commission. The client will not like it very much. The broker will scratch his head and redefine his order: okay, I’m selling 100,000 for 90 cu If buyers do not repeat their feint, the broker will execute the order, bringing the client on a plate instead of 10,000,000 cu only 9,000,000. Those. on the execution of the order, the client lost 10% of the capital, due to a curved hasty broker. Yes, I paid a commission. The client will not like it very much. The broker will scratch his head and redefine his order: okay, I’m selling 100,000 for 90 cu If buyers do not repeat their feint, the broker will execute the order, bringing the client on a plate instead of 10,000,000 cu only 9,000,000. Those. on the execution of the order, the client lost 10% of the capital, due to a curved hasty broker. Yes, I paid a commission. The client will not like it very much.
This phenomenon is called a “large order moves the market” (“moves the market”), the impact of a large order on market prices (market impact) is characteristic not only of the financial market. If, say, you bring bananas to the KAMAZ bazaar to sell them quickly, bazaar dealers-dealers will encircle your KAMAZ and immediately begin to reduce the price for which they agree to buy the whole truck from you.