Skip to content
All library documents

CTP Position Queries Through Account and Position Event Callbacks

Article vn.py community

Summary

This short Chinese-language post asks how to retrieve position data from a CTP trading gateway. The author shows a connection sequence that loads gateway settings, initiates a connection, pauses for login and initial contract, account, and position queries, then registers account and position event handlers. It waits for both callbacks, with timeouts, before unregistering the handlers. The practical idea is to receive positions through the event system after connection rather than rely only on a direct all-positions getter that the author says returned empty data.

The post does not report whether this approach returns correct or complete positions, and it asks readers whether the timing and callbacks can produce erroneous data. It gives no gateway version, event ordering guarantees, sample callback implementation, or diagnostic results. The fixed initial sleep and separate waits may be sensitive to network and gateway timing, so the snippet is a question and tentative procedure rather than a verified method. Readers should treat it as a troubleshooting prompt, not an authoritative CTP integration guide.

Key ideas

  • The post uses CTP event callbacks to receive account and position updates after initiating a gateway connection.
  • It waits for initial gateway queries before registering handlers and then waits for the callbacks to arrive.
  • The author reports that a direct all-positions getter returned empty data and asks whether the callback approach is reliable.
  • The snippet provides no evidence that the returned positions are complete or correct.

Tags

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