1. Introduction
In spread trading, the central challenge is often not deciding what to trade, but executing the trade. A spread position requires simultaneous entry into two legs — buying one contract and selling another — and any failure to fill both legs at the intended prices exposes the trader to leg-out risk: an unwanted directional exposure on the unfilled leg.
This article analyzes a price-level order management framework for spread execution. The approach is parameterized by fixed trigger prices for each direction, combined with time-based filtering and algorithmic lifecycle management. While simple in specification, the design reveals important principles about execution risk and state management in multi-leg trading.
2. Two-Leg Execution: Mathematical Description
2.1 Spread Definition
Let leg A and leg B have prices and respectively. The spread is defined as:
where is the leg ratio (number of B contracts per A contract). For the common case , the spread is simply .
A long spread position means: long leg A and short leg B. A short spread position means: short leg A and long leg B.
2.2 Execution as a Joint Operation
Executing a spread requires two orders submitted in quick succession:
| Spread Direction | Leg A | Leg B |
|---|---|---|
| Long spread | BUY | SELL |
| Short spread | SELL | BUY |
| Close long | SELL | BUY |
| Close short | BUY | SELL |
The ideal execution price for a long spread entry at spread level satisfies:
In practice, the two fills occur at different times and potentially different prices, so the realized spread is:
The execution slippage is:
Minimizing is the primary objective of spread execution algorithms.
2.3 Leg-Out Risk
Leg-out risk (also called execution risk or partial fill risk) arises when one leg fills but the other does not. Suppose leg A fills at but leg B remains unfilled. The trader now holds a naked position in leg A with exposure:
where is the number of filled contracts. This is a directional bet, not a spread, and the risk is unbounded.
The probability and severity of leg-out risk depend on:
- Liquidity asymmetry. If leg B is less liquid (wider bid-ask spread, lower depth), it is more likely to remain unfilled.
- Market volatility. During volatile periods, prices move between the two leg submissions, increasing the chance that the second leg’s price has moved away.
- Execution latency. The time gap between the two order submissions directly affects the probability of adverse price movement. Empirically, the variance of the mid-price change scales as .
Mitigation strategies include:
- Aggressive pricing on the second leg. After the first leg fills, cross the spread on the second leg to ensure immediate execution, accepting worse fill quality.
- Simultaneous submission with contingent logic. Submit both legs at once with instructions to cancel the first if the second fails.
- Timeout and unwind. If the second leg is not filled within seconds, liquidate the first leg at market.
3. Price-Level Order Management
3.1 Parameter Space
The framework is governed by four price levels and two position parameters:
| Parameter | Meaning |
|---|---|
| Spread price to trigger long entry | |
| Spread price to trigger long exit (close) | |
| Spread price to trigger short entry | |
| Spread price to trigger short exit (close) | |
| Target position size | |
| Allowed trading time window |
The price levels are set by the trader based on external analysis (fundamental valuation, technical levels, or model output). The execution engine merely monitors and acts.
3.2 State Machine
The system operates as a finite state machine with three states determined by the current spread position :
State 0: Flat (). Monitor both entry directions simultaneously:
| |
State 1: Long spread (). Cancel entry algorithms. Monitor exit:
| |
State 2: Short spread (). Cancel entry algorithms. Monitor exit:
| |
3.3 Algorithm Lifecycle
Each order algorithm (algo) has a lifecycle: pending → active → completed/stopped. When an algo terminates, the system must clear its identifier so that a new algo can be launched on the next evaluation cycle:
| |
Without this cleanup, the state machine would incorrectly believe an algo is still active and suppress new order submissions, effectively freezing execution.
4. Time-Based Filtering
4.1 Motivation
Spread relationships can behave differently across trading sessions. Reasons include:
- Opening and closing auctions. Price discovery during auctions can produce unreliable spread values due to non-continuous trading.
- Overnight gaps. For contracts with limited overnight liquidity, the spread may dislocate without the opportunity to execute both legs.
- Session-specific microstructure. Bid-ask spreads, depth, and volatility vary across the trading day, affecting execution quality.
4.2 Implementation
A time filter restricts trading to a window :
| |
When the filter deactivates (time exits the window), all running algos are stopped immediately. This is conservative: any unfilled portion is cancelled rather than left exposed to out-of-hours risk.
4.3 Practical Considerations
- Boundary effects. Setting slightly after the session open (e.g., 1–2 minutes) avoids the chaotic price action at the open.
- Split sessions. Markets with lunch breaks (e.g., Chinese futures) require separate windows for the morning and afternoon sessions, or a more general schedule specification.
- Time zone handling. The filter operates in the exchange’s local time zone. Incorrect time zone mapping is a common source of operational error.
5. Execution Speed and Price Improvement
When submitting spread orders, there is a fundamental tension between execution certainty and price improvement:
- A passive limit order at the target spread price may fail to fill, leaving the trader in State 0 (or, worse, with a partial fill and leg-out risk).
- An aggressive order that crosses the spread ensures fill but accepts worse prices.
A common heuristic is to shift the limit price by a payup amount in the favorable direction:
where the sign depends on the direction. This effectively pays for execution priority. The optimal depends on the current bid-ask spread of each leg and the urgency of the trade. For statistical arbitrage strategies with transient edges, a larger is justified because the edge decays with time.
Additionally, a re-submit interval controls how frequently unfilled orders are cancelled and resubmitted at updated prices, adapting to market movement without continuous cancellation overhead.
6. Summary
Price-level order management for spread trading encodes a simple but rigorous execution protocol: define trigger prices, manage state transitions, and filter by time. The framework’s apparent simplicity belies the complexity of the underlying execution problem — filling two legs simultaneously at known prices in a market where prices move between submissions.
The key design principles are:
- State-driven execution. Trading actions are fully determined by the current position and spread price relative to trigger levels, with no ambiguity.
- Algorithm lifecycle discipline. Completed algos must be cleaned up to prevent the state machine from blocking new orders.
- Time gating. Restricting execution to liquid sessions reduces leg-out risk from dislocated prices.
- Aggressive pricing for spread strategies. When the edge is time-sensitive, paying for execution certainty outweighs price improvement.
References
Gatev, E., Goetzmann, W. N., & Rouwenhorst, K. G. (2006). Pairs trading: Performance of a relative-value arbitrage rule. The Review of Financial Studies, 19(3), 797–827.
Avellaneda, M., & Lee, J.-H. (2010). Statistical arbitrage in the U.S. equities market. Quantitative Finance, 10(7), 761–782.
Aldridge, I. (2013). High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Trading Systems (2nd ed.). Wiley.
Hasbrouck, J. (2007). Empirical Market Microstructure: The Institutions, Economics, and Econometrics of Securities Trading. Oxford University Press.
Vidyamurthy, G. (2004). Pairs Trading: Quantitative Methods and Analysis. Wiley.
Cartea, Á., Jaimungal, S., & Penalva, J. (2015). Algorithmic and High-Frequency Trading. Cambridge University Press.