Live.__iter__
Using for; records will be yielded as they arrive. Iteration will stop when the connection is closed and all records are processed. This is best for integration into simple synchronous applications.
Iteration will automatically call Live.start if the session is connected but it has not been started. Starting iteration after the session has started will cause a ValueError.
Iteration will automatically call Live.stop if the iterator is destroyed, such as when a for loop is escaped with an exception or break statement. To prevent this behavior, an iterator can be created explicitly using iter().
API method
1
Live.__iter__() -> Iterator[DBNRecord]
Example usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import databento as db
# Create a live client
client = db.Live(key="$YOUR_API_KEY")
# Subscribe to a data stream
client.subscribe(
dataset="GLBX.MDP3",
schema="trades",
stype_in="parent",
symbols="ES.FUT",
)
# Start streaming and synchronously iterate the records
for record in client:
print(record)