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
| Aspect | Garleanu-Pedersen | Almgren-Chriss |
|---|---|---|
| Use case | Portfolio transition with alpha signal | Pure liquidation / acquisition |
| Objective | Maximize alpha capture minus impact cost | Minimize expected cost + risk penalty |
| Key parameter | Alpha decay rate (kappa) | Risk aversion (lambda) |
| Trade profile | Front-loaded when alpha decays fast | Depends on risk aversion |
| Permanent impact | Yes (linear) | Yes (linear) |
| Temporary impact | Yes (linear) | Yes (linear) |
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.| Parameter | Type | Description |
|---|---|---|
target_position | float | Target position to acquire |
current_position | float | Starting position (default: 0.0) |
alpha | float | Expected return per period from the signal |
alpha_decay | float | Exponential decay rate of alpha (positive) |
temporary_impact | float | Temporary impact coefficient (positive) |
permanent_impact | float | Permanent impact coefficient (non-negative) |
n_periods | int | Number of time steps in the trajectory |
GPTrajectory.
hz.gp_execution_cost
Estimate the total execution cost (temporary + permanent impact) for a GP trajectory.| Parameter | Type | Description |
|---|---|---|
target_position | float | Target position size |
alpha_decay | float | Alpha decay rate |
temporary_impact | float | Temporary impact coefficient |
permanent_impact | float | Permanent impact coefficient |
n_periods | int | Number of time steps |
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.| Parameter | Type | Description |
|---|---|---|
alpha_decay | float | Alpha decay rate |
temporary_impact | float | Temporary impact coefficient |
permanent_impact | float | Permanent impact coefficient |
float: the urgency parameter kappa.
GPTrajectory Type
| Field | Type | Description |
|---|---|---|
steps | list[GPStep] | Time-indexed trajectory steps |
total_cost | float | Total estimated execution cost |
urgency | float | Computed urgency parameter (kappa) |
completion_pct | float | Percentage of target position acquired |
GPStep contains:
| Field | Type | Description |
|---|---|---|
time | int | Time step index |
position | float | Optimal position at this step |
trade_rate | float | Number of contracts to trade this step |
remaining_alpha | float | Alpha remaining at this step |
cumulative_cost | float | Cumulative execution cost so far |
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.| Parameter | Type | Description |
|---|---|---|
position | float | Total position to liquidate (positive) |
n_periods | int | Number of time steps (at least 2) |
volatility | float | Per-period return volatility (positive) |
temporary_impact | float | Temporary impact coefficient (positive) |
permanent_impact | float | Permanent impact coefficient (non-negative) |
risk_aversion | float | Risk aversion lambda (positive) |
ACTrajectory.
hz.ac_efficient_frontier
Compute the efficient frontier of (expected cost, variance) pairs across a range of risk aversion values.| Parameter | Type | Description |
|---|---|---|
position | float | Position to liquidate |
n_periods | int | Number of time steps |
volatility | float | Per-period volatility |
temporary_impact | float | Temporary impact coefficient |
permanent_impact | float | Permanent impact coefficient |
n_points | int | Number of frontier points (default: 50) |
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.| Parameter | Type | Description |
|---|---|---|
volatility | float | Per-period volatility |
temporary_impact | float | Temporary impact coefficient |
permanent_impact | float | Permanent impact coefficient |
risk_aversion | float | Risk aversion parameter |
float.
ACTrajectory Type
| Field | Type | Description |
|---|---|---|
steps | list[ACStep] | Time-indexed liquidation steps |
expected_cost | float | Expected total execution cost |
variance | float | Variance of execution cost |
kappa | float | Computed kappa parameter |
ACStep contains:
| Field | Type | Description |
|---|---|---|
time | int | Time step index |
remaining | float | Position remaining after this step |
trade_size | float | Contracts to trade this step |
cumulative_cost | float | Cumulative cost so far |
Pipeline Integration
hz.gp_executor
Pipeline function for Garleanu-Pedersen execution. Readsctx.params["gp_request"] and drives optimal trading each cycle.
hz.ac_liquidator
Pipeline function for Almgren-Chriss liquidation. Readsctx.params["ac_request"] and executes the optimal schedule.
Mathematical Background
Garleanu-Pedersen (2013)
Garleanu-Pedersen (2013)
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).Almgren-Chriss (2001)
Almgren-Chriss (2001)
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.Choosing Between Models
Choosing Between Models
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.