Skip to main content
Ultra Feature. Requires an Ultra subscription. Get started at api.mathematicalcompany.com
What is this? When you need to buy or sell a large position, trading it all at once moves the price against you. These two models compute the optimal schedule - how much to trade at each time step - to minimize the total cost. Garleanu-Pedersen is for portfolio rebalancing when your alpha signal decays over time. Almgren-Chriss is for pure liquidation when you just need to sell everything.

Optimal Execution

Horizon implements two foundational optimal execution models: Garleanu-Pedersen (2013) for alpha-decay-aware portfolio transitions, and Almgren-Chriss (2001) for risk-averse liquidation scheduling. Both run entirely in Rust and produce executable trajectories compatible with the pipeline system.

Garleanu-Pedersen

Optimal trading with alpha decay. Balances urgency from decaying signals against temporary and permanent market impact.

Almgren-Chriss

Optimal liquidation under mean-variance preferences. Minimizes the expected cost plus risk penalty of unwinding a position.

Trajectory Output

Both models produce time-indexed position trajectories with per-step trade rates and cost estimates.

Pipeline Integration

hz.gp_executor() and hz.ac_liquidator() drive real-time execution within hz.run().

Model Comparison

Use Garleanu-Pedersen when you have a time-decaying signal and want to capture it optimally. Use Almgren-Chriss when you need to liquidate or acquire a fixed position with controlled risk.

Garleanu-Pedersen

The GP model solves for the optimal trading rate that maximizes expected alpha capture minus temporary and permanent impact costs. The solution is a closed-form exponential trajectory controlled by a single urgency parameter.

hz.gp_optimal_trajectory

Compute the optimal position trajectory for a portfolio transition under alpha decay.
Returns a GPTrajectory.

hz.gp_execution_cost

Estimate the total execution cost (temporary + permanent impact) for a GP trajectory.
Returns float: total estimated execution cost.

hz.gp_urgency

Compute the GP urgency parameter, which determines how aggressively the model front-loads trading. Higher urgency means faster execution.
Returns float: the urgency parameter kappa.

GPTrajectory Type

Each GPStep contains:

Almgren-Chriss

The AC model minimizes the expected cost of liquidating (or acquiring) a position subject to a variance penalty. The risk aversion parameter controls the trade-off between execution speed (less timing risk) and patience (less impact cost).

hz.ac_optimal_schedule

Compute the optimal liquidation schedule under mean-variance preferences.
Returns an ACTrajectory.

hz.ac_efficient_frontier

Compute the efficient frontier of (expected cost, variance) pairs across a range of risk aversion values.
Returns list[FrontierPoint] with fields risk_aversion, expected_cost, and variance.

hz.ac_kappa

Compute the AC kappa parameter that governs the curvature of the optimal trajectory.
Returns float.

ACTrajectory Type

Each ACStep contains:

Pipeline Integration

hz.gp_executor

Pipeline function for Garleanu-Pedersen execution. Reads ctx.params["gp_request"] and drives optimal trading each cycle.

hz.ac_liquidator

Pipeline function for Almgren-Chriss liquidation. Reads ctx.params["ac_request"] and executes the optimal schedule.

Mathematical Background

The GP model maximizes the trader’s expected utility over a trading horizon:max sum_t [alpha_t * x_t - (gamma/2) * (dx_t)^2 - (lambda/2) * (dx_t) * x_t]where x_t is position, dx_t is trade rate, alpha_t = alpha_0 * exp(-rho * t) is decaying alpha, gamma is temporary impact, and lambda is permanent impact. The closed-form solution is an exponential trajectory with urgency kappa = sqrt(rho + lambda / gamma).
The AC model minimizes expected shortfall plus a risk penalty:min E[cost] + lambda * Var[cost]where cost includes both permanent impact (proportional to trade size) and temporary impact (proportional to trade rate). The optimal trajectory is x_t = X * sinh(kappa * (T-t)) / sinh(kappa * T) where kappa depends on risk aversion and impact parameters.
Use GP when you have a decaying alpha signal (e.g., a mispricing that will correct over time). The model optimally front-loads trading to capture alpha before it decays, while controlling impact costs.Use AC when you have a fixed position to liquidate and no alpha signal. The model provides the cost-optimal schedule given your risk tolerance. Higher risk aversion produces faster, more expensive liquidation; lower risk aversion produces slower, cheaper liquidation with more timing risk.