Basic

Market microstructure

A fill is not a price. It is a queue position, a size limit, and a market that moves while you wait. Microstructure is the part of the cost that a daily backtest cannot see at all.

What you will see

A statement that the strategy does not exist at that size. That is the honest result.

About 1 min of reading

Try It

Measure one fill against one assumption

1

Write the assumed price

printf 'assumed 101.20\n' > /tmp/fill.txt; cat /tmp/fill.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One price, the one the backtest used.
2

Write the measured fill

printf 'assumed 101.20\nfill 101.05\n' >> /tmp/fill.txt; awk -F' ' '$1=="fill"{f=$2} $1=="assumed"{a=$2} END {printf "%.2f\n", f-a}' /tmp/fill.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
0.15 worse. That gap is the cost the backtest did not know.
3

Compare the gap to the edge

echo 'edge 0.12 gap 0.15 -> the cost is larger than the edge'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A statement that the strategy does not exist at that size. That is the honest result.

Data Flow

An order to a measured fill
1 An order is placed with a size
↓
2 The book gives the queue position
↓
3 The market moves while waiting
↓
4 The fill is measured against the assumed price
Why this works
Why the book is needed at all

Without the book there is no queue and no size limit. The backtest is not wrong, it is blind, and blind is the expensive kind of wrong.

The one measurement that fixes most of it

Fill price measured from the tape against the price you assumed. One number, and it is the number that decides if the strategy is real.

Examples

The queue is the cost

A limit order sits behind others. The distance to the top of the queue is the price you pay to be seen.

Why size matters here

A size that cannot fit at the top of the book cannot be filled at the price you assumed. The assumption is the leak.

The two fills are different trades

A limit fill and a market fill are not the same trade. A backtest that uses one price for both is measuring one of them.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Sizing with Kelly
Previous Lesson
Sizing with Kelly
Next Lesson
Data feeds and what they hide
Data feeds and what they hide →