Skip to content
All library documents

Using ScriptTrader to Auto-Exit Manual Futures Positions

Article vn.py community

Summary

The document proposes using VeighNa ScriptTrader to detect manual futures trades and submit limit orders to close them at a target offset. It explains that CTA strategies may not receive trade callbacks for orders they did not place, so the proposed workaround polls position changes or the account’s trade records. The position method estimates entry price from the position average; the trade-record method uses individual execution prices.

The post also outlines connecting to a simulation environment, enabling ScriptTrader, loading a locally saved script, and checking the resulting orders. It claims limit orders avoid execution beyond the specified price, but does not show test results or address whether such orders will fill. Polling can lag behind executions; the example’s handling of partial closes, order cancellation, duplicate orders, and contract price increments needs careful verification before use. The advice is an implementation sketch, not evidence of reliable live trading behavior.

Key ideas

  • ScriptTrader can monitor account positions or trades to detect manual activity outside a CTA strategy.
  • Position polling uses average position price, while trade polling can use individual execution prices.
  • The suggested exit order is a limit order offset from the detected entry price.
  • Limit orders constrain the acceptable price but do not guarantee execution.
  • Polling delays and order state handling can affect the behavior of the example.

Tags

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