0% found this document useful (0 votes)
151 views46 pages

Market MicroStructure

Uploaded by

yiyangsong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views46 pages

Market MicroStructure

Uploaded by

yiyangsong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Market Microstructure

Week 4

traders.berkeley.edu
Announcements

● Ask questions!!!
○ If something is unclear to you, it’s unclear to others as well.
● See Ed regarding quizzes/HWs.
Brainteaser/Warmup
This connects pretty directly to today’s lecture, let’s see how.

● You have 10 X_i’s which are IID uniform (0, 1) random variables. What is
● E[min({X_i})]
● Var[min({X_i})]
Solution
The probability density function is min({X_i}) = 10(1-x)^9. The rest is just
integration.

You can also find the expectation by symmetry.


Agenda
● Exchanges
● Settlement
● How Trading Firms Interact with Exchanges
○ Where they make money from this
● The Latency Game
● Trading is like Space
Why does this matter?
● The vast majority of trading is done electronically. This means that all trades
have to go through a computer program to be executed. If you can
understand that program better than anyone else, you can make a lot of
money.
● Exchanges make the rules for the game you play
Why do Exchanges Exist?
● Stocks are companies listed on major exchanges
○ The New York Stock Exchange (NYSE) is the largest and arguably the most important
○ The other important exchange is Nasdaq, formed in 1971 to trade securities electronically
● A full history of stock exchanges:
○ 1300s: Venetian moneylenders began to sell debt issues to lenders and individual investors
○ 1500s: Evidence of an exchange in Antwerp, Belgium, dealing in promissory notes and bonds
○ 1600s: The emergence of East India companies that issued stock led to a financial boom,
although this was followed by a bust when it was realized some companies did nothing
● Prior to the increased prominence of electronic trading, there existed a
trading pit at the exchange where traders would verbally place orders to
brokers
● In the modern era, face-to-face trading is all but dead
Public Exchanges
● Two main equities exchanges in US: NYSE and Nasdaq
○ 13 US equities exchanges. “Fragmented” structure. Intercontinental Exchange (ICE).
○ Unfragmented securities exchanges?
● Exchanges operate in a limit order book system:
○ Traders constantly send the prices they’re willing to buy and sell a security at
○ The central order book is publicly displayed for traders to make informed bid and ask offers
● Designated market makers “manage” specific securities on exchanges
○ The market maker determines the overall buy-sell imbalance and establishes a fair value price
based on market information
○ Market makers’ value in exchanges: liquidity providing, short-term price discovery
National Best Bid and Offer (NBBO)
● The NBBO is a quote that reports the highest bid and the lowest ask on a
security, sourced from all available exchanges or trading venues
○ The NBBO represents the tightest composite bid-ask spread in a security
● Regulation NMS
● What are some issues with this?
○ Hint: it takes ~3 ms to sync all exchanges
NBBO Example
Suppose a broker receives the following orders to offer to sell stock for company ABC:
● 200 shares for $1,000
● 300 shares for $1,500
● 100 shares for $1800
● 350 shares for $1,600
At the same time, the following are available bid prices for the same company's stock:
● 100 shares for $900
● 200 shares for $800
● 150 shares for $950
What is NBBO?
NBBO Exceptions
● Orders on exchanges are routed to the exchange with the best price.
○ What incentives does this give to exchanges?
● Traders can tell exchanges not to do this if they plan on sweeping NBBO
○ Why?
● Trading outside market hours
Types of Orders
Market Orders
● A market order specifies to the algorithm to buy or sell at the best available
market price
● Order executed fastest & most reliable because there are no restrictions on
its price
● Disadvantage: in today’s markets, prices can move away so quickly that
execution price be vary drastically from the time the order was routed
● Removes liquidity from the market: taking off shares from the Order Book to
fill your order
Limit Orders
● Buy or Sell at the specified limit price or
better
● Not guaranteed to execute, but provides
some safety surrounding the execution price
○ However, this makes limit sells risky because if
your sell price is skipped and the security keeps
going down your loss you’re in a bad spot
○ Commonly if a limit is skipped you convert to a
market order
● Market makers sometimes get trading
subsidies for increasing liquidity through
limit orders
Limit Order Books
● A limit order book is a record of outstanding limit orders maintained by the
security specialist who works at the exchange
● This is how exchanges internally store lists of resting orders to match against
incoming orders
The Matching Engine
● The matching engine is the algorithm used to match incoming (agressing)
orders to orders on the exchange (resting).
● There are two main types:
○ Price-Time Priority - Where the resting order at the best price which was placed first, gets
executed against firm
○ Pro Rata - Where all orders at the best price are executed against proportional to their
fraction of the liquidity at that level.
● Examples:
○ I want to lift 10 at the offer, which is @10.35. This level has three orders, which were placed at
9:12.12, 9:12.11, and 9:12.14, which have sizes 10, 15, 25. How much does each order get
filled in
■ A price time prio exchange?
■ A pro rata exchange?
Rebate Structures
● Maker-Taker rebates:
○ There is a fee for removing liquidity and a rebate for providing
○ Why would someone want to trade on this exchange?
○ Most exchanges are this.
○ Usually 30 cents per 100 lots.
● Taker-Maker rebates:
○ The opposite of Maker-Taker
● Which one might you expect to have tighter spreads and can you derive an
arb when this isn’t the case?
Okay, but what happens after a trade gets made?
● It along with a timestamp gets recorded for later settlement, where shares
actually change hands and contracts expire
Counterparty Risk
● The risk that the counterparty on a financial contract defaults on its
agreement prior to expiration, and not make (all) payments
● Exchange trading reduces risk significantly, primarily a problem in OTC
derivatives broadly
○ Swaps
○ Forwards
○ Repos
○ Exotic options
● Common ways to offset counterparty risk:
○ Trading with counterparties you’ve built a relationship with
○ Holding collateral
Central Clearing Party
● CCP becomes buyer to every seller and seller to every buyer
● Clearing members’ counterparty risk is to CCP now, mitigates risk
● Clearing member: special participants (qualified firms) that clear transactions
for themselves / their customers
○ CCP has no legal obligation to members’ customers
Settlement time
● Number of business days after transaction that security / financial instrument
must be delivered
● Historically, settlement times were much longer b/c of physical delivery of
things like stock certificates (stocks used to be T+5)
○ T+2
■ Stocks, bonds, spot forex
○ T+1
■ Options, government securities
○ T+0
■ Crypto (almost)
● Shorter settlement better
○ Lower counterparty / settlement risk
○ More efficiency in the market, lower liquidity requirements to participate (faster access to
funds)
Regulation NMS
Regulation National Market System

Implemented in 2005 by SEC to get more competition in the


market and make it easier for consumers to access market

Before Reg-NMS, HFT firms used to arbitrage the market


(between exchanges) left and right!

You’d think HFT firms would be mad about this but they were
the ones who understood the exchanges best, had the best
technology, and the incentives to act on these new rules
Dark Pools, briefly
Basically private, dark (not lit) exchanges!
A decade ago there used to be like 5, now there’s dozens
40%-50% of US equity trades happen on dark pools
You send orders into the pool, and if there’s a trade to be made, you will get traded
Who runs dark pools? Banks and other large financial institutions (pay to be in the pool)
Usually trade at NBBO midpoint, even if
Ex: NBBO is $100 @ $101, dark pool resting buy at $102; someone sends a sell at $100
Transact at $100.50 (NBBO mid) regardless => Very little information leakage to public!
How does PFOF work with NBBO?
AKA why does Citadel Securities pay Robinhood $800 million every year?
Robinhood routes their customers’ order to CitSec (or IMC, etc.) and CitSec packages them
into a bulk order (package a bunch of 5-share buys into a 10,000 share buy)
NBBO is $150 @ $151
CitSec sells 10,000 shares of AAPL to the RH consumers at $150.90 => price improvement!
Now they’re short 10k AAPL shares, so they go to dark pools to buy back the shares
Go to dark pool with Goldman Sachs and trade at NBBO midpoint ($150.50) to buy shares
CitSec profits $0.40 per share, Robinhood customers get price improvement ($0.10/share)
Payment for Order Flow (PFOF)
Robinhood bundles user order flow and sells it to trading firms,
which are rewarded for good execution
Trading firms need to provide good execution or they will get less flow
Options - Orders must be put on exchange regardless of who pays for it
Equities - Orders can just immediately be internalized by the firm (so far)
Why pay for order flow?
Is this all bad for you?
● No you get a discount on the spread, but that doesn’t really change the fact that the
trading firm still wins too.
● It is illegal for a trading firm to use your order flow to inform their trading.
What Makes Execution Good?
● Price improvement
● Speed
● Each seller weights these factors differently.
Game - Order Execution Optimization
Break and Questions
The Futures Chain
● Futures have an expiration date, where the underlying product needs to be
delivered to the holder of that future.
● Exchanges will typically have monthly expiry futures contracts.
Quick Intro To Options
● Options are characterized by both an expiry and a strike price
● Call options give the holder the right to buy a security at a specified price
● Put options give the holder are the right to sell a security at a specified price
● European options: can only be exercised on expiry
● American options: can be exercised any time before expiry
The Option Chain: Scaling Complexity
● Options have an extra dimension, which means that the exchange stores
options both by expiry and strike price
● There are many similarities between options which are close on the
strike/expiry surface, especially when we go out into the extremes.
● Because there are so many more options, the spreads will often be much
wider.
○ Why might a mispricing in the options space might not be good?
How does a trading firm interact with an exchange?
● The HFT stack!

