tcakit
A small, tested library for the three questions an execution desk actually asks.
What did this order cost, and why? Perold implementation-shortfall decomposition into delay, spread, timing, opportunity and fees, with an exact identity: the components sum to the total to 1e-9, a sell flips every sign, and an unfilled order is pure opportunity plus fees. Option costs come out in dollars per contract, as a fraction of the half-spread, and in delta-adjusted basis points.
Which broker, venue, algo or tier is cheaper, after controlling for difficulty? Grouped costs with bootstrap intervals, then the mean residuals of a difficulty regression. That’s the number that survives “your orders were just harder.”
What will a new order cost? Square-root law, Almgren et al. (2005), and Kissell I-star.
Every fit carries n_in, n_out and an out-of-sample RMSE, held out by day, alongside the
usual R².
The rule that shapes the library
Estimators are tested for parameter recovery on a seeded synthetic market with known impact, rather than merely for running. On 950 orders at realistic noise the square-root law’s single coefficient is identified (the true value sits inside the interval) while a free exponent is not: the interval on the exponent spans the whole literature range.
That’s why desks fix the exponent. The library shows you the reason instead of printing a point estimate.
Small decisions that matter
Missing mids give NaN, never zero. A component the data can’t identify, like delay without a decision timestamp, is reported as zero by construction rather than hidden. And an n-gate states whether the sample is large enough for any impact number to be quoted at all; below 50 parent orders, it isn’t.
An adapter for per-child JSONL logs of multi-leg option combos ships with it, and produces a full post-trade report from a single command.