The Almgren-Chriss framework is the seminal mathematical foundation for optimal portfolio execution in quantitative finance.
A quantitative fund must liquidate a parent position of shares over discrete trading intervals . Let denote the shares sold in interval , and let be the remaining inventory after trading at step , with boundary condition .
The objective is to minimize the total expected cost plus variance risk penalty: where:
Your Task
Implement almgren_chriss_optimal_execution(x_total: int, t_steps: int, eta: float, sigma: float, lambda_risk: float) -> tuple[list[float], float] that calculates the exact optimal liquidation trajectory and the resulting minimum objective cost using Riccati backward induction dynamic programming.
Constraints
Examples
# For zero risk aversion (lambda = 0), TWAP is strictly optimal:
trades, cost = almgren_chriss_optimal_execution(1000, 4, eta=0.01, sigma=0.1, lambda_risk=0.0)
# trades = [250.0, 250.0, 250.0, 250.0]
# cost = 4 * 0.01 * 250^2 = 2500.0