Almgren–Chriss Optimal Execution in Python: Scheduling a Large Equity Order

This article is built from the primary papers by Almgren and Chriss and Almgren et al., alongside the model overview, as a documentation-based walkthrough: it does not describe hands-on trading or live broker fills, and makes no claim of cost savings. Every number is checkable against the cited sources: Almgren & Chriss (2000), Almgren et al. (2005), and Wikipedia — Almgren–Chriss model.

Why is executing one large order a scheduling problem, not a prediction problem?

A large equity order sliced into N trades over horizon T faces a scheduling trade-off: bunch trades and market impact rises; linger and timing risk accumulates. Almgren–Chriss (AC) models that tension as mean-variance optimization, not a forecast of price direction. Bertsimas and Lo derived the risk-neutral linear-impact trajectory first; AC added risk aversion, the permanent/temporary impact split, and closed-form trajectories.

The price process is:

S_k = S_(k−1) + σ√τ ξ_k − τ g(n_k/τ)

Here, ξ_k are independent shocks with zero mean and unit variance. The model has no drift term: it assumes no information about future price direction. The execution price is:

S̃_k = S_(k−1) − h(n_k/τ)

The distinction matters: the execution price includes temporary impact, while the next market price does not.

What are the two impact components, and why must they be split?

Permanent impact shifts future market prices; temporary impact worsens the current fill but, in this model, does not affect the next market price. AC’s linear forms make that separation explicit. It is a modeling assumption, not a universal description of market response, and it helps make expected cost and variance tractable.

g(v) = γv
h(n_k/τ) = ε·sgn(n_k) + (η/τ)n_k

The permanent-impact coefficient γ is measured in ($/share)/share. The temporary-impact coefficient η is measured in ($/share)/(share/time). ε, in $/share, represents half the bid-ask spread plus fees. Under AC’s price and execution-price definitions, g changes subsequent market prices, while h affects only the current execution price.

What exactly are E(x) and V(x)?

E(x) is expected implementation cost in dollars, and V(x) is shortfall variance in dollars squared. The expected cost is essentially what Perold (1988) calls implementation shortfall. With linear impact, its temporary-impact term uses adjusted η̃; strict convexity requires η̃ to be positive.

η̃ = η − 1⁄2γτ

E(x) = 1⁄2γX² + ε·Σ|n_k| + (η̃/τ)·Σn_k²
V(x) = σ²·Στ·x_k²

For a buy order, X is total shares, n_k is the number traded in interval k, and x_k is the remaining position. V is exactly the variance under Gaussian shocks; otherwise, it is the model’s variance measure. The condition η̃ > 0 keeps the quadratic expected-cost objective strictly convex.

Two useful references are constant-rate execution and immediate liquidation:

Constant rate:
E = 1⁄2γX² + εX + (η − 1⁄2γτ)·X²/T
V = (1/3)σ²X²T·(1 − 1/N)(1 − 1/(2N))

Immediate liquidation:
E = εX + ηX²/τ
V = 0

Immediate liquidation has no timing variance within the model’s horizon, but pays its temporary impact over one interval.

What is the efficient frontier, and what does λ actually mean?

The efficient frontier contains schedules for which no alternative has lower variance at the same or lower expected cost, or lower expected cost at the same or lower variance. AC constructs it by minimizing E(x) + λV(x). The parameter λ is the curvature of a smooth utility function, with units of $⁻¹; higher λ increases risk aversion and front-loads execution.

At λ = 0, the schedule is linear, or TWAP-like. AC says that in a certain sense this naive schedule is “never an optimal strategy”: a modest increase in expected cost can buy a large reduction in variance. As λ → ∞, the solution approaches immediate liquidation. In between, λ sets the cost–risk trade-off rather than expressing a directional view.

The solution is static and time-homogeneous under the paper’s fixed quadratic utility: re-optimizing later continues along the same path. This is a property of the model and objective, not a guarantee that an unchanged schedule remains appropriate when market conditions change.

What is the closed-form trajectory, and what are κ and the half-life θ?

The optimal remaining position follows a hyperbolic-sine curve, with trades given by a hyperbolic-cosine list. κ controls how quickly the position is depleted, and θ = 1/κ is the time to reduce it by a factor of e. That half-life is independent of the total horizon T.

