Minimum Impact Schedule for Liquidating a Futures Position
Last updated: November 29, 2026
Quick Overview
Sell Q contracts over T time buckets. Selling x contracts in bucket t costs impact[t] times x squared plus spread[t] times x, and bucket t can absorb at most cap[t] contracts. Find the minimum total cost and the per bucket allocation, or report that it is infeasible.
DRW
November 29, 20260
0
0 solved
Sell Q contracts over T time buckets. Selling x contracts in bucket t costs impact[t] times x squared plus spread[t] times x, and bucket t can absorb at most cap[t] contracts. Find the minimum total cost and the per bucket allocation, or report that it is infeasible.
Execution cost modeling matters to DRW because large positions in futures and rates must be worked without moving the market. The question tests 2D DP over time and quantity, and strong candidates notice that the convex cost allows a much faster greedy, which the interviewer will push toward.
What the Interviewer Expects
- Defines dp over buckets and units sold so far
- Handles capacity limits and infeasibility
- Reconstructs the allocation from stored choices
- States O(T Q C) complexity honestly
- Recognizes convexity enables a marginal cost greedy with a heap
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Prove the greedy by marginal cost is optimal for convex per bucket costs.
- Add a penalty for holding inventory (risk aversion). What does the DP state need?
- Impact decays across buckets instead of being independent. How does that change the problem?
- How would you handle Q in the millions?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: integer Q, arrays impact, spread, cap of length T. Each bucket's cost depends only on its own x (no cross bucket impact). Output: (cost, allocation) or (inf, None) if the caps sum be...
High-Level Design
This is a bounded knapsack with a convex cost per item group. dp_t[q] is the cheapest way to sell q units using buckets 0..t. Transition: `dp_t[q] = min over x in [0, min(cap_t, q)] of dp_{t-1}[q-...