# Smart order routing

Smart order routing (SOR) is an automated process of handling orders, aimed at taking the best available opportunity throughout a range of different trading venues.
The increasing number of various trading venues and MTFs has led to a surge in liquidity fragmentation, when the same stock is traded on several different venues, so the price and the amount of stock can vary between them. SOR serves to tackle liquidity fragmentation, or even benefit from it. Smart Order Routing is performed by Smart Order Routers - systems designed to analyze the state of venues and to place orders the best available way, relying on the defined rules, configurations and algorithms.

## History
### 1980s

The forebears of today's smart order routers appeared in the late 1980s: "In an attempt to lock in the client order flow and free traders up from smaller trades, in order to handle the larger trades, many of the larger broker dealers began to offer a new service called Direct Order Turnaround or DOT. DOT boxes were the first electronic machines to provide the institutional buy-side with what we now call "direct sponsored access", they, however, were not very smart yet (they could be directed to only one destination, the New York Stock Exchange)".
By 1988, SuperDOT included "roughly 700 communications lines that carry buy and sell orders."

### 1990s

It was in the US, in the late 1990s, that the first instances of Smart Order Routers appeared: "Once alternative trading systems (ATSes) started to pop up in U.S. cash equities markets … with the introduction of the U.S. Securities and Exchange Commission’s (SEC’s) Regulation ATS and changes to its order handling rules, smart order routing (SOR) has been a fact of life for global agency broker Investment Technology Group (ITG)."

### 2000s

As a reaction to the introduction of MiFID (Europe) and Reg NMS (USA), Smart Order Routers proliferated in Europe in 2007–2008, their sole purpose consisting in capturing liquidity on lit venues, or doing an aggressive or a passive split, depending on the market data. Later the SOR systems were enhanced to cope with High Frequency Trading, to decrease latency and implement smarter algorithms, as well as work with dark pools liquidity.
Here are some US statistics from 2006-2007: "Smart order routing capabilities for options are anonymous and easy to use, and optimizes execution quality with each transaction". "In a study conducted earlier this year in conjunction with Financial Insights, BAS found that about 5% of all equity orders were executed using trading algorithms, with this number expected to increase to 20% by 2007".
Smart order routing may be formulated in terms of an optimization problem which achieves a tradeoff between speed and cost of execution.

## Benefits and disadvantages

SOR provides the following benefits:
* Simultaneous access to several venues;
* Automatic search for the best Price;
* A good framework for usage of custom algorithms;
* Opportunity to get additional validation, control and statistics;
There are, however, some disadvantages:
* Additional latency;
* Additional complexity, and, therefore, additional risk of loss/outage;
* Transparency of information, concerning your transactions, for the third party;

## Concept

The idea of Smart Order Routing is to scan the markets and find the best place to execute a customer's order, based on price and liquidity.
Thus, SOR can involve a few stages:
1. Receiving incoming orders through different channels:
* An incoming FIX gateway;
* An incoming Gateway based on any custom protocol;
* A front-End;
2. Processing the orders inside the SOR system, taking into account:
* Characteristics of available venues;
* Custom algorithms;
* Settings/preferences of a certain client;
* The state of available markets/market data;
Venue parameters, such as average latency, commission, and rank can be used to prioritize certain venues. Custom algorithms, like synthetic orders (peg, iceberg, spraying, TWAP), can be used to manage orders automatically, for instance, if a specific client has certain routing preferences among several brokers, or certain rules for handling of incoming, or creation of outgoing orders. It is also crucial to track the actual venue situation, like the trading phase, as well as the available opportunities. Thus, any Smart Order Router requires real-time market data from different venues. The market data can be obtained either by connecting directly to the venue's feed handlers, or by using market data providers.
3. Routing the orders to one or several venues according to the decision made at step 2 using:
* A FIX gateway;
* A custom API gateway;
Routing here does not just imply static routing to a certain venue, but dynamic behavior with updates of existing orders, creation of new ones, sweeping to catch a newly appeared opportunity.
At a closer look, the structure of the SOR system usually contains:
* Client Gateways (to receive incoming orders of the SOR customers);
* Market gateways (to send orders to certain exchanges);
* The SOR implementation (to keep the SOR logic and custom algos and tackle the clients’ orders);
* Feedhandlers (to provide market data from exchanges, for decision-making);
* Client front-ends (to provide GUI for SOR );

## Algorithmic trading and SOR

