Skip to content
All library documents

Calculating Synthetic Spread Prices, Volumes, and Positions

Code Quant course library

Summary

This implementation models a spread as a collection of instrument legs, with separate multipliers for calculating its quoted price and translating spread quantities into leg quantities. It combines leg bid and ask prices, reversing which side is used for negative price weights, then rounds spread prices to a tick increment. Available spread volume is constrained by the least capacity among its legs after accounting for trading multipliers. For inverse contracts, the code converts quoted volume into an equivalent quantity using contract size and price.

Position calculations translate each leg’s net position into spread units, round quantities to the configured minimum volume, and infer a net spread position from the limiting leg. The excerpt also describes loading synchronized leg bars to construct historical spread bars, and includes bar or tick backtesting modes. These are implementation details rather than evidence of a profitable strategy. Results depend on correct leg data, multiplier configuration, contract conventions, and synchronized timestamps; the partial excerpt does not establish execution realism or validate the calculations empirically.

Key ideas

  • A synthetic spread price is calculated as a weighted combination of its leg prices.
  • Negative price weights use the opposite side of the leg quote when forming spread bids and asks.
  • Spread quote volume is limited by the least available leg capacity after quantity adjustments.
  • Inverse contract quantities are converted using contract size and price.
  • Spread positions and historical bars are derived from the underlying legs, with bar availability requiring matching timestamps.

Tags

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