σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Optimization skill›Module 4 · Constraints and regularisation›Topic 4.4·~55 minAdvanced

Linear programming for execution schedules

Skill positionModule 4 of 5 · Topic 4 of 4
4.4 Linear programming for execution schedules
—Lab score— / 100Total XP—Streak—

Splitting an order over time

A linear program minimises a linear objective cTx\mathbf c^{T}\mathbf xcTx subject to linear constraints Ax≤bA\mathbf x\le\mathbf bAx≤b and x≥0\mathbf x\ge0x≥0. The feasible set is a polytope, a shape with flat faces and corners, and because the objective is linear the best point is always at a corner (a vertex) of that shape. There is no downhill walking: the simplex method hops from vertex to vertex and interior-point methods cut through the middle, and both reach the exact optimum of a problem with thousands of variables in a fraction of a second.

min⁡x ∑t=1Tctxt ;∑t=1Txt=Q,0≤xt≤ut\min_{\mathbf x}\ \sum_{t=1}^{T}c_t x_t\ ;\quad \sum_{t=1}^{T}x_t=Q,\qquad 0\le x_t\le u_txmin​ t=1∑T​ct​xt​ ;t=1∑T​xt​=Q,0≤xt​≤ut​(1)

An execution schedule is a natural linear program. To sell QQQ shares over TTT intervals, let xtx_txt​ be the shares sold in interval ttt, ctc_tct​ the expected cost per share there (spread plus impact, in basis points) and utu_tut​ a capacity such as a participation cap of 10% of the expected volume. With one budget constraint the solution is greedy: fill the cheapest interval to its cap, then the next cheapest, until QQQ is done. The multiplier of the budget constraint, which linear programming reports for free, is the marginal cost of one more share, namely the cost of the cheapest interval that still has room.

Four intervalsSell Q=10,000Q=10{,}000Q=10,000 shares. The costs are 3,1,2,43,1,2,43,1,2,4 basis points and the caps 4000,3000,5000,60004000,3000,5000,60004000,3000,5000,6000 shares in intervals 1 to 4. Greedy fill: interval 2 (cost 1) takes its cap of 300030003000, interval 3 (cost 2) takes 500050005000, and interval 1 (cost 3) takes the remaining 200020002000. The total is 3000⋅1+5000⋅2+2000⋅3=19,0003000\cdot1+5000\cdot2+2000\cdot3=19{,}0003000⋅1+5000⋅2+2000⋅3=19,000 basis-point-shares, an average of 1.91.91.9 bps. The marginal cost is the cost of interval 1, 333 bps, because it is the cheapest interval that still has room. The total capacity is 18,00018{,}00018,000, so an order of 20,00020{,}00020,000 shares has no feasible schedule at all.

The capacity numbers can come from data. Over the last 250 sessions in the course dataset, the median daily volume of AAPL is about 45.5 million shares, so a 10% participation cap is about 4.55 million shares a day, and selling 20 million shares needs at least 20/4.55=4.420/4.55=4.420/4.55=4.4, that is five, sessions. A constant cost per share is a first approximation. Real impact grows with the size traded in an interval, which makes the cost convex in xtx_txt​ and turns the schedule into a quadratic program, the model of the capstone.

  • Vertex solution: an LP optimum sits at a corner of the feasible polytope.
  • Greedy schedule: with one budget constraint, fill the cheapest capacity first.
  • Shadow price: the budget multiplier is the marginal cost of one more share.
Check feasibility firstA solver answers an impossible request with 'infeasible', not with an approximate schedule. Compare the order size with the total capacity before you optimise, and decide what gives if it does not fit: a longer horizon, a higher participation cap or a smaller order. Costs and capacities are forecasts, so rerun the program as the day unfolds.

Lab · what's graded

  • The total cost15 pts
  • The average cost10 pts
  • Shares in the dearest interval used15 pts
  • The marginal cost15 pts
  • An order that is too large15 pts
  • Where an LP optimum sits15 pts
  • Formulating the schedule15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

Sell 10,000 shares over four intervals with costs 3, 1, 2, 4 bps and caps 4000, 3000, 5000, 6000 shares. What is the minimum total cost in basis-point-shares?

total=total =total=accepted: ± 1
2Numeric answer10 ptsNot answered

What is the average cost per share of that schedule, in basis points?

avg=avg =avg=accepted: ± 0.01
3Numeric answer15 ptsNot answered

How many shares does the optimal schedule sell in interval 1 (cost 3 bps)?

slot1=slot1 =slot1=accepted: ± 1
4Numeric answer15 ptsNot answered

If the order grew by one share and was still feasible, the total cost would rise by how many basis points? In other words, what is the shadow price of the budget constraint?

shadow=shadow =shadow=accepted: ± 0.01
5Choice15 ptsNot answered

The same four intervals are asked to execute 20,000 shares. What does the LP solver report?

6Choice15 ptsNot answered

A linear program with a bounded, non-empty feasible set has an optimal solution at...

7Order the steps15 ptsNot answered

Put the steps of setting up and solving the execution LP in order.

Drag to reorder, or focus an item, press Space to lift it, the arrow keys to move it and Space to drop it.

  1. 1Write the constraints: total equals QQQ and 0≤xt≤ut0\le x_t\le u_t0≤xt​≤ut​
  2. 2Solve it and read the shadow price of the budget constraint
  3. 3Choose the variables: shares xtx_txt​ sold in each interval
  4. 4Write the objective: total cost ∑tctxt\sum_t c_t x_t∑t​ct​xt​
Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub