Skip to content
All library documents

Execution and Fill Tracking for Multi-Leg Spread Trading

Code Quant course library

Summary

The document describes a software framework for executing spread trades across multiple instruments. It tracks each leg’s orders, fills, costs, and positions, then estimates the spread’s completed volume and average fill price. For inverse contracts, it converts between contract quantities and coin-denominated exposure using price and contract size; it also rounds prices and quantities to each leg’s trading increments.

The framework checks whether active and passive legs have filled enough to satisfy spread targets, accounting for different rules for linear and inverse contracts. It can submit long or short orders, cancel outstanding orders, update status from trades and order events, and stop when remaining quantities fall below minimum order sizes. The document is implementation-oriented: it provides no market data, performance evaluation, or evidence that a particular execution policy improves results. Its behavior depends on the spread definition, contract specifications, and engine callbacks.

Key ideas

  • The framework coordinates order and fill tracking across the legs of a spread.
  • Inverse-contract quantities are converted between coin exposure and contract units using price and contract size.
  • Order prices and sizes are rounded to each instrument’s minimum increments.
  • Completion checks account for spread multipliers and distinguish linear from inverse legs.
  • The document explains execution plumbing but provides no evidence of trading performance.

Tags

From a private course collection; the original is not published.