LEARN/EXECUTION COST

Execution cost

Every TCA vendor approximates one missing number: what the price would have done if you had never traded. Here you can run that world.

ex = tf.tca.analyse(
    my_algo, seed=42,
    universe=u, days=5)

ex.shortfall_bps()   # what it cost
ex.by_step()         # where
ex.partial_fills()   # asked vs got

Two runs, one seed

The run with your orders Your fills, at the prices the book gave you.
The run without them The same seed, the same world, and no trades from you. Subtract one from the other and the difference is your footprint.

Where the cost comes from

There is no slippage formula in the code. A big order pays more because it takes the levels that rest above it. Below is one market buy for 175 shares, replayed from the engine's own reference program.

The book before the order

ask 101.00 50
ask 102.00 110
ask 103.00 120
bid 99.00 100
bid 99.00 50
bid 99.00 25

What 175 shares cost

50 @ 101.00 from bob
110 @ 102.00 from mm
15 @ 103.00 from mm
101.8000 Average fill, against 101.00 on screen when the order arrived. That is 79 basis points, paid to depth.

The number nobody else can measure

Arrival price, VWAP and fitted impact models all stand in for a counterfactual that real data can not supply. Round-trip shortfall measured over eight simulation seeds:

-17.72 bps 0 +2.03 bps

The range crosses zero, so a round trip can end up ahead. This happens when the market moves your way during the order. It is the reason one run tells you nothing about your algorithm.

One known boundary: the fear gauge leaks

VIX drives the market factor's variance, so the market prices fear of your flow. Names that you never touched can move a few basis points through that channel. That is impact, not an artefact of the measurement. If you need the subtraction to be exact, pin VIX in both worlds and the two runs match byte for byte.

All pages