Reading the Current Bar Timestamp in an on_bars Callback
Summary
This short VeighNa community exchange answers how to obtain the time associated with the current bar inside an on_bars callback. The reply takes the first bar from the supplied bars collection and reads its datetime field. This gives a direct way to inspect the timestamp attached to a bar during event-driven strategy processing.
The exchange contains no broader discussion of bar processing, timezone handling, timestamp conventions, or behavior when the collection is empty or contains multiple instruments. It offers a concise API usage pointer rather than a trading strategy or market analysis, and provides no testing or performance evidence. Readers should confirm that selecting the first bar matches their callback's instrument and data structure.
Key ideas
- The callback receives bars in a collection that can be accessed by instrument.
- A bar's datetime field supplies its timestamp.
- The example selects the first bar in the collection.
- The exchange does not explain timezone conventions or empty-collection handling.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.