Spread Taker Execution with Passive-Leg Hedging
Summary
This algorithm takes liquidity in the active leg of a multi-leg spread when the quoted spread reaches a configured limit. For a long spread, it checks whether the ask is at or below the target; for a short spread, it checks whether the bid is at or above it. It waits for valid bid and ask volumes, avoids acting while orders remain open, and checks that existing active-leg fills have been hedged before starting another take.
After active-leg trades, it calculates the corresponding target quantities in each passive leg and sends orders for any remaining hedge amounts. Orders use the available top-of-book price adjusted by a configurable number of ticks, while a timer periodically cancels outstanding orders. This is execution logic rather than a signal-generation or profitability study. The code does not specify spread construction, hedge ratios, market impact, failure handling, or measured results, so those depend on the surrounding system and market conditions.
Key ideas
- The algorithm takes the active leg when the spread quote reaches its configured price threshold.
- It waits for initialized quote volumes and completed orders before placing another active-leg order.
- Filled active-leg exposure is translated into target quantities for passive-leg hedges.
- Hedge orders adjust top-of-book prices by a configurable tick amount, and open orders are periodically canceled.
- No profitability, slippage, or hedge-failure evidence is provided.
Tags
From a private course collection; the original is not published.