All You Need to Know About Algorithmic Trading
All You Need to Know About Algorithmic Trading
Algorithmic Trading
March 3, 2023
* The views expressed are those of the authors only, no other representation should be attributed.
[email protected]
Algorithmic Trading
History
History of Algorithmic Trading
Mr. Market
Market Participants
Market Liquidity
Market Microstructure
Algorithmic Trading/Execution
[email protected]
Algorithmic Trading
History of Exchange Silk Road
▶ Marketplace/Bazaar/Financial
Innovation/Exchange and Raise Capital
− Monopolies and Funds: 1600 - 1780s
− Globalization: 1780s - growth until
1914.
In 1851, Paul Reuter (founder of the
Reuters news agency) used a cable
beneath the English Channel to get
market moves of London and Paris.
Replacing his pigeons.
− Great Reversal - WWI/Great
Depression(1929)/WWII
− Return of Globalization -1980s/90s
− Boom in Electronic Markets: 2000s
− Next? Singularity(Global 24/7)? AI?
[email protected]
Algorithmic Trading
History of Algorithmic Trading
▶ Automated Trading
− was first introduced by Richard Donchian in 1949 when he
used a set of rules to buy and sell based on moving averages.
− Modern Portfolio Theory (MPT) Markowitz Model in 1952
▶ Computerization
− first arbitrage trade using computers (1960): Harry
Markowitz, Ed Thorp, and Michael Goodkin
− early Computerization in NYSE (1965-1972)
Old Trading Pit vs Digital Trading Floor
− first electronic communications network (ECN) named
Instinet (1967), ECNs are also called alternative trading
systems (ATS/ATN) - less regulated than an exchange
− NASDAQ (1971), first automated OTC quotations, later fully
automated trading, first Intermarket Trading System (ITS) on
NASDAQ in 1978, first dark pools (1986/87) by Instinet/ITG
− Renaissance Technologies (1982), Millennium (1989)
− Interactive Brokers by Thomas Peterffy (1993), first fully
automated algorithmic trading system
− US Securities and Exchange Commission (SEC) relaxed
exchange regulations for more automation (1998)
[email protected]
Algorithmic Trading
▶ The Boom (2000s)
Recent Updates in Algorithmic Trading
− HFT execution time: several seconds (2001),
milliseconds/microseconds (2010), and nanoseconds (2012).
− Tech Arm Race: Intense competition, ultra-low latency trading
− Traders pay to place computers inside Exchange data centers
− Pandas by AQR Capital Management (2008)
− Spread Networks, fiber-optic link (2010), trading between
New York and Chicago only in 13.3 milliseconds
− HFT as a % of ADV increased > 50%, revenue/speed bump
▶ The Bust (Flash Crash in May 2010)
− a single algo-executed sale worth $4.1 billion triggered a
trillion dollars loss (10% drop) and rebound in 36 minutes
▶ Regulations due to increased market complexity/risk
− Following 2010 flash crash, SEC introduced circuit breakers
− US Commodity Futures Trading Commission (CFTC)
approved more regulations on automated trading (2015).
− Regulation National Market System or Reg NMS (2005)
− National Best Bid Offer (NBBO) - Market Fragmentation
− Best execution for investors
− In the EU: MiFID I (2007), MiFID II (2018), European
Market Infrastructure Regulation (EMIR) for derivative market
− Market Abuse Regulation (MAR) - FCA in the UK
− Volcker Rule / Dodd-Frank (limits prop trading in banks)
▶ Today: AlgoTrading growth in other asset classes and EM
regions, increased market liquidity, lower trading fees
− Big Data and Cloud computing, it’s all about speed
− AI/machine learning, wireless, fiber-optic, submarine cables
[email protected]
Algorithmic Trading
Mr. Market
▶ Market: Random vs Rational - or somewhere in between
− Interaction of different agents:
− Informed traders (really?)
− Noise traders
− Market Makers (MM)
▶ Constantly evolving: millions of brains/machines at once
▶ Mathematical tools: randomness, time series and statistics,
machine learning, and game theory
▶ Price formation: trading, investing, speculation, asset
allocation, a capital pool
▶ Market moves: Fundamental vs Mechanical
− Root of most trading signals: fundamental, mechanical, news,
macroeconomics, pure data, quantamental, spreads, arbitrage,
market crossover, StatArb, etc
▶ Is the market truly efficient?
− Small scale, short term: No
− Medium term/range: Maybe
− Long Term: Maybe/Yes - ”the truth will out”
▶ Why to study Market / Market Microstructure?
− Design/test and optimize trading algorithms
− Working in trading/investing institutions
− Talk/work with regulators
− Risk management
− Financial innovations, academics and practitioners
[email protected]
Algorithmic Trading
Market Participants
▶ Buy Side
− Long Only Asset Managers: Mutual funds,
pension funds, Vanguard, Fidelity, etc. Pooled
investment mainly from households and retail
investors.
− Institutional Investors/Wealth Managements.
Big bank wealth management such as UBS
wealth management, Bank of America/Merrill
Lynch wealth management, etc. Serving a wide
array of clients ranging from affluent to top rich
individuals and families.
− Long-Short Asset Managers: Hedge funds like
Millennium, Citadel, Point72, Renaissance
Technologies, etc. Pooled investment from
institutional clients and wealthy individuals.
▶ Sell Side: Broker-Dealers
− such as Goldman Sachs, Morgan Stanley, JP Morgan, BofA, etc.
− Broker: trading on behalf of a client
− Dealer: trading as a principal and providing liquidity on their own books. Used to be a main source of
revenue before Dodd-Frank Act and limitation on proprietary trading for the sell side.
▶ Market Makers (MMs)/High-Frequency Traders (HFTs)/Designated MMs (DMMs)/ ELPs
− Two Sigma, DRW, Jump Trading, Virtue, and the largest MM/DMM firm in the word: Citadel
Securities (separate entity from Citadel, the hedge fund)
− Provide liquidity and sometimes take liquidity, then unwind their position for a profit. They trade with
or against the buy/sell-side market participants or other MMs/HFTs.
− Usually most technology-advanced traders, use ultra-low latency infrastructure.
− Also can aggregate retail liquidity such as Robinhood/ETrade or other online trading apps
[email protected]
Algorithmic Trading
Common Liquidity Measures
▶ Liquidity Futures
- How easily and quickly an asset can be - Open interest: Similar to options, open interest in the
bought or sold in the market without futures market reflects the total number of futures
affecting the market price. The most liquid contracts that have not been settled or expired.
asset is usually cash ($) - Trading volume
Equity (Stocks): Swaps:
- Bid-Ask spread: The difference between the - Market size: The size of the market for a particular
highest price a buyer is willing to pay (bid) swap contract.
and the lowest price a seller is willing to - Ease of trading: The ease with which a swap can be
accept (ask) for a stock. A narrower bought or sold, which depends on the availability of
bid-ask spread indicates higher liquidity. counterparties and the standardization of the contract.
- Trading volume (Average Daily volume or FX (Foreign Exchange):
ADV): The number of shares traded in a
given period of time. Higher trading volume - Market size
is generally associated with higher liquidity. - Trading volume
[email protected]
Algorithmic Trading
Market Microstructure
▶ Markets: Quote Driven (MM) vs Order Driven (LOB)
▶ Open outcry or oral (ex: LME Ring) vs Electronic
− Price formation and discovery led by machines
▶ Matching Engine: Double (buy/sell) Auction Markets
− match price: the price that maximizes trading volume
▶ Continuous Auction vs Call Auction (MOO,MOC)
− Historically, Open and Close Auction were implemented
to avoid manipulating the official prices.
▶ Market Fragmentation: Lit venues vs Dark.
− Mostly in the US/less in EMEA/much less in APAC
− Main trading venues in the US equity market:
1 Organized exchanges: different consolidations or fee
structure ICE(NYSE)/NASDAQ/CBOE(BATS)/IEX
2 Crossing networks/Brokers Internalizers: SDP/IOI/MTFs
3 ATS/Dark pool: Do not display any order info and use
National Best Bid/Offer (NBBO) as a reference (mostly
used by institutional traders. %30 - %40 of trading
volume, mostly for large orders that can be hard to execute
in Lit venues)
▶ Order types in Electronic Limit Order Book (LOB)
− Market orders (execute what’s available)
− Limit orders, Stop-loss, Stop (condition on price level)
− FOK (entirely or not), IOC, All or None
− Iceberg (deep), Hidden (mid)
− Market on Open/Close (MOO/MOC)
− First In First Out (FIFO) rule
[email protected]
Algorithmic Trading
Order Flow
▶ Flow chart is depicting the process of an order
from a client was sent to a broker.
▶ Clients submit “parent orders” to execution
services and different trading desks in a broker
firm such as JP Morgan or Bank of America.
▶ These desks could be high tough (HT) and low
touch (LT) desks.
− High tough desks: dealing with larger orders
and providing sophisticated execution services
such as portfolio execution, IOI (indication of
interest), etc. Also, receive higher commissions.
− Low tough desks: provide more standard
execution services and are mostly automated.
Receive lower commissions from the clients.
▶ At steps ‘Desks’ and ‘Algos’, the parent orders
are sliced into child orders, and sent to
different venues for cost-efficient execution.
▶ Usually, a routing system (SOR) determines to which venue a child order is sent.
▶ HFTs increase market quality by potentially dampening intraday volatility/spread
− trade directions of HFTs are based on public information such as ‘macro news announcements,
market-wide price movements, and limit order book imbalances’
− MMs to take most of the limit order track and to hold lower inventories compared to HFTs.
− HFT trades by identifying the so-called ‘strategy runs’, i.e., periods with similar inter-arrival times and
order sizes, which is unique for HFTs
[email protected]
Algorithmic Trading
Algorithmic Trading/Execution
▶ Known as Automated trading system (ATS)
▶ Algorithmic Execution
− Goal is minimizing execution/transaction cost
and risk
− other algorithmic trading strategies such as
Automated/black box/robo/HFT trading aim to
maximize the profit and minimize risk. Such
systems run strategies including market making,
inter-market spreading, arbitrage, or pure
speculation such as trend following. Many fall
into the category of high-frequency trading
(HFT), which are characterized by high turnover
and high order-to-trade ratios. HFTs benefit from
the law of large numbers, the benefit of trading
thousands to millions of tiny, low-risk, and
low-edge trades every trading day.
▶ Clients: institutional investors, hedge funds, and trading desks
− Institutional clients need to trade large amounts of stocks. These amounts are often larger than what
the market can absorb without impacting the price.
− The reasons could be re-balancing their portfolios, hedging, and so on.
− Institutional investors: investment banks, pension funds, mutual funds, hedge funds
− Need to execute large orders in markets that cannot support all of the sizes at once.
− Large order flow at special days, option expires, and index re-balance days.
▶ Execution Engines: Enable programs to search/discover fragmented liquidity pools to
optimize execution via complex / high-frequency smart order routing (SOR) strategies
▶ Algo Wheel: selecting the best broker/algo to rout a given buy-side order, given market/order
[email protected]
Algorithmic Trading
Algorithmic Execution
▶ Properties
− Automation vs Optimization or both
− Reduced transaction cost/commissions, optimized
− Control over the orders, Fast and efficient access to
different markets/venues
− Minimum information leakage
− Transparency
− Rising competition among brokers: Algo Wheel
▶ Main players: Clients, Brokers, MMs/HTFs
− Others: Independent Vendors, Order management,
and execution management software firms,
Exchanges, Third-party providers, In house
development teams, Regulatory bodies
▶ Order hierarchy
− Parent orders: Large orders according to the algo
and the specific nature of the order needs to be split
into smaller orders which will be executed
electronically over the the course of minutes, hours,
and days.
− Child orders via SOR: finding the best price/venue
with the best execution quality.
− Challenge: Information leakage
− Latency (from 20 minutes in 1980s to few milliseconds
and microseconds in the 2010s).
− According to Information Week Magazine, in modern
trading applications, each millisecond can be worth
over 100m$ in revenue per year.
− Venue/trade fees/rebates/costs consideration
[email protected]
Algorithmic Trading
Best Execution
▶ Definition: the opportunity to get a better price than what is currently quoted, and the
likelihood and speed of execution.
◦ As electronic trading systems became more widespread, traders and market participants began to explore ways
to use technology to improve the efficiency and effectiveness of their trading strategies. This led to the
development of algorithms for executing trades, which could be used to make trades faster, more accurate, and
more cost-effective. The use of algorithms for executing trades soon gave rise to the concept of best execution,
which refers to the requirement that traders and market participants must make every effort to achieve the most
favorable outcome for their clients when executing trades. This concept has since become an important principle
in the financial industry, and is closely regulated by national and international financial authorities. Today, best
execution remains an important issue in algorithmic trading, as market participants seek to ensure that their
trading algorithms are executing trades in a fair and transparent manner that benefits their clients.
▶ In Europe there has been an attempt to define “best execution” within the Markets in
Financial Instruments Directive (MiFID I/II), which introduces the principle that all financial
services firms carrying out transactions on their client’s behalf: “must take all reasonable
steps to obtain the best possible result, taking into account price, costs, speed, the likelihood
of execution and settlement, size, nature, or any other consideration relevant to the execution
of the order.”
▶ the opportunity to get a better price than what is currently quoted, the speed of execution,
and the likelihood trade will be executed (fill ratio)
▶ It is not straightforward to have a well-defined measure of best execution. It may vary from
one market to the next, and it may depend on the order characteristics. Best execution is
quantified on average and other statistically meaningful measures, however, it may change in
time/situations.
[email protected]
Algorithmic Trading
Market Microstructure, Market Impact Models, and Optimal
Liquidation Strategies
Automation and Optimization
◦ The automation and optimization of trading have their roots in the development of electronic trading systems and
the increasing use of computers in financial markets. As electronic trading systems became more widespread, traders
and market participants began to explore ways to use technology to improve the efficiency and effectiveness of their
trading strategies. This led to the development of algorithms and models for automating and optimizing trading
decisions, which could be used to make trades faster, more accurate, and more cost-effective. The use of algorithms
and models for trading optimization has since become widespread in financial markets and has been an important
driver of innovation and growth in the financial industry. Today, the automation and optimization of trading continue
to evolve, with new techniques and technologies being developed all the time, as market participants seek to gain a
competitive edge and improve their trading performance.
Mathematical/Statistical models: quantify the price formation and optimizing trading strategies
◦ Market impact models originated in the field of financial economics, where researchers sought to understand the
relationship between trading activity and asset prices in financial markets. Early models of market impact focused on
the relationship between trading volume and the price changes of securities and aimed to capture the effects of
trading on the supply and demand for assets. Over time, market impact models have become increasingly
sophisticated, incorporating factors such as the behavior of informed and uninformed traders, order flow dynamics,
and the impact of market frictions. These models have become an important tool for traders, investors, and regulators
seeking to understand the behavior of financial markets and the impact of trading on asset prices. Today, market
impact models continue to be an active area of research, with new models and insights being developed all the time.
◦ The field of market microstructure emerged in the 1970s and 1980s, as economists and financial experts sought to
understand the workings of financial markets at a more granular level. This focus on the microstructure of financial
markets was driven by a recognition of the importance of market frictions, such as bid-ask spreads and transaction
costs, in shaping market outcomes and the behavior of market participants. Early market microstructure models
focused on the relationships between market structure, market participants, and market outcomes, and sought to
explain phenomena such as price formation, trading volume, and market efficiency. As the field has evolved, market
microstructure models have become increasingly sophisticated, incorporating new data and insights from related fields
such as financial economics, computer science, and physics. Today, market microstructure models continue to be an
important tool for understanding the behavior of financial markets and the impact of market frictions on market
outcomes. Market microstructure models have evolved significantly in recent years, incorporating new data and
insights from related fields such as financial economics, computer science, and physics.
[email protected]
Algorithmic Trading
Market Impact
Elements of price formation
◦ The mechanism of price formation stems from the complicated interplay between incoming orders (and cancellations) and
price changes due to these orders
◦ Market reaction to trades, termed market impact, describes how much price change immediately and in the near future in
response to the order! mechanical vs induced response
◦ The order flow is composed of market orders, limit orders and cancellations and depends on the state of the book as well on
the past price history
Recap: What is the market impact?
◦ Market impact refers to the correlation between an incoming order (to buy or to sell) and the subsequent price change.
◦ Market impact induces extra costs. Indeed, large volumes must typically be fragmented and executed incrementally. The total
cost of this large trade is quickly dominated, as sizes become large, by the average price impact
◦ Monitoring and controlling impact has therefore become one of the most active domains of research in quantitative finance
since the mid-nineties.
◦ Volume dependence of impact (By how much do larger trades impact prices more than smaller trades?), and temporal
behavior of impact (is the impact of a trade immediate and permanent, or does the impact decay after one stops trading?).
◦ Impact is a dynamic quantity since it depends on the available liquidity, but also on the recent history of my trades.
Why is there market impact?
◦ Agents successfully forecast short-term price movements and trade accordingly. This does result in a measurable correlation
between trades and price changes, even if the trades by themselves have absolutely no effect on prices at all. If an agent
correctly forecasts price movements and if the price is about to rise, the agent is likely to buy in anticipation of it. Noise
trades, with no information content, have no price impact.
◦ The impact of trades reveals some private information. The arrival of new private information causes trades, which causes
other agents to update their valuations, leading to a price change. But if trades are anonymous and there is no easy way to
distinguish informed traders from non-informed traders, then all trades must impact the price since other agents believe that
at least a fraction of these trades contains some private information, but cannot decide which ones.
◦ Impact is a purely statistical effect. Imagine for example a completely random order flow process, that leads to certain order
book dynamics (see, e.g. “zero-intelligence” models). Conditional to an extra buy order, the price will on average move up if
everything else is kept constant. Fluctuations in supply and demand may be completely random, and unrelated to information,
but a well-defined the notion of price impact still emerges. In this case, the impact is a completely mechanical – or better,
statistical – phenomenon.
[email protected]
Algorithmic Trading
Market Impact Models based on Financial Equilibrium
Kyle Model (1985) - Linear Market Impact Model
◦ Kyle, A. S. (1985). Continuous auctions and insider trading. Econometrica, 53(6), 1315-1335.
◦ The Kyle model is often cited as the foundation of the field of market microstructure.
◦ This model was one of the first models to examine the interactions between informed traders and
uninformed traders in a market. The model assumes that informed traders have private information
about the value of security and that they will trade in such a way as to maximize their profits. The
model also takes into account the fact that uninformed traders will trade randomly.
Glosten-Milgrom Model (1985)
◦ Glosten, L. R., Milgrom, P. R. (1985). Bid, ask and transaction prices in a specialist market with
heterogeneously informed traders. Journal of Financial Economics, 14(1), 71-100.
◦ The Glosten-Milgrom model is similar to the Kyle model, but instead of assuming that informed
traders have private information about the value of a security, it assumes that informed traders have
private information about the order flow imbalance in the market. The model shows how this
information can be used to infer the value of a security.
Other early works
Roll Model (1984) - a model for bid spread
◦ The Roll model is one of the first models to examine the role of market makers in a market. The model assumes that market
makers trade with both informed traders and uninformed traders and that they will adjust their quotes to maximize their
profits. The model also shows how market makers can provide liquidity to the market.
Admati-Pfleiderer Model (1987)
◦ The Admati-Pfleiderer model builds upon the Roll model by taking into account the fact that market makers can use their
information advantage to manipulate prices. The model shows how market makers can use their information advantage to
generate profits by exploiting informed traders. Stylized fact on volume and price variability in intraday transaction data.
Implementation shortfall (1988)
◦ “The Implementation Shortfall: Paper versus Reality” by André F. Perold (1988) The author defines the implementation
shortfall as the difference between the expected return of a portfolio based on theoretical models and the actual return of the
portfolio after taking into account the costs of executing trades.
Foucault-Tirole Model (1999)
◦ Market liquidity and its impact on the cost of performance monitoring and market efficiency by market participants. The results
of the model have important implications for market design and regulation.
[email protected]
Algorithmic Trading
Market Impact Models and Optimal Liquidation
Square Root Law (1994)
◦ For many years, traders have used the simple the sigma-root-liquidity model described for
example by Grinold and Kahn in 1994: Active Portfolio Management: “A Quantitative
Approach for Producing Superior Returns and Controlling Risk” by Ronald N. Kahn and
Richard O. Grinold (Grinold Kahn, 1994).
◦ This model was based on the observation that the impact of trade on market prices is
proportional to the volatility of the price process, which in turn is proportional to the
square root of the volume traded.
◦ Given Q as order size, ADV as daily average volume, and σ as daily volatility, T as the
duration of trade as a fraction of trading day, the model is usually in the form of
s
Q
I(Q) = E [∆P|Q, T = 1] = αSpread + βσ
ADV
where α, β are model parameters. Q: Why Square Root? A: Shape of LOB
Almgren-Chriss Model (2000): First in discrete time, then the continuous time in 2003
◦ A dynamic optimization framework for the optimal execution of a portfolio of trades, taking into account the impact of
trading on asset prices. The framework is designed to maximize the expected utility of the terminal wealth, taking into
account the trade-off between the expected price impact of trades and the speed of execution. The authors use stochastic
calculus to model the market impact of trades. The results of the framework provide insights into the optimal trade size and
timing for a portfolio of trades, taking into account the market impact of trading and the trade-off between speed and cost.
◦ It is considered a seminal work in the field of optimal execution and market impact. Similar work: Bertsimas and Lo (1998)
◦ Price: St = S0 + σ 0t dWs where W is a Brownian motion and σ is the daily the volatility. By trading Q shares, the market
R
price moves against us and its dynamic is modeled via the participation rate vs
Z t Z t Z t
St = S0 + σ dWs + I (xs , vs )ds subject to xt = vs ds Q = XT
0 0 0
where xt is the volume of the trade executed at time t, vt is the rate of trading at time t, and T is the total time horizon for
the portfolio of trades. The function I (xt , vt ) captures the impact of trade on market prices as a function of the volume of
the trade xt executed at time t and the rate of trading vt . The shape of I can be examined by market data. In the case of the
linear impact model, It = kv
t , Rwhere k is the constant Rtransaction cost per unit of volume. The optimal liquidation schedule
is the solution of Argminv E[ 0T I (xt , vt )dt] + λVar [ 0T I (xt , vt )dt] for risk aversion factor λ
[email protected]
Algorithmic Trading
Temporary and Permanent Market Impact Models
◦ Stoll, H. R. (1989). Inferring the components of the bid-ask spread: Theory and empirical tests. J. Finance
◦ Different versions based on linear, and nonlinear such as square root, logarithmic, and power-law market impact
models.
◦ These models distinguish between two impact components. The first component is temporary and only affects the
individual trade that has also triggered it. The second component is permanent and affects all current and future
trades equally. A good example is the 2005 paper “Direct Estimation of Equity Market Impact” by Robert Almgren,
Chee Thum, Emmanuel Hauptmann, and Hong Li (2005) based on execution data from Citigroup.
◦ Another example is the continuous extension of discrete permanent/temporary impact: Almgren, Robert F. “Optimal
execution with nonlinear impact functions and trading-enhanced risk.” Applied mathematical finance 10.1 (2003)
◦ In summary: Realized change of price= PermanentImpact + TemporaryImpact + Noise:
θ
Q Q
Temp
I(Q, T ) = E [∆P|Q, T ] = ασ + βσ
ADV ADV × T
Usually, the assumption is that the permanent impact is small and should be linear, while the temporary impact is
more complicated and non-linear.
◦ Empirical results: The average price move during and after the execution. The decay after execution is not well
explained by the above framework, therefore more sophisticated models such as propagators are proposed.
[email protected]
Algorithmic Trading
Propagator/Transient Market Impact Models
Propagator Model (discrete time, origin: Madhavan, Richardson, and Roomans (MRR) model (1997))
◦ The bulk of price the impact is neither entirely temporary nor permanent. It is transient in the sense that it decays or
propagate over a certain time interval after its creation. Clearly, this transient nature of price impact is also responsible for
the the fact that the liquidation costs of trades can be reduced by splitting them into a sequence of smaller child orders.
Order flow is a long memory process therefore the dominant effect is order-splitting.
◦ Bouchaud, Jean-Philippe, et al. “Fluctuations and response in financial markets: the subtle nature of random price changes.”
Quantitative finance 4.2 (2003). Similar work: Obizhaeva and Wang (2005)
◦ The authors propose a new framework for understanding the impact of trades on market prices, based on the idea that market
prices are driven by a complex interplay between supply and demand. They argue that the impact of trade on market prices is
not just a function of the size of the trade, but also depends on the liquidity of the market, the behavior of other traders, and
the history of the market.
◦ The propagator model in Market Impact Models is typically formulated as follows: Let x(t) be the volume of a trade executed
at time t, and let I (t, t ′ ) be the impact of the trade on market prices at time t ′ as a result of the trade executed at time t.
Then the linear propagator model is given by
′ ′
I (t, t ) = K ∗ x(t) ∗ g (t − t )
where K is a constant that depends on the market and g (t − t ′ ) is the propagator (decay factor) function, which describes
the spread of the impact of the trade through the market over time. The propagator function is usually assumed to have the
following properties: It is normalized, such that g (0) = 1 and it decays over time, such that g (t − t ′ ) → 0 as |t − t ′ | → ∞.
The exact form of the propagator function g (t − t ′ ) depends on the particular market and the assumptions made about the
spread of the impact of trade through the market. Common forms of the propagator function include exponential decay,
power-law decay, and Gaussian decay. For example, a Gaussian propagator function might take the form:
(t−t ′ )2
′ −
g (t − t ) = e 2σ 2
where σ is a parameter that determines the spread of the impact of the trade through the market over time.
Transient Impact Model (TIM) (continuous time and application of dynamic programming)
◦ Jim Gatheral, No-dynamic-arbitrage and market impact, Quantitative Finance 10(7) 749–759 (2010).
Z t Z t Z t
St = S0 + σ dWs + I (vs )G (t − s)ds subject to xt = vs ds Q = XT
0 0 0
[email protected]
Algorithmic Trading
Models based on LOB and Order Flow
Order flow from order book: The market order or limit order decision
◦ The Parlour (1998) model, The Foucault Kadan Kandel (2005) model, The Roşu (2009) model, Cont and Kukanov (2013),
Order book from order flow, Bouchaud, Mézard and Potters order book shape approximation, Mike and Farmer empirical law
of order arrivals. Cont and Kukanov (2017) Optimal order placement in limit order markets
The Santa Fe Zero-intelligence (ZI) Model: After an algo vs algo trading tournament at Santa Fe Institute
◦ Daniels, Marcus G., et al. “Quantitative model of price diffusion and market friction based on trading as a mechanistic
random process.” Physical review letters 90.10 (2003): 108102.
◦ Extension of ZI: Smith et al. (2003), Cont and De Larrard (2013)
◦ Market impact as a statistical effect. No designated market makers, everyone can provide or take liquidity. Sometimes
multiple order books compete for liquidity (market fragmentation). Variety of rules (fees, tick size, transparency, latency, etc),
but a common set of order types.
◦ Order book is modeled as a discrete price grid of constant minimum price increment w (the tick size). Limit order placement
follows a Poisson process of rate λ per unit price and unit event time, i.e Limit orders (per price level) arrive at a rate λ.
Market orders arrive at a rate µ per unit event time. Each existing limit order
√ has the same probability ν per unit event time
to be canceled. Spread is proportional to µ/2λ and volatility is scaled at µ ν/λ
◦ Consistent with square root law market impact model. With more realistic rules, zero-intelligence models of the order book
can serve as useful tools for comparing the performance of proposed order execution strategies.
Agent-Based Models of LOB:
◦ Bouchaud and Tóth (2016) considered the market impact of trades in a multi-agent context.
◦ Guéant and Rosenbaum (2015) Mean Field/Game Theory approach
Continuous Time Mathematical Models of LOB
◦ Partial Stochastic Differential Equations (SPDE) for LOB: See Cont and Mueller(2019)
◦ Continuous extension of ZI model: Fokker-Planck equation
Market Impact Models with Order Flow Imbalance (OFI)
◦ Price Impact of Order Flow Imbalance: Multi-level, Cross-sectional, and Forecasting R Cont, M Cucuringu, C Zhang
Machine Learning Models of LOB
◦ Sirignano and Cont (2019) Universal features of price formation in financial markets: perspectives from deep learning,
Quantitative Finance
◦ Fabbri, Mirco, and Gianluca Moro. “Dow Jones Trading with Deep Learning: The Unreasonable Effectiveness of Recurrent
Neural Networks.” Data. 2018.
[email protected]
Algorithmic Trading
Optimal Market Making and Inventory Risk Management
Early works
◦ The Garman (1976) model, Amihud and Mendelson (1980), Stoll (1978) optimal bid-ask computation, Ho and Stoll (1981),
◦ Dynamic programming principle and the Hamilton-Jacobi-Bellman (HJB) equation
◦ Most models based on dynamic programming were not traceable, i.e. no robust solution.
Avellaneda and Stoikov (2008)
◦ Breakthrough. they find an elegant solution and to this day the industry reference for optimal Market Marking
◦ Assume price is St = S0 + σ 0t dWs and let NtB , NtS be cumulative market Buy/Sell orders up to time t. The evolution of
R
stock inventory is given by
B S
dqt t = dNt − dNt
and the MM objective is to maximize its profit over certain admissible controls given a utility function like CRRA
U(x) = −e −αx
−α(xT +qT ST )
h i
max E −e
◦ Extentions: Guéant, Lehalle and Fernandez-Tapia (2013) and Guilbaud and Pham (2013). Cartea, Donnelly and Jaimungal
solve an optimal control problem to find the optimal placement of limit orders using the book imbalance
All inventory models have the following characteristics for
Market Makers:
◦ It is optimal for the market maker to keep inventory close to zero
(Risk Reduction)
◦ There will therefore be the market impact
◦ Market sales cause the price to decrease
◦ Market buys cause the price to increase
◦ For the MM the spread is compensation for risk
◦ The spread is increasing in volatility and in the price of risk
[email protected]
Algorithmic Trading
Kyle Model on single auction with asymmetric information
Kyle Model (1985): application of game theory - no spread assumption
- The Kyle model was one of the first models to examine the interactions between informed traders and
uninformed traders in a market and it remains an important model in the field of market microstructure.
- The Kyle model is often cited as the foundation of the field of market microstructure.
- Three agents competing to maximize their profit: informed trader IT, noise trader NT, market maker MM
- First Market Impact Model: single period/auction Kyle model formulation:
◦ ST ∼ N (S0 , σ02 ): Asset Price at terminal time T , where S0 is the price at time 0
◦ By holding private information, the informed trader IT knows the terminal price (Signal ST ) and then chooses to buy
(ϵ = +1) or to sell (ϵ = +1) a volume q = ϵQ where Q > 0
2
◦ The Noise/Uninformed traders NT submit a random quantity of U ∼ N (0, σU ) (can be sell or buy randomly)
◦ The Market Maker MM observers a total net/aggregated volume V = ϵQ + U, which is matched with her own
∗
inventory through a rule-based clearing price S (V ) (the realized price) as a function of the net order flow V
◦ Who know what? All see S0 , σ0 , σU , IT knows ST and bets optimal Q, and MM observes total V .
◦ The market efficiency condition states that the market maker’s expected profit is equal to zero, conditional on
observing the order flow V . This means the market price S ∗ is determined by the MM by matching the net volume,
∗
S (V ) = E[ST |V ] (1)
◦ Profit maximization condition (IT acts rational!): IT bets optimal q = ϵQ when it maximizes expected profit given
the signal ST (IT does not observe U but knows the distribution of U). Call this the IT trading strategy function
X (q). q maximizes the IT’s expected profit, taking the pricing rule S ∗ by MM.
∗ ∗
q = X (ST ) := Argmaxq E q ST − S (V ) |ST = Argmaxq E q ST − S (q + U) |ST (2)
◦ There exists a Unique Nash Equilibrium if the pricing rule for the clearing price S ∗ (V ) and the IT strategy function
X (ST ) are linear (linear market impact model). A profit maximization condition and a market efficiency condition
∗
X (ST ) = α + βST S (V ) = µ + λKyle V (3)
◦ where λKyle is the model parameter that measures the illiquidity, i.e. the larger the coefficient, the more a given
volume impacts the price and the more expensive the trading activity (adverse selection).
◦ MM knows that there is an informed trader and if the total demand is large (in absolute value) she is likely to incur a
loss. Thus the MM protects herself by setting a price that is increasing in the net order flow.
[email protected]
Algorithmic Trading
Kyle Model on single auction with asymmetric information
◦ Notice Since the price rule S ∗ (V ) is a linear function, the expectations operator has the effect of making the zero-mean noise
trade U disappear from the maximization problem. Note that the noise trade U would not disappear in such a simple
manner if the pricing rule were non-linear, an issue which becomes important when we examine whether non-linear
equilibrium exists.
◦ Looking at the profit maximization condition 2, and assuming linearity in equation 3 yields:
∗
q = X (ST ) = α + βST = Argmaxq E q ST − S (q + U) |ST
h i
2 2
= Argmaxq E qST − qµ − λKyle q − qλKyle U|ST = Argmaxq −λKyle q + q(ST − µ)
Solving Argmax by taking the derivative of the quadratic results in q = (ST − µ)/2λKyle and comparing with q = α + βST
results in α = − 2λµ , and β = 2λ 1 .
Kyle Kyle
◦ Both ST and V = q + U = (ST − µ)/2λKyle + U are normally distributed and by the projection theorem we have
2 Cov (ST , V )
Normal regression (Bayes Rule) E[ST |V ] = E[ST ] + r (V − E[V ]) , Var [ST |V ] = Var [ST ] − r Var (Vt), r =
σV
Now, looking into the market efficiency condition 1, assuming linearity in equation 3, and combing with above:
∗
S (V ) = E[ST |V ] = µ + λKyle V
σ
◦ After the calculations (do it as an exercise to find µ = S0 and λKyle = 12 σ 0 ) we have the full picture
U
1 σ0 ST − S0 σU ∗
λKyle = , q= = (ST − S0 ) , S (V) = S0 + λKyle V
2 σU 2λKyle σ0
◦ Informed trader should trade optimal quantity q = ϵQ proportional to the mispricing ST − S0 and that is greater when it is
possible to hide her demand in the noise traders’ liquidity (measured by σU ), at the expense of the noise traders who are
losing their money. The Kyle model shows that the total order flow impacts the price because of its expected information
content and in the particular case of Gaussian distributed trading volumes the market impact scales linearly with the informed
trader’s volume.
σ
◦ The higher the dispersion of the noise trader’s order quantity (high σU ), the lower λKyle = 21 σ 0 and that indicates lower
U
execution costs. The informed trader can loses money(why?) but on average is in gain
[email protected]
Algorithmic Trading
Kyle Model on single auction with asymmetric information
◦ To summarize: the three agents after seeing price S0 trade at the price S ∗ set by the market maker
◦ after their transaction the price ST is revealed
◦ Market Maker profit ΠMM is zero on average give the volume V and MM sets the price by seeing the volume (V=q+U) and
trading against the IT and NT
∗
ΠMM = −V (ST − S )
∗ ∗ ∗
E [ΠMM |V ] = −V (E [ST |V ] − S ) = −V (S −S )=0
with the condition that MM sets the price linearly in V
∗
S = E [ST |V] = S0 + λKyle V
Exercise: Calculate the unconditional expectation of MM profit E[ΠMM ]
◦ Informed Trader optimal bet q
ST − S0 σU
q= = (ST − S0 )
2λKyle σ0
looking into the profit of IT ΠIT = q(ST − S ∗ ) and substituting S ∗ = S0 + λKyle V and V = q + U
∗ 2
ΠIT = q(ST − S ) = q(ST − S0 − λKyle V ) = q ST − S0 − λKyle (q + U) = q (ST − S0 ) − λKyle q − λKyle qU
[email protected]
Algorithmic Trading
Notation
◦ Expected Slippage, liquidation cost, or total impact: The demand for a large amount of liquidity will typically affect
the cost of the trade in a negative fashion and that is the average cost we pay for trading, including the spread cost.
◦ The procedure for executing an order will affect the average cost per share, according to which algorithm is used.
◦ Let St be the mid-price at t, and St∗ be the executed price at t.
◦ Usually St∗ is less favorable than St since it is deeper in the limit order book.
◦ Let qt be the order quantity to be executed in [t, t + dt]
◦ ϵ the order side. ϵ = 1 for a buy order and ϵ = −1 for a sell order
◦ Take Q = 0T qs ds be the order quantity. And let ADV be the whole day market volume
R
◦ Aim: maximizing the expected utility by finding the optimal trade schedules Minimize Risk (usually Risk =
Var(Slippage or Cost)) and Slippage by finding optimal trading schedule Q = 0T qs ds:
R
[email protected]
Algorithmic Trading
Practitioner’s Execution Benchmark
▶ POV or VolumeInLine
◦ Percentage of Volume (POV) (Reactive): Benchmark price is the price weighted by the participation rate. We execute the
trade with a fixed target participation rate vPOV therefore qt = vPOV Vt for all the times in [0, T ]. The benchmark price
is given by
R TPOV
0 St Vt dt
POVBenchmarkPrice = R TPOV
0 Vt dt
where TPOV the time that enough shares (In practice it is including Q) have been traded that the total volume in the
market is Q/vPOV so we have a constant participation rate vPOV
Z T
POV Q
Vt dt =
0 vPOV
◦ The vPOV is given by the client usually in % such as 10%POV, and the broker keeps trading in a margin close to the
actual POV. The strategy is reactive to the volume observed in the market.
◦ POV with participation rate vPOV is similar to VWAP traded on horizon [0, TPOV ], however, in practice, they are
different, as POV is more reactive to market volume surprises and usually more aggressive and not a good candidate for
low liquidity instruments.
▶ Target Close MOC / Target Open MOO - qt = Q1t∈Close/Open
◦ Last/First price of the day. Usually is determined via an auction lasting for 5 minutes plus a random time in order avid
price manipulation. The Close auction volume can be huge, around 15% to 20% of the daily volume in EMEA.
◦ Close and Open auctions are attractive for large passive liquidity.
◦ Also a benchmark price for many future contracts and derivatives.
◦ Intuition: MOC strategy is the reverse of IS, and MOO is similar to IS with the arrival price to be the auction price.
▶ Market Impact in practice
◦ The participation rate as a function of the volume is a historical estimate of the actual unknown volume. So there is
always a deviation from the actual ideal benchmark. (The full volume profile is only revealed at T). Using volume time
instead of time. Time is scaled by the volume curve Vt /ADV so [0,T] goes to [0,1] scaled by trading activity (volume).
The continuous time problem is discretized. The optimization is simplified to quadratic or conic optimization. The case of
the portfolio is also considered. The constraint depends on the algo, benchmark, and client max cap. Usually, there is no
close-form solution: Numerical approximation of the solutions
[email protected]
Algorithmic Trading
Optimal Execution under Almgren-Chriss Model
◦ Fair price: Martingale St = S0 + σ 0t dWs where W is a Brownian motion and σ is the daily the volatility.
R
◦ Trading Q > 0 shares (ϵ > 0 for buy order and ϵ < 0 for sell order) over horizon [0, T ], with participation rate
Z T Z t
qt
v (t) = ∀t ∈ [0, T ] subject to Q = qt dt, define Qt = qs ds
Vt 0 0
by executing qt dt shares at [t, t + dt] the market price moves against us and the dynamic of the price at which
transactions occur is given by the linear form
∗
St = St + ϵI (qt )
◦ We can summarize the deterministic trading strategy in the shape of the q process. qt is the trading rate, how fast or
slow we are trading at time t, and vt is the participation rate, or what is our share of the market volume at time t. We
assume that the volume profile in the market is uniform or Vt = ADV is constant and Volume in the market during our
trade is 0T Vt dt = T × ADV , so time is the same as volume time and trade duration is the same as trade horizon.
R
Rt
◦ 0 qs ds is our inventory at time t. We start with zero and end up with Q shares in our inventory. Strategy qt is the
volume of the trade executed at time t, vt is the rate of trading compared to the market at time t, and T is the whole
time horizon of our trading.
◦ The function I (qt ) captures the impact of trade on market prices as a function of the trading rate qt .
◦ The shape of I can be examined by market data. In the case of the linear impact model, It = kqt , where k is the
constant transaction cost per unit of volume.
Z t
∗
St = St + kqt = S0 + σ dWs + ϵkqt
0
The Profit and Loss (P&L) or Wealth function Π for the trader at any time is given by the total number of shares traded
(bought or sold) times the execution price :
Z t
∗
Π(t) = Ss qs ds
0
Z t
= (Ss + ϵkqs )qs ds
0
Z t Z t
2
= Ss qs ds + ϵk qs ds
0 0
[email protected]
Algorithmic Trading
Optimal Execution under Almgren-Chriss Model
Z T Z T
2
Π(T ) = St qt dt + ϵk qt dt
0 0
∗ 2
St = St + ϵkqt , St = S0 + σWt , dSt = σdWt , St ∼ N (S0 , σ t)
◦ Exercise Show that both Π(t) and St∗ are normally distributed (Hint: Use integration by parts based on Itô formula)
Using Integration by parts on St and 0t qs ds we get
R
Z T Z T Z T
St qt dt = St dQt = QT ST − Qt dSt
0 0 0
Z T Z t Z T
2
Π(T ) = QST − qs ds σdWt + ϵk qt dt
0 0 0
Z T Z T Z t Z T
2
= QS0 + QσdWt + qs ds σdWt + ϵk qt dt
0 0 0 0
Z T Z T Z t
2
= QS0 + ϵk qt dt + σ Q− qs ds dWt
0 0 0
Z T Z T Z T Z t
2
= QS0 + ϵk qt dt + σ qs ds − qs ds dWt
0 0 0 0
Z T Z T Z T
2
= QS0 + ϵk qt dt + σ qs ds dWt
0 0 t
◦ Exercise Show that mean and variance of Π(T ) are given by
Z T
2
E[Π(T )] = QS0 + ϵk qt dt (4)
0
Z T Z T 2
2
Var [Π(T )] = σ qs ds dt (5)
0 t
[email protected]
Algorithmic Trading
Optimal Execution under Almgren-Chriss Model
▶ Liquidation Cost Measures
◦ Average Execution Price, weighted by order quantity:
RT ∗ Z T Z T Z T
∗ S qt dt 1 ∗ Π(T ) 1 ϵk 2
S0,T = 0R T t = St qt dt = = St qt dt + qt dt
0 qt dt
Q 0 Q Q 0 Q 0
substituting equations 4,5 for mean and variance of Π(T ) we get the mean and variance of the slippage (Notice ϵ2 = 1):
σ2
Z T Z T Z T 2
k 2
E [Sllipage] = qt dt Var [Sllipage] = qs ds dt
QS0 0 2 2
Q S0 0 t
◦ Liquidation Cost (absolute Cost requires CARA utility) with respect to the arrival price S0 (IS Cost similar to IS
Slippage) is given by
Z T
∗ ∗
Cost = ϵ St − S0 qt dt = ϵQ S0,T − S0 = ϵ (Π(T ) − QS0 )
0
substituting equations 4,5 for mean and variance of Π(T ) we get the mean and variance of the Cost function:
Z T Z T Z T 2
2 2
E [Cost] = k qt dt Var [Cost] = σ qs ds dt
0 0 t
◦ Notice minimizing both Slippage and Liquidation Cost looks identical. However, we need to use a proper utility function
for each cost measure. Slippage is a relative relative cost measure and requires a CRRA utility function, while Liquidation
Cost is an absolute cost measure and requires a CARA utility function. The latter is easier to use when applying to a
normally distributed random variable.
◦ Similar to the wealth process Π, the average execution price, slippage, and liquidation cost are all normally distributed.
◦ Average Cost measures the market impact of the execution.
[email protected]
Algorithmic Trading
Optimal Execution under Almgren-Chriss Model
◦ Variance of the Cost measures the timing risk of the execution, i.e. the risk of missing the arrival price and it is
proportional to volatility σ and the remaining execution quantity tT qs ds.
R
▶ Objective Function
◦ Trader objective is to maximize its profit over certain admissible controls given a utility function like CARA
U(x) = −e −γx for some risk aversion factor γ
h i
−γΠ(T )
Argmaxq E −e
◦ Because Cost is normally distributed this is equivalent to a mean-variance optimization. This can be formulated by the
2 2
characteristic function of the normal distribution as E[e isZ ] = e isµ−σ s /2 for any normal distribution Z ∼ N (µ, σ 2 )
◦ Therefore the optimal strategy is the solution of the following mean-variance minimization
Argminq E [Cost] + γVar (Cost)
▶ Optimal Strategy
For given risk aversion factor γ the optimal strategy q minimizes the objective function
Z T Z T Z T 2
2 2
Argminq k qt dt + γσ qs ds dt
0 0 t
◦ The AvgCost looks like kinetic energy and the RiskCost (TimingRisk) is like potential energy, and the objective function
looks like the objective in mean-variance portfolio optimization.
◦ Solution: Objective function as a function of two variables and using Euler–Lagrange equation in variational calculus:
Z T
dx(t)
min F (x(t), y (t))df , s.t y =
x(t) 0 dt
Stationary to small perturbations requires that the optimal x(t) solve the Euler-Lagrange equation
∂F d ∂F
− =0
∂x dt ∂y
[email protected]
Algorithmic Trading
Optimal Execution under Almgren-Chriss Model
▶ Special case where γ = 0: VWAP is the Optimal Strategy with no risk aversion
Z T
2
Argminq k qt dt
0
[email protected]
Algorithmic Trading
Optimal Execution under Almgren-Chriss Model
also
′ ′
y (t) = x (t) = (Q − Qt ) = −qt
then by Euler-Lagrange equation
∂F d ∂F 2 d
− = 0 → 2γσ x(t) − 2k y (t) = 0
∂x dt ∂y dt
or
2 d ′ 2 ′′
γσ x(t) − k x (t) = 0 → γσ x(t) − kx (t) = 0
dt
we get the following linear second-order homogeneous ODE
s
′′ 2 γσ 2
x (t) − θ x(t) = 0, θ = , subject to boundary condition x(0) = Q, x(T ) = 0
k
by solving the above ODE for x(t) = Q − Qt , we get the optimal execution strategy Qt as following
!
sinh (θ(T − t))
Qt = Q 1 −
sinh (θT)
▶ Efficient Frontier
[email protected]
Algorithmic Trading
Sample Question
◦ Q1 In the Almgren-Chriss Model, the stock price is following the following SDE
St = S0 + σWt t ∈ [0, 1]
where S0 is the initial price, σ is the daily volatility, and Wt is the standard Brownian Motion with
normal distribution N (0, t). A trader is executing Q shares (QR> 0 to buy, Q < 0 to sell) during
[0, T ] interval where T <= 1. The inventory process is Qt = 0t qs ds for the deterministic strategy
process q where the terminal inventory is QT = 0T qt dt = Q. Each time the trader executes qt
R
shares at interval [t, t + dt] the execution prices are given by the following linear market impact
model
∗
St = S0 + σWt + kqt t ∈ [0, 1] s.t. qt = 0 if t > T
where the positive constant k is the given model parameter.
◦ A Show that St∗ has a normal distribution at each t ∈ [0, T ] and find its mean and its variance.
◦ B Plot the expected value of the average execution price during and after a buy TWAP strategy
(VWAP when the volume curve is flat) and discuss if this is consistent with the imperial analysis in
the industry.
◦ C Show that the wealth process 0t Ss∗ qs ds has a normal distribution at each t ∈ [0, T ]. Also, find
R
it’s mean and its variance in terms of q and Q processes. (Hint: use the product formula)
[email protected]
Algorithmic Trading
References I
Frédéric Abergel, Jean-Philippe Bouchaud, Thierry Foucault, Charles-Albert Lehalle,
and Mathieu Rosenbaum, Market microstructure: confronting many viewpoints, John
Wiley & Sons, 2012.
Jeffrey M Bacidore, Algorithmic trading: A practitioner’s guide, TBG Press, 2020.
Jean-Philippe Bouchaud, Julius Bonart, Jonathan Donier, and Martin Gould, Trades,
quotes and prices: financial markets under the microscope, Cambridge University Press,
2018.
Álvaro Cartea, Sebastian Jaimungal, and José Penalva, Algorithmic and high-frequency
trading, Cambridge University Press, 2015.
Olivier Guéant, The financial mathematics of market liquidity: From optimal execution
to market making, 2016.
Stefan Jansen, Machine learning for algorithmic trading, Packt Publishing, 2020.
Barry Johnson, Algorithmic trading & DMA: An introduction to direct access trading
strategies, vol. 1, 4Myeloma Press London, 2010.
Robert Kissell, The science of algorithmic trading and portfolio management, 2013.
Raja Velu, Algorithmic trading and quantitative strategies, Chapman and Hall/CRC,
2020.
[email protected]
Algorithmic Trading