OKEX Calendar Spread Grid Using WebSocket Price Differences
Summary
This teaching example describes a futures calendar spread between quarterly and weekly OKEX contracts. It subscribes to both contracts’ ticker updates over a WebSocket and tracks their price difference. A grid of spread thresholds is created from a starting level, interval, and node count. When the quarterly contract’s bid less the weekly contract’s ask exceeds an opening threshold, the strategy sells the quarterly contract and buys the weekly one. It closes that paired position when the opposite-side price difference falls below the node’s closing threshold, which includes a configured profit spread.
The example tracks each node as held or available and submits paired orders at opposing market sides. It describes only the positive calendar spread direction and notes that reversing the contracts would change the direction. No backtest or performance results are supplied. The source explicitly frames the code as a simplified teaching strategy, cautions that real trading is risky, and leaves substantial room for improvement; execution and legging risk are not quantified.
Key ideas
- The strategy monitors the price difference between quarterly and weekly futures contracts using ticker updates.
- A configurable grid opens paired short-quarterly and long-weekly positions when spread thresholds are crossed.
- Each open node closes when the spread reaches its configured profit threshold.
- The example covers one spread direction and provides no backtest evidence.
- The document cautions that the simplified teaching strategy carries real-trading risk.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.