**Jing Xu explains what a quant does in the algorithmic trading world**

Algorithmic trading uses computer models that define the steps required to execute orders. Investment banks increasingly use automated execution for internal desks and external clients via algorithmic automatic trading platforms. These give clients a selection of execution algorithms with which to trade financial instruments such as equities, bonds, FX, futures and options. The algorithms are designed to reduce costs and minimise price movements caused by the trades, and to do it at high frequency, in less than a millisecond.

Quantitative analysts (quants) who work in this area will research, design and implement the execution algorithms used by clients. The work requires production-level programming skills in order to write the production code for the algorithms, as well as expertise in statistical modelling and analysis, machine learning and mathematical techniques.

The heart of an algorithmic trading strategy is scheduling/optimal slicing. When a client sends a large order, an execution algorithm breaks it up and releases dynamically determined smaller chunks to the market over a specified time period, during which the order can be cancelled or replaced.

Consider the volume-weighted average price (VWAP) strategy. The VWAP for a stock is total traded value divided by total traded volume, and is often used as a benchmark for a trading strategy to achieve or improve on. In general, it is where Vi and Pi are the market traded volume and averaged price at time interval Ii , and represents a trading period.

Suppose a trader aims to execute an order of a quantity Q during a specific time period I , with as little market impact as possible. One way to achieve this is to trace closely to the market VWAP given above by breaking the parent order Q into a sequence of child orders q1, ...,qn , releasing consecutively in each time interval Ii , i = 1, ...,n. The value of time interval n can be unknown.

Estimation methods on the basis of historical volume can be used to find the optimal time interval. The quantities q1, ...,qn can be found by minimising the distance between the trader VWAP and the market VWAP. The measure of distance can take different forms, which may lead to different strategies. For example, the following minimises expected squared difference over all possible market volume and/or price trajectories:

A simple and static VWAP strategy sets the optimal child orders qi = Q zi where zi is the percentage of volume traded over the specific time period I.The value of the volume profile zi , i = 1, ...,n can be estimated using historical market traded volumes. Dynamic VWAP strategies such as the one mentioned earlier involve market volume and/or price prediction for a trading period. The predictors used are usually stock-specific characteristics and market conditions, such as historical information and volatility up to the trading day. The forecast approach could be either mathematical, deriving from the assumptions of stochastic processes, or empirical, including statistical modelling and machine learning techniques such as time series analysis (eg ARMA/GARCH model, Bayesian modelling or neural network/deep learning).

Once the child order qi is determined, it will be released to the market with optimally chosen prices at the scheduled time interval Ii . This process is called order placement and uses information provided by a limit order book (LOB) to optimise trading cost.

**Order book dynamics **

The objective of electronic markets is to match asset sellers and buyers via market orders and limit orders. A limit order is an order to trade a certain amount of security at a specified price. All the posted limit orders form the LOB, which is grouped by buy/sell side and arranged by order price with corresponding quantities. At a given time t, the bid price is the best available buying limit order, while the ask price is the best available selling limit order. The difference between the bid and ask prices is called the quoted spread. A market order is an order to buy/sell a certain amount of the security at the best available price in the LOB; a limit order stays in the LOB until it is executed against a market order or cancelled. Cancellation is allowed at any time.

Most exchanges are based on a ‘first-in-first-out’ policy for orders on the same price level. *Table 1* is a typical example, showing the LOB dynamics of the top five levels: a market sell order of size 4,000 eats up the first layer of 2,900 at the bid order price of 9.07, as well as 1,100 of the second layer at the bid order price of 9.06, by walking the book. This is followed by a limit ask order of size 400 at the price of 9.08, and then a cancel action of size 123 for limit ask order at the price of 9.10.

“Liquidity fragmentation has made it impossible for human traders to know where an instrument is likely to trade best”

Resuming the VWAP example introduced above, if our goal is to sell qi shares in time horizon Ii, one option is to submit a market order immediately at the beginning of the time interval – that is, sell all qi shares at the bid price. However, the trading cost of this option might not be optimal, given the LOB dynamics during the time horizon Ii . A potentially better strategy is the ‘submit and leave’ policy: pick a fixed limit order price p and place a sell order of qi shares at the price p. After Ii minutes, go to the market with any remaining (not-executed) shares. Such strategies provide a simple framework to trade off the likelihood of execution against prices obtained. This idea can be extended to a rich class of state-based execution strategies that examine salient features of current order books and trading activity to decide what to do next. Reinforcement learning based on the state, action and reward structure is an example.

