Live.__aiter__

Using async 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 asynchronous applications.

Asynchronous iteration is only supported inside a coroutine.

Asynchronous 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.

Asynchronous iteration will automatically call Live.stop if the iterator is destroyed, such as when an async for loop is escaped with an exception or break statement. To prevent this behavior, an iterator can be created explicitly using aiter().

API method
1
Live.__aiter__() -> AsyncIterator[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 asynchronously iterate the records
async for record in client:
    print(record)