Spread Taker Execution with Passive-Leg Hedging
Summary
The document describes a spread-taking algorithm that waits for valid bid and ask volume, checks that prior orders have finished, and hedges any unbalanced passive legs before initiating another active-leg order. For a long spread, it takes the active leg when the spread ask is at or below its limit; for a short spread, it acts when the spread bid reaches or exceeds its limit. Order size is bounded by visible spread volume and remaining target quantity.
After active-leg fills, the algorithm calculates the passive-leg quantities needed to match the spread exposure and sends offsetting orders. It adjusts order prices from each leg’s best bid or ask by a configurable pay-up amount, and cancels outstanding orders on its interval callback. The excerpt gives no test results, fill model, or performance evidence. Execution quality and residual exposure therefore depend on market liquidity, leg ratios, timing, and how the surrounding framework reports fills and cancellations.
Key ideas
- The algorithm enters the active leg only when the spread reaches the configured price and previous orders are complete.
- It caps each active-leg order by available spread volume and the remaining target quantity.
- Passive legs are traded to hedge the active-leg exposure after fills.
- Leg order prices incorporate a configurable pay-up from the best displayed quote.
- The code provides no performance evidence and leaves execution outcomes dependent on liquidity and event handling.
Tags
From a private course collection; the original is not published.