Skip to content

deephaven_massive.queries

deephaven_massive.queries

The query classes: what a dataset method returns, and the methods that turn it into a table.

Every dataset method, such as m.stocks.trades(["AAPL"]), returns a query. A query describes a read and reads nothing until you call one of its methods, and each method returns a Deephaven table of one shape: fetch() reads what Massive has now, poll(interval) reads it again on a timer, the stream methods (blink(), append_only(), ring(capacity), last_by()) follow a live feed, and history(start, end) reads a past range. Which of these a query has depends on what Massive serves for its dataset, and the query's class says so:

  • FetchQuery: a REST dataset, with fetch() and poll().
  • StreamQuery: a live stream, with blink(), append_only(), ring(), and last_by().
  • NoSymbolStreamQuery: any live stream whose rows name no symbol, with blink(), append_only(), and ring() but no last_by(). Annotate with it to take any such stream.
  • HistoryQuery: any query with history(), and the query of bars Massive doesn't stream.
  • StreamHistoryQuery: a stream that also has history, with all five of those methods.
  • NoSymbolStreamHistoryQuery: a stream whose rows name no symbol, with history, such as m.options.admin_messages(). It has blink(), append_only(), ring(), and history(), but no last_by().
  • Query: the base class of all of them, with columns(), for code that takes any query.

You never construct a query: you get one from a dataset method. Import a class from here to annotate your own code, such as a helper that keeps each symbol's latest row of any stream:

from deephaven.table import Table

import deephaven_massive as dm
from deephaven_massive.queries import StreamQuery


def latest(query: StreamQuery) -> Table:
    return query.last_by()


m = dm.MassiveSession()
quotes = latest(m.stocks.quotes(["AAPL", "MSFT"]))

A helper that takes any stream, with or without symbols, annotates its query StreamQuery | NoSymbolStreamQuery.

A bars() call returns a StreamHistoryQuery for the bars Massive streams, 1-second and 1-minute bars at multiplier=1, and a HistoryQuery for any other bars, and declares both. A type checker allows a stream method on its result only after you check the class:

from deephaven_massive.queries import StreamHistoryQuery

minute = m.stocks.bars("AAPL", dm.Timespan.MINUTE)
assert isinstance(minute, StreamHistoryQuery)  # 1-minute bars stream
live = minute.last_by()

dm.datasets() lists every dataset with its methods, and help() on a class describes each method.

Classes

FetchQuery dataclass

FetchQuery()

A query of a REST dataset: fetch() reads what Massive has now, poll() keeps reading it.

Many of Massive's datasets answer with what it holds at the moment you ask: a stock's dividends, each symbol's latest trade, a market snapshot, a list of tickers. Their dataset methods return a FetchQuery. Call fetch() for a table of the rows Massive has now, or poll(interval) for a live table that reads them again every interval seconds. Each call reads again, so you can reuse the query.

Import it as from deephaven_massive.queries import FetchQuery to annotate your own code. You get one from a dataset method, such as m.stocks.dividends(...), and never construct one.

Example
dividends = m.stocks.dividends(["AAPL", "MSFT"], start="2024-01-01").fetch()
latest = m.stocks.snapshots(["AAPL", "MSFT"]).poll(5)

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")
fetch
fetch(*, wait: bool = False) -> Table

Return a table of every row Massive has now, up to the query's limit.

By default the call returns a live table with no rows at once, and the rows arrive in the background. Deephaven updates the table, and every table built on it, as they land. For symbols passed in code or in a static table, they land all in one update, and m.streams() shows the read LOADING, then DONE or FAILED. Pass wait=True to wait for the rows; without a watchlist, you then get a static table.

A static table of symbols is read once, when you call. A watchlist is followed: a symbol you add is read, and one you delete leaves. One symbol's failure leaves the watchlist's other symbols in place, unless its cause is set to dm.OnError.RAISE, which fails the table. m.symbol_reads() shows each symbol's read.

Parameters:

Name Type Description Default
wait bool

