¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: TWS queue buildup


 

There is no TWS API function to monitor the amount of unprocessed data in the socket that your client uses to connect with TWS API and I am not sure that would be a good approach in the first place. You just need to structure your client such that it is event driven and always ready to process TWS API callback function calls. Your callbacks:
  • should not directly perform very time consuming processing tasks
  • should not directly perform tasks such as file or database operations that might block the callback for extended or unbounded periods of time
  • and your client shall never call a sleep function.

Callbacks alert you about the arrival of new data and trigger processing (possibly at a later time). Simple and fast tasks can be performed right away, but anything more serious needs to be handled by a thread other than the callback thread. Every programming language has built-in or library add-ons that provide the tools you need for an event-driven client structure.

In this setup, your client can manage the data flow actively and by importance of the message:
  • it could drop certain messages by performing no task in the callback function (say you drop Bid/Ask or account value updates at peak times)
  • or it could buffer lower priority data in a queue for later processing
  • but it would always be ready to process important messages such as order updates, execDetails, and error messages or the most critical data your trading logic needs to be aware of immediately

We have never seen any backup issues and process in excess of 20,000 messages per second in peak situations.

´³¨¹°ù²µ±ð²Ô

Join [email protected] to automatically receive all group messages.