The discrete first-order condition and its solution are:

(1/τ²)·(x_(j−1) − 2x_j + x_(j+1)) = κ̃²·x_j
κ̃² = λσ²/η̃

x_j = X·sinh(κ(T − t_j)) / sinh(κT)

n_j = [2·sinh(1⁄2κτ) / sinh(κT)]
      · cosh(κ(T − t_(j−1⁄2)))·X
t_(j−1⁄2) = (j − 1⁄2)τ

In the continuous-time limit, κ ≈ √(λσ²/η): risk-scaled volatility relative to temporary impact. When T ≫ θ, the schedule front-loads and resembles minimum-variance liquidation. When T ≪ θ, temporary impact dominates and the trajectory approaches a straight line.

AC also gives closed-form expected cost E(X) and variance V(X) for the optimal schedule. They reduce to the constant-rate expressions as κ → 0 and to immediate-liquidation expressions as κ → ∞. The code below evaluates the finite-interval versions using hyperbolic identities, alongside direct calculations from the trade list.

Task — implement the schedule, trade list, E and V in runnable Python

This NumPy-only implementation returns remaining holdings and trade quantities, then computes expected cost and variance both directly from the trades and from finite-sum closed forms. It also provides the constant-rate and immediate-liquidation references, so the limiting cases can be checked without additional packages.

import numpy as np


def schedule(X, T, N, lam, sigma, eta, gamma):
    tau = T / N
    eta_tilde = eta - 0.5 * gamma * tau
    if eta_tilde <= 0:
        raise ValueError("Strict convexity requires eta_tilde > 0.")

    if lam == 0:
        holdings = X * (1.0 - np.arange(N + 1) / N)
        return holdings, holdings[:-1] - holdings[1:], 0.0, eta_tilde

    # Exact discrete curvature for the difference equation.
    kappa = np.arccosh(1.0 + lam * sigma**2 * tau**2 /
                       (2.0 * eta_tilde)) / tau
    t = np.arange(N + 1) * tau
    holdings = X * np.sinh(kappa * (T - t)) / np.sinh(kappa * T)
    trades = holdings[:-1] - holdings[1:]
    return holdings, trades, kappa, eta_tilde


def objectives_from_trades(X, trades, T, N, sigma, eta, gamma, epsilon):
    tau = T / N
    eta_tilde = eta - 0.5 * gamma * tau
    holdings = np.r_[X, X - np.cumsum(trades)]
    expected_cost = (0.5 * gamma * X**2
                     + epsilon * np.sum(np.abs(trades))
                     + eta_tilde / tau * np.sum(trades**2))
    variance = sigma**2 * tau * np.sum(holdings[1:]**2)
    return expected_cost, variance


def objectives_closed_form(X, T, N, kappa, sigma, eta_tilde, gamma,
                           epsilon):
    tau = T / N
    if kappa == 0:
        holdings = X * (1.0 - np.arange(N + 1) / N)
        trades = holdings[:-1] - holdings[1:]
        return objectives_from_trades(
            X, trades, T, N, sigma, eta_tilde + 0.5 * gamma * tau,
            gamma, epsilon
        )

    a = kappa * tau
    sum_trade_squares = (
        (2.0 * np.sinh(a / 2.0) / np.sinh(kappa * T))**2
        * X**2
        * (N / 2.0 + np.sinh(2.0 * kappa * T) /
           (4.0 * np.sinh(a)))
    )
    sum_holdings_squares = (
        X**2 / np.sinh(kappa * T)**2
        * 0.5
        * (np.sinh(N * a) * np.cosh((N - 1) * a) / np.sinh(a) - N)
    )
    expected_cost = (0.5 * gamma * X**2 + epsilon * X
                     + eta_tilde / tau * sum_trade_squares)
    variance = sigma**2 * tau * sum_holdings_squares
    return expected_cost, variance


def constant_rate_reference(X, T, N, sigma, eta, gamma, epsilon):
    tau = T / N
    expected_cost = (0.5 * gamma * X**2 + epsilon * X
                     + (eta - 0.5 * gamma * tau) * X**2 / T)
    variance = ((1.0 / 3.0) * sigma**2 * X**2 * T
                * (1.0 - 1.0 / N) * (1.0 - 1.0 / (2.0 * N)))
    return expected_cost, variance