False, the default, returns at once and fills the table in the background. True waits for the rows; for a watchlist, until each symbol has been read once.

False

Returns:

Type Description
Table

A table with the dataset's columns: live, or static for wait=True without a watchlist.

Raises:

Type Description
TypeError

If wait isn't a bool.

ValueError

At the call, before any request, if: - it runs on a Deephaven update-graph thread; - the endpoint doesn't take one of the query's parameters or filters, or, for a watchlist, one of the endpoints its symbols could need doesn't; - a static symbols, underlying=, or product_code= table is empty; - no row of a table of symbols is Massive's exact ticker.

AuthenticationError

With wait=True, if Massive rejects your API key.

EntitlementError

With wait=True, if your plan doesn't include the data, or Massive delays current data whose subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

With wait=True, if: - a rate limit outlasts the retries; - a request fails in any other way; - Massive has no data for a symbol, under unavailable_symbols=dm.OnError.RAISE; - for a watchlist, every symbol's read failed.

Without wait=True, an error from Massive fails the table instead of raising: it is logged and shows in Error of m.streams(). A watchlist's table fails when every symbol it held at the call fails for good, unless one of them is read first or leaves the watchlist before it fails. A plan without the dataset is one such case.

Example
dividends = m.stocks.dividends(["AAPL", "MSFT"]).fetch()
now = m.stocks.dividends(["AAPL", "MSFT"]).fetch(wait=True)
poll
poll(interval: float | timedelta, *, mode: PollMode = PollMode.AUTO) -> Table

Return a live table that fetches the query again every interval.

