Skip to content
All library documents

Tracking Spread Execution Prices and Recovering Inconsistent Positions

Article vn.py community

Summary

This Chinese-language forum exchange explains how to track execution information for a spread-trading algorithm. A participant asks how to obtain a spread’s opening average price and its fill prices and quantities. The reply recommends receiving algorithm status updates through the strategy’s callback and recording the reported average fill price for use in strategy-side tracking.

The discussion also illustrates a position-state problem after a stop-loss error caused an incomplete, or legged, spread execution. The trader manually closed positions, but the spread-position file retained an imbalanced position, causing the position query to return zero. Removing that state file resolved the reported issue. This is a single troubleshooting anecdote, not a general recovery procedure: deleting persisted position state may be unsafe unless actual broker positions have first been reconciled. The exchange gives no code, API version details, or systematic guidance for handling partial fills, so implementations should verify callback fields and reconcile each leg against broker records.

Key ideas

  • An execution algorithm’s status callback can provide its average fill price.
  • A strategy can record execution updates to maintain its own spread trade information.
  • Partial or imbalanced leg fills can leave persisted spread position state inconsistent.
  • The reported position query returned zero despite stale imbalanced state in the position file.
  • Position recovery should reconcile persisted state with actual leg positions; the exchange is only an anecdotal example.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.