All time stamps for events outside of your computer reported by TWS API currently have a precision of 1 second. There is nothing you can do to get a higher precision.
What you can do (and I do) is:
- Tag every event you record with a unique and monotonously increasing id that is unique for each trading session. All modern processors have instructions for very fast atomic increments and all programming languages provide built-in or library support such as the in Java.? You simply call
()
to receive a thread-safe sequence of guaranteed increasing numbers.
- Assure your computer has a stable time source and timestamp every event you record with a high-resolution (local) timestamp such as the Java , which provides nano-second resolution subject to the precision of your local clock. In my case, that is 1 micro-second.
You tag and timestamp everything: major high-level events in your client, your TWS API requests, data you receive from any callbacks, all market data, ... That way can accurately replay any sequence of events and have the relative timing from your client's point of view. For certain events, such as the first TickByTick Last or BidAsk after market open, you can get a pretty good estimate of the actual lag between when the event took place at the exchange and when your client became aware of it. The same is true for the first TickByTick event for very busy seconds.
Hope that helps,
´³¨¹°ù²µ±ð²Ô
?
?
On Tue, May 6, 2025 at 10:41 AM, Neal Young wrote:
toggle quoted message
Show quoted text
..
I would like to use TWS to obtain a precise timestamp for each such event, for the time when the event occurs at the exchange.
To what extent is that possible? How should I go about finding out? Is there accurate documentation of available timestamps?
Thanks,
-Neal