def immediate_reference(X, tau, eta, epsilon):
    return epsilon * X + eta * X**2 / tau, 0.0

For λ = 0, the code uses the exact linear schedule. For finite λ, it uses the discrete curvature implied by the difference equation; as τ shrinks, that curvature approaches √(λσ²/η̃). The cost functions treat the order as a buy, so the spread contribution is εX.

Task — reproduce the Almgren–Chriss (2000) test case

The paper’s five-day example combines a $50/share starting price with a 1,000,000-share, $50M order and one trade per day. Using its reported impact and risk parameters gives κ ≈ 0.6/day and κT ≈ 3, an intermediate schedule rather than pure TWAP or immediate liquidation. The listed drift is ignored.

The full test-case inputs are:

S₀ = $50/share
X = 1,000,000 shares
T = 5 days; N = 5; τ = 1 day
σ = 0.95 ($/share)/day^(1/2)
α = 0.02 ($/share)/day, listed but ignored
ε = $0.0625/share
Daily volume = 5,000,000 shares
γ = 2.5×10⁻⁷ $/share²
η = 2.5×10⁻⁶ ($/share)/(share/day)
λ_u = 10⁻⁶/$
95% VaR confidence; λ_v = 1.645

The following call prints the five daily trade quantities. Comparing its direct and closed-form objectives checks the finite-sum implementation.

S0 = 50.0
X = 1_000_000.0
T = 5.0
N = 5
sigma = 0.95
alpha = 0.02  # Listed in the paper; not used by the schedule.
epsilon = 0.0625
daily_volume = 5_000_000.0
gamma = 2.5e-7
eta = 2.5e-6
lambda_u = 1e-6
lambda_v = 1.645

holdings, trades, kappa, eta_tilde = schedule(
    X, T, N, lambda_u, sigma, eta, gamma
)
direct = objectives_from_trades(
    X, trades, T, N, sigma, eta, gamma, epsilon
)
closed = objectives_closed_form(
    X, T, N, kappa, sigma, eta_tilde, gamma, epsilon
)

print("kappa per day:", kappa)
print("kappa T:", kappa * T)
print("daily trades:", trades)
print("E and V from trades:", direct)
print("E and V from closed forms:", closed)

The no-trade benchmark is σ√T = $2.12/share, or √V = $2.12M for the full order. This is the uncertainty associated with carrying the entire position over the week in the model; it is not an execution-cost estimate.

How do you calibrate γ, η and ε from real order data?

Almgren et al. (2005) estimated market impact from almost 700,000 Citigroup US equity orders from December 2001 through June 2003, filtered to 29,509 orders. Their impact model uses power laws: permanent impact has exponent α, while temporary impact has exponent β. Their fitted coefficients and modeling choices are empirical results for that dataset, not universal constants.

The permanent exponent fit was α = 0.891 ± 0.10, but the authors fixed it at 1, citing freedom from arbitrage and independence of permanent impact from trading time. They fixed the temporary exponent at β = 3/5 and explicitly rejected square-root impact as the temporary-impact model in that paper. Their reported coefficients are γ = 0.314 ± 0.041 (t = 7.7) and η = 0.142 ± 0.0062 (t = 23). Half-spread and fees remain separate in ε. The square-root-law literature exists as adjacent work, including Tóth et al. (2011); it should not be confused with the 2005 paper’s chosen temporary-impact exponent.

How do the fitted coefficients scale to a specific order?

The 2005 paper scales permanent and temporary impact by volatility, order size, average daily volume, shares outstanding, and execution duration in volume time. It defines post-trade impact at a specific observation point—half an hour after the last execution—so the permanent and realized measures should not be conflated.

I = γσ(X/V)(Θ/V)^(1/4)
J = I/2 + sgn(X)·η·σ·|X/(V·T)|^(3/5)

Here, X is shares, V is average daily volume, Θ is shares outstanding, σ is daily volatility, and T is duration in volume-time units. I = (S_post − S₀)/S₀, where S_post is measured half an hour after the last execution. J = (S̄ − S₀)/S₀ is realized impact. Volume time is the fraction of an average day’s volume executed so far; a constant-rate trajectory in volume time is a VWAP execution in real time.

What does buying 10% of daily volume actually cost?