The classic definition of Smart Order Routing is choosing the best prices and order distribution to capture liquidity. "Forwarding orders to the "best" out of a set of alternative venues while taking into account the different attributes of each venue. What is "best" can be evaluated considering different dimensions – either specified by the customer or by the regulatory regime – e.g. price, liquidity, costs, speed and likelihood of execution or any combination of these dimensions".
In some cases, algorithmic trading is rather dedicated to automatic usage of synthetic behavior. "Algorithmic trading manages the "parent" order while a smart order router directs the "child" orders to the desired destinations." "... slicing a big order into a multiplicity of smaller orders and of timing these orders to minimise market impact via electronic means. Based on mathematical models and considering historical and real-time market data, algorithms determine ex ante, or continuously, the optimum size of the (next) slice and its time of submission to the market. A variety of principles is used for these algorithms, it is aimed at reaching or beating an implicit or explicit benchmark: e.g. a volume weighted average price (VWAP) algorithm targets at slicing and timing orders in a way that the resulting VWAP of its own transactions is close to or better than the VWAP of all transactions of the respective security throughout the trading day or during a specified period of time".
However, smart order routing and algorithmic trading are connected more closely than it seems. Since even Smart Order Routing can be considered the simplest example of algorithm, it is reasonable to say that algorithmic trading is a logical continuation and an extension of Smart Order Routing.
This is a common example of a simple Smart Order Routing strategy.
Having the initial Order Book, the SOR strategy will create child orders, that is orders which aim at completing the initial SOR parent order. These orders can either be aggressive or passive depending on the current context and the SOR algorithm. In this example IOC (immediate or cancel) orders are used:
| Preferred venue | Preferred venue | Venue 1 | Venue 1 | Venue 2 | Venue 2 |
| Buy | Sell | Buy | Sell | Buy | Sell |
| | 100@21.5 | | 200@21.5 | | 300@21.6 |
1) An SOR Buy Day order for 1000@21.5 comes;
2) Aggressive child order to grab opportunity on preferable venue created: Buy IOC 100@21.5;
3) Aggressive child order to grab opportunity on Venue 1 created: Buy IOC 200@21.5;
4) The remaining part placed passive to the Preferred venue:
| Preferred venue | Preferred venue | Venue 1 | Venue 1 | Venue 2 | Venue 2 |
| Buy | Sell | Buy | Sell | Buy | Sell |
| 700@21.5 | | | | | 300@21.6 |
5)New liquidity on Venue 2 appears: Sell 150@21.4:
| Preferred venue | Preferred venue | Venue 1 | Venue 1 | Venue 2 | Venue 2 |
| Buy | Sell | Buy | Sell | Buy | Sell |
| 700@21.5 | | | | | 150@21.4 |
| | | | | | 300@21.6 |
6)The algo "sweeps" from Preferred venue to grab the opportunity on Venue 2: Buy 150@21.4 IOC
| Preferred venue | Preferred venue | Venue 1 | Venue 1 | Venue 2 | Venue 2 |
| Buy | Sell | Buy | Sell | Buy | Sell |
| 550@21.5 | | | | | 300@21.6 |
7)New liquidity on Venue 1 appears: Sell 600@21.5:
| Preferred venue | Preferred venue | Venue 1 | Venue 1 | Venue 2 | Venue 2 |
| Buy | Sell | Buy | Sell | Buy | Sell |
| 550@21.5 | | | 600@21.5 | | 300@21.6 |
8)The algo "sweeps" from the Preferred venue to grab the opportunity on Venue 1: Buy 550@21.5 IOC
9)The trade happens, the algo terminates because all the intended shares were executed:
| Preferred venue | Preferred venue | Venue 1 | Venue 1 | Venue 2 | Venue 2 |
| Buy | Sell | Buy | Sell | Buy | Sell |
| | | | 50@21.5 | | 300@21.6 |
As there are latencies involved in constructing and reading from the consolidated order book, child orders may be rejected if the target order was filled before it got there. Therefore, modern smart order routers have callback mechanisms that re-route orders if they are rejected or partially executed.
If more liquidity is needed to execute an order, smart order routers will post day limit orders, relying on probabilistic and/or machine learning models to find the best venues. If the targeting logic supports it, child orders may also be sent to dark venues, although the client will typically have an option to disable this.
More generally, smart order routing algorithms focus on optimizing a tradeoff between execution cost and execution time.

## Cross-Border Routing

Some institutions offer cross-border routing for inter-listed stocks. In this scenario, the SOR targeting logic will use real-time FX rates to determine whether to route to venues in different countries that trade in different currencies. The most common cross-border routers typically route to both Canadian and American venues; however, there are some routers that also factor in European venues while they are open during trading hours.