Each poll reads the whole query again, so the table follows a watchlist. The table keeps polling while anything uses it (https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#stop-live-tables).

A feed, a dataset whose poll() appends new rows (news, filings, unusual trades), needs a start or a limit. Without either, each poll would read Massive's whole archive.

A failed poll logs a WARNING and shows in m.problems(), and the next poll runs as usual. The table fails and stops polling if its polls keep failing for MassiveConfig.max_outage, 300 seconds by default. It also fails on a failure no later poll can fix, such as a rejected key.

Each poll reads every symbol on its own, so one symbol's failure never costs another symbol its rows. A symbol whose read fails for now is read again at a later poll, and a dm.PollMode.REPLACE table keeps its last rows meanwhile. A symbol Massive refuses, or that keeps failing for max_outage, isn't read again until you delete its row from the table of symbols and add it back, or call poll() again. The table fails when every symbol of its first poll has failed that way before any of them answered, or when Massive refuses the feed or the API key. A poll skips a symbol it can't read or that Massive has no data for. Each such symbol is listed in m.problems(). To fail the table instead, set noncanonical_symbols, unavailable_symbols, refused_symbols, or undocumented_errors of dm.ErrorPolicy to dm.OnError.RAISE, through MassiveConfig(on_error=...) or the dataset method's on_error=.

Parameters:

Name Type Description Default
interval float | timedelta

The time between polls, in seconds or as a timedelta, at least 1 second. For anything faster, use a stream.

required
mode PollMode

How polls combine. dm.PollMode.AUTO, the default, uses the mode the dataset's page names. REPLACE keeps only the latest poll's rows. UPSERT keeps every key ever seen, at its latest row. APPEND adds only rows it hasn't seen.

AUTO

Returns:

Type Description
Table

A live table with the dataset's columns: keyed for REPLACE and UPSERT, append-only for APPEND. Each row's TimestampInsert is the time of the poll that wrote it. The table remembers each key or row it has held, so its memory grows with them.

Raises:

Type Description
TypeError

If interval isn't a number or a timedelta, or mode isn't a dm.PollMode.

ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - interval is shorter than 1 second or isn't finite; - a feed has neither start nor limit; - no row of a table of symbols is Massive's exact ticker; - an endpoint doesn't take one of the query's parameters or filters.

SessionClosedError

If the session is closed.

MassiveError

If the call meets a bug in the library.

HistoryQuery dataclass

HistoryQuery()

Any query that reads a past range: history(start, end) reads the rows between two times.

Annotate with HistoryQuery when your code only reads history, such as a helper that loads a week of any dataset's rows. Call history(start, end) for a table of the rows in that range. The library reads them from Massive's REST API or its S3 flat files, whichever serves the range, unless you choose with source. Each call reads its range again.

A bars() call returns exactly this class for bars Massive doesn't stream, such as day bars. Every other dataset with history also streams, so its method returns a StreamHistoryQuery, a subclass of this class that adds the stream methods; code annotated with HistoryQuery takes either.

Import it as from deephaven_massive.queries import HistoryQuery to annotate your own code. You get one from a dataset method and never construct one.

Example
from deephaven.table import Table

from deephaven_massive.queries import HistoryQuery


def week(query: HistoryQuery) -> Table:
    return query.history("2025-01-06", "2025-01-10")  # whole days, both included


hourly = week(m.options.bars("O:AAPL250117C00150000", dm.Timespan.HOUR))

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")
history
history(start: DateLike, end: DateLike | None = None, *, source: HistorySource = HistorySource.AUTO, reread: Reread = Reread.ALWAYS, wait: bool = False) -> Table

Return the dataset's rows over a range of days or of exact times.

By default the call returns a live table with no rows at once, and the rows arrive in the background. Deephaven updates the table, and every table built on it, as they land. For symbols passed in code or in a static table, they land all in one update, and m.streams() shows the read LOADING, then DONE or FAILED. Pass wait=True to wait for the rows; without a watchlist, you then get a static table.

Dates, such as "2025-03-03", read whole days in the market's time zone, both ends included. Times, such as a datetime with a time zone, read from start up to end, which is excluded. A bar is included only when its whole window is in the range and has ended.

Rows come from REST or from Massive's flat files. By default, the library picks the source and reads from REST any day the flat files can't serve. The table's description says which source it read. Each flat file holds a whole day of data, and a flat-file read downloads all of it, however few symbols or short a range you ask for.

A static table of symbols is read once, when you call. A watchlist is followed over the range fixed at the call: a symbol you add arrives with all its rows, and one you delete leaves (https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#drive-with-a-watchlist). One symbol's failure leaves the watchlist's other symbols in place, unless its cause is set to dm.OnError.RAISE, which fails the table. m.symbol_reads() shows each symbol's read.

Parameters:

Name Type Description Default
start DateLike

The first day, or the first time included.

required
end DateLike | None

The last day included, or the first time excluded. Leave it out to read through now.

None
source HistorySource

dm.HistorySource.AUTO, the default, picks the source; REST or FLAT_FILES forces one.

AUTO
reread Reread

For a watchlist, whether a symbol you delete and add back is downloaded again (dm.Reread.ALWAYS, the default) or gets its earlier rows back without a request (dm.Reread.NEVER).

ALWAYS
wait bool

False, the default, returns at once and fills the table in the background. True waits for the rows; for a watchlist, until each symbol has been read once.

False

Returns:

Type Description
Table

A table with the dataset's columns, with no row when none is in the range: live, or static for wait=True without a watchlist.

Raises:

Type Description
TypeError

If source isn't a dm.HistorySource, reread isn't a dm.Reread, wait isn't a bool, or a bound isn't a date or a time.

ValueError

At the call, before any request, if: - it runs on a Deephaven update-graph thread; - a bound is a datetime without a time zone, unreadable text, or NaT; - one bound is a date and the other a time; - start is after end, or in the future when end is left out; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - no source can serve the request; the message gives each reason; - the endpoint doesn't take one of the query's parameters or filters.

AuthenticationError

With wait=True, if Massive or its flat-file server rejects your keys.

EntitlementError

With wait=True, if your plan doesn't include the data from any source the call can use.

SessionClosedError

If the session is closed.

MassiveError

With wait=True, if: - a request fails; - adjusted bars come back unadjusted, or the reverse; - a trading day's flat file is missing and REST can't serve that day; - for a watchlist, every symbol's read failed.

Without wait=True, an error from Massive fails the table instead of raising: it is logged and shows in Error of m.streams(). A watchlist's table fails when every symbol it held at the call fails for good, unless one of them is read first or leaves the watchlist before it fails. A plan without the dataset is one such case.

Example
day = m.crypto.trades("X:BTCUSD").history("2026-01-02", "2026-01-02")
rows = m.crypto.trades("X:BTCUSD").history("2026-01-02", "2026-01-02", wait=True)

NoSymbolStreamHistoryQuery dataclass

NoSymbolStreamHistoryQuery()

A query of a stream whose rows name no symbol, with its history: live and past rows.

OPRA's administrative messages name no symbol. Massive streams them and serves their history, so m.options.admin_messages() returns this class. Its methods are blink(), append_only(), ring(capacity), and history(start, end). The stream methods follow the live feed, and history() reads a past range with the same columns. It has no last_by(), since the rows have no Symbol.

Import it as from deephaven_massive.queries import NoSymbolStreamHistoryQuery to annotate your own code. You get one from a dataset method and never construct one.

Example
q = m.options.admin_messages()
live = q.append_only()
day = q.history("2026-11-13", "2026-11-13")

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")
history
history(start: DateLike, end: DateLike | None = None, *, source: HistorySource = HistorySource.AUTO, reread: Reread = Reread.ALWAYS, wait: bool = False) -> Table

Return the dataset's rows over a range of days or of exact times.

By default the call returns a live table with no rows at once, and the rows arrive in the background. Deephaven updates the table, and every table built on it, as they land. For symbols passed in code or in a static table, they land all in one update, and m.streams() shows the read LOADING, then DONE or FAILED. Pass wait=True to wait for the rows; without a watchlist, you then get a static table.

Dates, such as "2025-03-03", read whole days in the market's time zone, both ends included. Times, such as a datetime with a time zone, read from start up to end, which is excluded. A bar is included only when its whole window is in the range and has ended.

Rows come from REST or from Massive's flat files. By default, the library picks the source and reads from REST any day the flat files can't serve. The table's description says which source it read. Each flat file holds a whole day of data, and a flat-file read downloads all of it, however few symbols or short a range you ask for.

A static table of symbols is read once, when you call. A watchlist is followed over the range fixed at the call: a symbol you add arrives with all its rows, and one you delete leaves (https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#drive-with-a-watchlist). One symbol's failure leaves the watchlist's other symbols in place, unless its cause is set to dm.OnError.RAISE, which fails the table. m.symbol_reads() shows each symbol's read.

Parameters:

Name Type Description Default
start DateLike

The first day, or the first time included.

required
end DateLike | None

The last day included, or the first time excluded. Leave it out to read through now.

None
source HistorySource

dm.HistorySource.AUTO, the default, picks the source; REST or FLAT_FILES forces one.

AUTO
reread Reread

For a watchlist, whether a symbol you delete and add back is downloaded again (dm.Reread.ALWAYS, the default) or gets its earlier rows back without a request (dm.Reread.NEVER).

ALWAYS
wait bool

False, the default, returns at once and fills the table in the background. True waits for the rows; for a watchlist, until each symbol has been read once.

False

Returns:

Type Description
Table

A table with the dataset's columns, with no row when none is in the range: live, or static for wait=True without a watchlist.

Raises:

Type Description
TypeError

If source isn't a dm.HistorySource, reread isn't a dm.Reread, wait isn't a bool, or a bound isn't a date or a time.

ValueError

At the call, before any request, if: - it runs on a Deephaven update-graph thread; - a bound is a datetime without a time zone, unreadable text, or NaT; - one bound is a date and the other a time; - start is after end, or in the future when end is left out; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - no source can serve the request; the message gives each reason; - the endpoint doesn't take one of the query's parameters or filters.

AuthenticationError

With wait=True, if Massive or its flat-file server rejects your keys.

EntitlementError

With wait=True, if your plan doesn't include the data from any source the call can use.

SessionClosedError

If the session is closed.

MassiveError

With wait=True, if: - a request fails; - adjusted bars come back unadjusted, or the reverse; - a trading day's flat file is missing and REST can't serve that day; - for a watchlist, every symbol's read failed.

Without wait=True, an error from Massive fails the table instead of raising: it is logged and shows in Error of m.streams(). A watchlist's table fails when every symbol it held at the call fails for good, unless one of them is read first or leaves the watchlist before it fails. A plan without the dataset is one such case.

Example
day = m.crypto.trades("X:BTCUSD").history("2026-01-02", "2026-01-02")
rows = m.crypto.trades("X:BTCUSD").history("2026-01-02", "2026-01-02", wait=True)
blink() -> Table

Return the stream as a blink table, which holds only the latest update cycle's rows.

A blink table keeps no history, so it suits a Deephaven aggregation that should count every row without storing them.

Returns:

Type Description
Table

A live blink table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

append_only
append_only() -> Table

Return every row the stream sends after the call, oldest first.

The table grows for as long as the stream runs; ring() keeps only the latest rows.

Returns:

Type Description
Table

A live append-only table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

ring
ring(capacity: int) -> Table

Return the latest capacity rows the stream sends.

Parameters:

Name Type Description Default
capacity int

How many rows to keep, from 1 to 2**31 - 1.

required

Returns:

Type Description
Table

A live ring table with the dataset's columns.

Raises:

Type Description
TypeError

If capacity isn't an int.

ValueError

At the call, before the table exists, if: - capacity is out of range; - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

StreamHistoryQuery dataclass

StreamHistoryQuery()

A query of a stream that also has history: the live feed and the past, with one schema.

Massive both streams some datasets live and keeps them for the past, such as stock trades and quotes, index values, and aggregate bars. Their dataset methods return a StreamHistoryQuery, which has every method of StreamQuery and of HistoryQuery: history(start, end) reads a past range, and the stream methods follow the live feed, with the same columns, so code written against one works on the other. help(StreamQuery) covers the stream methods and the symbols and watchlists they take.

A bars() call returns this class only for the bars Massive streams over its WebSocket, 1-second and 1-minute bars at multiplier=1; any other bars give a HistoryQuery, which has history() only. Its declared return type names both classes, so check the class with isinstance(q, StreamHistoryQuery) before you call a stream method on it.

Import it as from deephaven_massive.queries import StreamHistoryQuery to annotate your own code. You get one from a dataset method and never construct one.

Example
q = m.stocks.trades(["AAPL", "MSFT"])
live = q.append_only()
day = q.history("2025-03-03", "2025-03-03")

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")
history
history(start: DateLike, end: DateLike | None = None, *, source: HistorySource = HistorySource.AUTO, reread: Reread = Reread.ALWAYS, wait: bool = False) -> Table

Return the dataset's rows over a range of days or of exact times.

By default the call returns a live table with no rows at once, and the rows arrive in the background. Deephaven updates the table, and every table built on it, as they land. For symbols passed in code or in a static table, they land all in one update, and m.streams() shows the read LOADING, then DONE or FAILED. Pass wait=True to wait for the rows; without a watchlist, you then get a static table.

Dates, such as "2025-03-03", read whole days in the market's time zone, both ends included. Times, such as a datetime with a time zone, read from start up to end, which is excluded. A bar is included only when its whole window is in the range and has ended.

Rows come from REST or from Massive's flat files. By default, the library picks the source and reads from REST any day the flat files can't serve. The table's description says which source it read. Each flat file holds a whole day of data, and a flat-file read downloads all of it, however few symbols or short a range you ask for.

A static table of symbols is read once, when you call. A watchlist is followed over the range fixed at the call: a symbol you add arrives with all its rows, and one you delete leaves (https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#drive-with-a-watchlist). One symbol's failure leaves the watchlist's other symbols in place, unless its cause is set to dm.OnError.RAISE, which fails the table. m.symbol_reads() shows each symbol's read.

Parameters:

Name Type Description Default
start DateLike

The first day, or the first time included.

required
end DateLike | None

The last day included, or the first time excluded. Leave it out to read through now.

None
source HistorySource

dm.HistorySource.AUTO, the default, picks the source; REST or FLAT_FILES forces one.

AUTO
reread Reread

For a watchlist, whether a symbol you delete and add back is downloaded again (dm.Reread.ALWAYS, the default) or gets its earlier rows back without a request (dm.Reread.NEVER).

ALWAYS
wait bool

False, the default, returns at once and fills the table in the background. True waits for the rows; for a watchlist, until each symbol has been read once.

False

Returns:

Type Description
Table

A table with the dataset's columns, with no row when none is in the range: live, or static for wait=True without a watchlist.

Raises:

Type Description
TypeError

If source isn't a dm.HistorySource, reread isn't a dm.Reread, wait isn't a bool, or a bound isn't a date or a time.

ValueError

At the call, before any request, if: - it runs on a Deephaven update-graph thread; - a bound is a datetime without a time zone, unreadable text, or NaT; - one bound is a date and the other a time; - start is after end, or in the future when end is left out; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - no source can serve the request; the message gives each reason; - the endpoint doesn't take one of the query's parameters or filters.

AuthenticationError

With wait=True, if Massive or its flat-file server rejects your keys.

EntitlementError

With wait=True, if your plan doesn't include the data from any source the call can use.

SessionClosedError

If the session is closed.

MassiveError

With wait=True, if: - a request fails; - adjusted bars come back unadjusted, or the reverse; - a trading day's flat file is missing and REST can't serve that day; - for a watchlist, every symbol's read failed.

Without wait=True, an error from Massive fails the table instead of raising: it is logged and shows in Error of m.streams(). A watchlist's table fails when every symbol it held at the call fails for good, unless one of them is read first or leaves the watchlist before it fails. A plan without the dataset is one such case.

Example
day = m.crypto.trades("X:BTCUSD").history("2026-01-02", "2026-01-02")
rows = m.crypto.trades("X:BTCUSD").history("2026-01-02", "2026-01-02", wait=True)
blink() -> Table

Return the stream as a blink table, which holds only the latest update cycle's rows.

A blink table keeps no history, so it suits a Deephaven aggregation that should count every row without storing them.

Returns:

Type Description
Table

A live blink table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

append_only
append_only() -> Table

Return every row the stream sends after the call, oldest first.

The table grows for as long as the stream runs; ring() keeps only the latest rows.

Returns:

Type Description
Table

A live append-only table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

ring
ring(capacity: int) -> Table

Return the latest capacity rows the stream sends.

Parameters:

Name Type Description Default
capacity int

How many rows to keep, from 1 to 2**31 - 1.

required

Returns:

Type Description
Table

A live ring table with the dataset's columns.

Raises:

Type Description
TypeError

If capacity isn't an int.

ValueError

At the call, before the table exists, if: - capacity is out of range; - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

last_by
last_by(by: str | Sequence[str] = 'Symbol') -> Table

Return the latest row of each key, by default one row per symbol.

The table starts empty and gains each key's row when its first update arrives. For each symbol's current state at once, poll a snapshot instead, such as m.stocks.snapshots(["AAPL", "MSFT"]).poll(5).

With a watchlist, each symbol's row shows only while the symbol is on it.

Parameters:

Name Type Description Default
by str | Sequence[str]

The key column or columns, as in Deephaven's Table.last_by; "Symbol" by default. Name each column once.

'Symbol'

Returns:

Type Description
Table

A live table with the dataset's columns and one row per key.

Raises:

Type Description
TypeError

If by isn't a str or a sequence of str.

ValueError

At the call, before the table exists, if: - by is empty, repeats a column, or names a column the dataset doesn't have; - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

Query dataclass

Query()

Any query: the common type of what every dataset method returns.

A query describes one read of a dataset (its symbols, its range, its parameters) and reads nothing until you call one of its methods, each of which returns a Deephaven table. Which methods it has depends on its subclass: FetchQuery, StreamQuery, NoSymbolStreamQuery, HistoryQuery, StreamHistoryQuery, or NoSymbolStreamHistoryQuery. Annotate with Query when your code takes any query and uses only what every query has: columns() and its repr, which is the call that built it, such as m.stocks.trades(['AAPL', 'MSFT']).

Import it as from deephaven_massive.queries import Query. You get a query from a dataset method, such as m.stocks.trades("AAPL"); calling a query class raises TypeError. A query is immutable and hashable, safe to share between threads, and equal to another query of the same class and session that asks for the same data.

Example
from deephaven.table import Table

from deephaven_massive.queries import Query


def column_names(query: Query) -> Table:
    return query.columns().view("Name")


names = column_names(m.stocks.trades("AAPL"))

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")

NoSymbolStreamQuery dataclass

NoSymbolStreamQuery()

A query of a live stream whose rows name no symbol: blink(), append_only(), ring().

Massive sends OPRA's administrative messages per channel rather than per symbol. Their rows have no Symbol column, so their query has no last_by(). Each of its three methods returns the stream as a different kind of live Deephaven table: blink() holds only the latest update cycle's rows, append_only() keeps every row since the call, and ring(capacity) keeps the latest capacity rows.

Identical queries share one stream, and each call returns its own table. The stream stays subscribed while any of its tables, or a table made from one, is in use. A method returns once its table exists, without waiting for Massive to confirm the subscription. A later failure, such as a refused subscription or a rejected key, fails the table and shows in m.streams(), and the next call on an identical query opens a new stream.

Import it as from deephaven_massive.queries import NoSymbolStreamQuery to annotate your own code. You never construct one. m.options.admin_messages() returns its subclass NoSymbolStreamHistoryQuery, which adds history().

Example
notices = m.options.admin_messages().append_only()

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")
blink() -> Table

Return the stream as a blink table, which holds only the latest update cycle's rows.

A blink table keeps no history, so it suits a Deephaven aggregation that should count every row without storing them.

Returns:

Type Description
Table

A live blink table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

append_only
append_only() -> Table

Return every row the stream sends after the call, oldest first.

The table grows for as long as the stream runs; ring() keeps only the latest rows.

Returns:

Type Description
Table

A live append-only table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

ring
ring(capacity: int) -> Table

Return the latest capacity rows the stream sends.

Parameters:

Name Type Description Default
capacity int

How many rows to keep, from 1 to 2**31 - 1.

required

Returns:

Type Description
Table

A live ring table with the dataset's columns.

Raises:

Type Description
TypeError

If capacity isn't an int.

ValueError

At the call, before the table exists, if: - capacity is out of range; - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

StreamQuery dataclass

StreamQuery()

A query of a live WebSocket stream: blink(), append_only(), ring(), and last_by().

Massive streams trades, quotes, bars, and other events over its WebSocket as they happen. A stream's dataset method returns a StreamQuery, and each of its methods returns the same stream as a different kind of live Deephaven table: blink() holds only the latest update cycle's rows, append_only() keeps every row since the call, ring(capacity) keeps the latest capacity rows, and last_by() keeps each symbol's latest row, a live table of the current state of every symbol you follow. A stream whose rows name no symbol has no last_by(), so its query is a NoSymbolStreamQuery instead.

Identical queries share one stream, and each call returns its own table. The stream stays subscribed while any of its tables, or a table made from one, is in use. A method returns once its table exists, without waiting for Massive to confirm the subscription. A later failure, such as a refused subscription or a rejected key, fails the table and shows in m.streams(), and the next call on an identical query opens a new stream.

The symbols can be a list, a static table, which is read once at the call, or a live table, which works as a watchlist: the stream subscribes and unsubscribes as you add and delete rows. A watchlist row that isn't Massive's exact ticker is skipped and listed in m.streams(). Massive allows 1,000 option contracts on one connection, and the library counts a contract's trades and quotes as two. More contracts than that, passed as a list or a static table, raise ValueError; a watchlist's extra contracts wait for room, and Deferred in m.streams() counts them.

Import it as from deephaven_massive.queries import StreamQuery to annotate your own code. You get one from a dataset method and never construct one.

Example
bands = m.stocks.luld(dm.ALL).last_by()  # the latest band of every ticker
recent = m.stocks.imbalances(["AAPL", "MSFT"]).ring(1000)

Refuse to build a query: a dataset method builds every query.

Raises:

Type Description
TypeError

Always. Call a dataset method instead, such as m.stocks.trades("AAPL").

Methods:
columns
columns() -> Table

List the dataset's columns, their types, and what each one means.

Every method of the query returns these columns, in this order. A column that the call's source doesn't fill is null. The call reads nothing from Massive and works on a closed session.

Returns:

Type Description
Table

A static table with one row per column, and these columns:

  • Name: the column's name.
  • Type: its Deephaven type, such as double, long, String, or Instant. A calendar date, such as Date, is yyyy-MM-dd text.
  • Description: what it holds, empty where Massive gives no description.
  • SuppliedBy: the sources that fill it: REST, flat files, or WebSocket. fetch() and poll() read REST, the stream methods read the WebSocket, and history() reads REST or flat files.

Raises:

Type Description
ValueError

If called on a Deephaven update-graph thread, such as inside a table listener.

Example
cols = m.stocks.trades("AAPL").columns()
# The columns a stream leaves null.
not_streamed = cols.where("!SuppliedBy.contains(`WebSocket`)")
blink() -> Table

Return the stream as a blink table, which holds only the latest update cycle's rows.

A blink table keeps no history, so it suits a Deephaven aggregation that should count every row without storing them.

Returns:

Type Description
Table

A live blink table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

append_only
append_only() -> Table

Return every row the stream sends after the call, oldest first.

The table grows for as long as the stream runs; ring() keeps only the latest rows.

Returns:

Type Description
Table

A live append-only table with the dataset's columns.

Raises:

Type Description
ValueError

At the call, before the table exists, if: - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

ring
ring(capacity: int) -> Table

Return the latest capacity rows the stream sends.

Parameters:

Name Type Description Default
capacity int

How many rows to keep, from 1 to 2**31 - 1.

required

Returns:

Type Description
Table

A live ring table with the dataset's columns.

Raises:

Type Description
TypeError

If capacity isn't an int.

ValueError

At the call, before the table exists, if: - capacity is out of range; - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.

last_by
last_by(by: str | Sequence[str] = 'Symbol') -> Table

Return the latest row of each key, by default one row per symbol.

The table starts empty and gains each key's row when its first update arrives. For each symbol's current state at once, poll a snapshot instead, such as m.stocks.snapshots(["AAPL", "MSFT"]).poll(5).

With a watchlist, each symbol's row shows only while the symbol is on it.

Parameters:

Name Type Description Default
by str | Sequence[str]

The key column or columns, as in Deephaven's Table.last_by; "Symbol" by default. Name each column once.

'Symbol'

Returns:

Type Description
Table

A live table with the dataset's columns and one row per key.

Raises:

Type Description
TypeError

If by isn't a str or a sequence of str.

ValueError

At the call, before the table exists, if: - by is empty, repeats a column, or names a column the dataset doesn't have; - it runs on a Deephaven update-graph thread; - a static table of symbols is empty, or no row of a table of symbols is Massive's exact ticker; - option contracts passed as a list or a static table pass the connection's limit.

AuthenticationError

If Massive rejects your API key while the call checks which feed your plan streams. A later rejection fails the table instead.

EntitlementError

If Massive's data for this dataset is delayed and its subscription isn't in MassiveConfig.delayed_subscriptions. The message names the setting to change.

SessionClosedError

If the session is closed.

MassiveError

If the stream fails while it opens.