Skip to content

Releases

execution-simulator 0.1.0

Choose a tag to compare

@IkerAbad IkerAbad released this 23 Nov 16:35

execution-simulator 0.1.0

Execution cost simulator for large orders: Almgren-Chriss optimal schedules, a finite-depth book with partial replenishment, and cost-risk frontiers. No external optimisation library: the optimum is derived by hand.

Model

  • Linear permanent and temporary impact in the Almgren-Chriss tradition, including the discrete correction eta_eff = eta - gamma*tau/2.
  • Closed-form moments of the implementation shortfall:
    E[IS] = ½·γ·X² + s·X + (η − ½·γ·τ)/τ · Σn² and Var[IS] = σ²·τ·Σx².
  • Finite-depth ladder with exact level consumption, static (refill = 1) or partially replenishing (refill < 1), exhaustible beyond the deepest visible level.
  • Monte Carlo engine that reproduces the analytic mean and standard deviation.

Algorithms

Immediate execution, TWAP, VWAP on a synthetic U-shaped volume profile, POV with an endogenous horizon, and the Almgren-Chriss optimum.

The optimal schedule is solved twice by different routes: the hyperbolic closed form x_k = X·sinh(κ(T−t_k))/sinh(κT) with cosh(κτ) = 1 + λσ²τ²/(2η̃), and a hand-written Thomas solver for the first-order conditions. Both must agree.

Main result

TWAP is the exact optimum only for a risk-neutral trader. At λ = 1e-6 its mean-variance cost is 24.9% higher than the Almgren-Chriss schedule's, and one extra basis point of expected cost buys 39.8 bp of standard deviation.

With a depleting book (refill = 0.25) the advantage of front-loading falls from 17.6% to 2.8%. With no replenishment at all the temporary cost becomes path independent (4e-11 bp across the five schedules) and immediate execution wins outright: 61.07 bp of objective against 65.14 for Almgren-Chriss and 69.14 for TWAP. The whole benefit of slicing comes from the book refilling.

Published rather than hidden: between refill = 0.3 and refill = 0.7 the POV schedule beats the Almgren-Chriss one by up to 0.13 bp (1% of the objective), because the optimal schedule minimises the linear model, not the running book.

Validation

  • 168 tests, 99% coverage, ruff and mypy --strict clean in CI.
  • Closed-form schedule matches the Thomas solution to 2.9e-11 shares on a 100,000-share order.
  • Monte Carlo mean and standard deviation match the analytic values within sampling error.
  • Regenerating the report from the PyPI wheel reproduces results/summary.md byte for byte and all six figures.

Install

pip install execution-simulator==0.1.0
execution-sim compare