Suppose we want to sell qi = 1,000 shares within Ii = 2 minutes. Given a unit of shares that a policy can distinguish is 250 shares, all the possible states of the inventory unit are X = 1, ...,4. Given a unit of time that a policy can observe a state at is 30 seconds, all the time stages are t = 0, ...,4. Hence the observed state x at each time stage t is the number of inventory units left to be executed.

At time stage t we can withdraw the outstanding limit order and reposition all the remaining inventory with a new limit order at a price of ask price – a. A positive a corresponds to ‘crossing the spread’ towards the buyers, which leads to a larger chance of execution with potentially higher cost. A negative a corresponds to placing the order in the sell book. The more negative the a is, the deeper the limit order sits in the book, increasing the risk of no execution – although with potentially reduced cost. At the end of time horizon Ii , any remaining inventory will be executed at market price – that is, we eat into the opposite book no matter how poor the prices are, since we have run out of time and have no choice.

The reward produced by an action from a given state is essentially the proceeds from any (partial) execution of the limit/market order placed. The optimal policy is obtained by maximising total discounted rewards at all time stages. The reinforcement learning agent uses historical limit order data to learn an optimal compromise between fast order completion with higher costs, and slow, riskier order completion with lower costs.

Optimal order placement decisions depend not only on private variables such as inventory and trading horizon, but also market variables: characteristics of the order flows, queue sizes in each LOB, and the structure

of transaction fees and rebates across exchanges/venues. Research and development in this area remains active among academics and practitioners.

**Smart order routing **

The increasing number of various trading venues leads to a surge in liquidity fragmentation. The effects of liquidity fragmentation, combined with regulation and new technology, have made it impossible for human traders to know where an instrument is likely to trade best: there are too many markets, and prices change too quickly for a human to keep up with.

A tool like the smart order routing (SOR) brings back the control. Through analysing the state of venues and following the order book dynamics, it can dictate where the order slices are to be traded, with the aim of trading as many of the slices as possible at the best average price available. Here, the sizes, price limits and trading time horizons of the order slices are pre-determined by algorithmic trading strategies or clients.

SOR is performed by smart order routers – systems configured by defined rules/logic and algorithms. The design of a smart order router should take into account not only the attributes of each venue, such as price, liquidity, cost, speed/latency, likelihood of execution and venue limit, but also client preferences such as urgency, as well as market impact.

The strategies used in SOR often have two phases: an aggressive phase, which sweeps the markets to pick up all the liquidity available; and then a passive phase, in which unfilled volume is posted to one or more venues. A sweep can be carried out across lit markets, where quoted prices and sizes of instrument are displayed, or dark venues, where order books are not available to public investors and orders can only be executed at market mid-price (bid + ask) / 2 . Is it best to sweep lit venues aggressively before dark venues, or vice versa?

The advantage of sweeping lit markets first is immediacy. The SOR takes liquidity when seeing a suitable price in the lit markets, and then sweeps the dark venues for the unfilled quantity. However, it may cause information leakage and move the price adversely in the lit markets, and also affect mid-price referenced in the dark venues. A better approach seems to be scanning the dark venues before the lit ones; this may achieve a better price if most of the order can be filled quickly in the dark. However, a speculative scan of dark venues may delay the residual order volume getting to the lit markets. In the worst cases, nothing gets filled in the dark scan, and the suitable lit price originally in the market is no longer available. The best strategy therefore depends on priority. If the aim is to optimise the price, sweep the dark venues first. If the aim is to optimise the chance of hitting currently displayed liquidity, sweep the lit venues first.

Routing orders for best execution essentially involves optimising in high dimensional space, where mathematical and statistical techniques play a key role.

**Conclusion **

Algorithmic trading is highly competitive. Market conditions change, and demands from clients evolve. Staying at the top as a quant in this area requires motivation, creativity and continuous learning of new techniques.

**Dr Xing Ju is an algorithmic trading quant at Bank of America, Merrill Lynch**