In the paper’s worked Table 3 example, permanent impact is independent of execution time, while temporary and realized impact vary with duration. The reported costs are in basis points for IBM and DRI orders equal to 10% of a day’s average volume; they illustrate that paper’s estimates, not a guarantee about another order.

Stock Permanent Temporary at T = 0.1 / 0.2 / 0.5 days Realized at T = 0.1 / 0.2 / 0.5 days
IBM 20 bp 22 / 15 / 8 bp 32 / 25 / 18 bp
DRI 22 bp 32 / 21 / 12 bp 43 / 32 / 23 bp

Permanent impact does not move with duration, while temporary and realized impact do. The quantity the paper finds identical across assets is the volatility-normalized temporary cost K/σ — 0.142, 0.094 and 0.054 at the three durations for both stocks — not the basis-point figures, which are larger for DRI because its daily volatility is higher (2.26% against IBM’s 1.57%). The paper defines K = J − I/2, so IBM’s 32 bp realized cost is half its 20 bp permanent impact plus 22 bp temporary, and DRI’s 43 bp is half its 22 bp permanent impact plus 32 bp temporary.

How do you validate a schedule before you trust it?

Validate the implementation mechanically before interpreting its frontier: trades must sum to the order, remaining holdings must decrease monotonically, and the schedule must recover its limiting cases. Then evaluate E against √V over a range of λ values; the resulting pairs show the model’s cost–risk trade-off.

Five checks make the code auditable:

  • Σn_k = X, and the final remaining position is zero.
  • Holdings are non-increasing for a buy liquidation schedule.
  • As κ → 0, E and V recover the constant-rate reference.
  • As κ → ∞, E recovers immediate liquidation and V → 0.
  • θ = 1/κ does not depend on T, in the continuous-time limit where the paper defines it.

The code above imports only NumPy; producing the frontier plot itself needs a plotting library, but the schedule and the checks do not. Run the call below to see the five daily trades and to confirm that the two cost calculations agree.

Where does the model break, and what are the honest fixes?

The linear-impact model makes position size cancel from the schedule’s time scale at fixed λ, a limitation AC calls “at best only approximate” for large problems. It also requires η̃ > 0. Empirical impact is noisy, parameters can drift, and a static variance objective can be dynamically inconsistent; these are reasons to treat the output as a model schedule, not a promise of execution quality.

In the 2005 study, regression R² values are typically below 1%, and residuals are extremely fat-tailed. The authors describe quantitative accuracy up to about 10% of daily volume, with unmodeled uncertainty above a few percent of ADV. Those qualifications matter when applying coefficients to a specific order.

AC’s linear model is size-invariant at fixed λ because both variance and impact scale quadratically with order size. The authors suggest re-choosing η by problem size or using nonlinear impact. Other limitations include non-stationary market conditions and dynamic inconsistency: later information can make a static plan inappropriate. Almgren and Lorenz (2007) discuss adaptive strategies. Further pointers include Almgren (2003) on nonlinear impact, Gatheral and Schied (2013) on continuous-time HJB formulations, and Kato (2015) on volume-dependent VWAP tracking, as summarized in the Almgren–Chriss model overview.

FAQ

AC is a transparent baseline for separating expected impact from timing risk, but its conclusions depend on the specified objective, impact assumptions, and inputs. These concise answers clarify the model’s interpretation; they do not establish a universally best schedule or parameter choice.

Is TWAP ever optimal?

In this model, λ = 0 gives a TWAP-like schedule. AC argues it is never optimal on the efficient frontier because a modest increase in expected cost can substantially reduce variance.

How do I choose λ?

λ encodes the curvature of the utility trade-off between expected cost and variance. The paper does not supply a universal value; its example lists λ_u = 10⁻⁶/$ and λ_v = 1.645 for its stated setup.

Why not use square-root impact?

Square-root impact is an established area of market-impact research, including Tóth et al. (2011). But Almgren et al. (2005) fixed temporary-impact β at 3/5 and explicitly rejected the square-root model for that component.

Takeaway: treat the schedule as a model, not a forecast

Almgren–Chriss turns execution into a checkable choice between impact and timing risk: λ sets the trade-off, κ shapes the trajectory, and the frontier makes the cost–variance alternatives visible. Use its closed forms and limiting cases to validate the implementation, while keeping the empirical and model limitations in view.

← Back to all posts