● Quick reminder on different measurements of speed:


Break and Questions
An overview of a trading system
● The theoretical value calculation in the “brain”
● Server location
● Wire-to-wire time
● The execution layer
● FPGAs

Let’s draw it out!

Some important intra-exchange and inter-exchange latencies


Why does being smart with exchanges matter?
● Smarts - the “hidden edge”
○ Smarts isn’t just predicting the price! You can be smarter at how you interact with the
exchange.
● First bit trading
○ Measuring and replacing wires (future slide).
○ Tons of other examples we can’t get into.
● Better rebates
○ Registered market makers, Designated market makers
○ Getting drinks and talkin ‘em up
● Talent: The exchanges’ revolving door
Being Smart About Trades
● Quants (researchers) use statistical techniques and a deep understanding of
the exchange and assets being traded to come up with fair and relative value
for every asset they trade.
● This often involves using alphas and signals to derive relative pricing for
assets and trade around these relative prices.
● Focus: being right, not necessarily the fastest.
● Questions:
○ Is there a situation where you would ever make a trade that your theoretical value
disagrees with?
Being Smart About Trades: Example
● Our pricing model indicates that the fair value for the AAPL 100 Call should
be $57. What trade should you make if
○ The current NBBO is [email protected]?
■ Lift the offer!
○ The current NBBO is [email protected]?
■ Hit the bid!
○ The current NBBO is [email protected]?
■ Nothing.
Trading is like empty space
● There are very few good opportunities (relatively speaking) and everyone
wants them.
● https://joshworth.com/dev/pixelspace/pixelspace_solarsystem.html
Being Fast about Trades (C++ and execution)
● The brains of the trading operation cannot possibly react to all the market
info it receives, so there is often a second execution layer.
● Core primitives:
○ Written in a low level language like C++.
○ Able to slightly adjust theoretical value based on incoming market data.
● Often used to flash cancel all orders during unstable market conditions.
Being even Faster about Trades (FPGAs)
● Take high-level software out of the picture. Many logical operations and
mathematical operations can be run on specialized hardware (FPGAs) using
Verilog.
○ FGPA vs ASICs
● These are much faster than even C++, because the hardware itself it
programmed to react:
● These are often used to adjust resting limit orders and spreads.
● They are fast enough to ensure a trading firm is always on the market and
offering liquidity.
Wire-to-Wire and Networking Time
● The only thing a trading firm can now control is how long it takes:
○ The time it takes for the trading system to read the packets from the exchange
○ To the time the firm sends orders back.
● You can only make your strategy/execution layers faster.
Incoming market data
● Measuring and replacing cross-connects
○ Tolerances in wires
● Hardware vs software switches
Trading Firm Exchange

Outgoing orders
Colocation: History
● The speed of light is actually a limiting factor in trading. Trading is often
done on the scale of micro- and nano- seconds.
○ Light travels about a foot in a nanosecond
● Firms would often compete to be the closest to the exchange, buying nearby
servers or buildings, or even hanging wires out of windows to reduce latency.
● Exchanges thought this was unfair, so they came up with a solution.
Colocation: Solution
● Exchanges sell nearby server space!
○ For a lot of money
● They also only allow connects with wires of a fixed length.
○ How do you deal with wire variance?
● This levels the distance-latency playing field.
Cross-Exchange Speeds
● Information from one exchange matters a lot at another exchange!
● McKay Brothers
Questions?

You might also like