deephaven_massive
deephaven_massive ¶
Market data from Massive as live and historical Deephaven tables, for traders and quants.
Testing a trading idea usually takes one program for history and another for the live feed. Here, one query of a streaming dataset gives both, with the same columns.
Every dataset works the same way. Create a session, call a dataset method to get a query, and call one of the query's methods to get a Deephaven table.
Example
In the Deephaven console, with your API key in MASSIVE_API_KEY:
import deephaven_massive as dm
m = dm.MassiveSession()
# Apple's daily bars for one week.
apple = m.stocks.bars("AAPL", dm.Timespan.DAY).history("2026-10-26", "2026-10-30")
# Each stock's latest minute bar, kept live.
latest = m.stocks.bars(["AAPL", "MSFT"], dm.Timespan.MINUTE).last_by()
Datasets
Each dataset is a method of a namespace on the session. The namespaces by asset class are
m.stocks, m.options, m.futures, m.indices, m.forex, and m.crypto. The ones by
topic are m.reference, m.indicators, m.economy, and m.partners. m.snapshots()
reads symbols of several asset classes at once. dm.datasets() lists every dataset in a
table, with each one's query methods in its Methods column.
To annotate your own code, import the class of a namespace, such as StocksNamespace for
m.stocks, from deephaven_massive.namespaces, and the class of a query, such as
StreamHistoryQuery, from deephaven_massive.queries. The types of the arguments,
dm.SymbolsLike, dm.DateLike, and dm.FilterValue, are here, and so is
dm.AllSymbols, the type of dm.ALL.
Query methods
A query reads nothing until you call one of its methods. It has only the methods its dataset supports:
history(start, end): a table of a past range.fetch(): a table of what Massive has now.poll(interval): a live table that fetches again everyintervalseconds.blink(): a live table of a stream's rows from the latest update cycle.append_only(): a live table of every row a stream sends after the call.ring(capacity): a live table of a stream's latestcapacityrows.last_by(): a live table of each symbol's latest row from a stream.
columns() on any query lists its columns and what each one means.
A live table updates while anything uses it: a variable, a panel, or a table made from it.
m.release(table) drops your variable's hold at once. The table then stops when no panel
or table made from it is left. m.close() stops every live table of the session.
Settings
dm.MassiveConfig holds a session's settings. Pass it as dm.MassiveSession(config). Two
settings match a session to your plans:
delayed_subscriptionslists the subscriptions whose data Massive serves you delayed. Their streams use Massive's delayed feed, and theirfetch()andpoll()tables accept delayed data.rest_requests_per_minutekeeps a subscription's requests within the limit Massive gives your plan from the first request.
help(dm.MassiveConfig) lists every setting. dm.ErrorPolicy decides what a bad symbol or
row does, for the session or for one call.
Symbols
Datasets take Massive's tickers, spelled exactly: AAPL, BRK.B, O:SPY271217C00700000,
I:SPX, C:EURUSD, X:BTCUSD, and ESZ6. dm.ALL means every symbol, in the datasets
that take it. A table with a Symbol column works too. A live one is a watchlist, which
the library follows as you add and delete rows. dm.canonical_symbol and
dm.canonicalize_symbols convert other spellings, such as Yahoo's BRK-B.
Enums
An argument with a fixed set of values takes an enum member, such as dm.Timespan.MINUTE.
dm.Timespan("minute") converts text to a member.
Errors
dm.MassiveError covers every error Massive reports and every failure inside a method of
a query, such as fetch(). dm.AuthenticationError means your API key is missing or Massive
refused your keys. dm.EntitlementError means your plan doesn't include the data.
dm.SessionClosedError means the session is closed. Each error's source says what
stopped the call, as a dm.ErrorSource. Its is_retryable says whether the same call may
succeed later, and its is_bug whether a bug caused it.
A wrong argument raises TypeError or ValueError at the call instead.
dm.enable_debug_logging() records what the library does, for a bug report.
Server
The library runs inside a Deephaven server: in its console, in an application script, or in a Python program that starts one first. Importing the package without a running server fails with Deephaven's own error. In a plain Python program, start the server before the import:
from deephaven_server import Server
Server(port=10000, jvm_args=["-Xmx4g"]).start()
import deephaven_massive as dm
Attributes:
| Name | Type | Description |
|---|---|---|
__version__ |
str
|
The installed version, such as |
Attributes¶
DateLike
module-attribute
¶
DateLike: TypeAlias = str | date | datetime | np.datetime64
A time bound: history()'s start and end, a list's start, end, and as_of, a day.
Every argument that names a date or an instant takes any of these forms, so a caller can pass
text, a Python or Java time, or a numpy or pandas one, whichever their code holds. Annotate your
own code with it, as dm.DateLike, when you pass a time through to a dataset method. One of:
- text, read by one of two parsers:
- ISO-8601: a date in any ISO form (
"2025-03-03","20250303","2025-W10-1"), or a date and time with an offset ("2025-03-03T09:30:00-05:00"), whose digits below the microsecond are rounded outward like a Java instant's; - otherwise Deephaven's own date text, as
deephaven.time.to_j_local_datereads it ("2025-3-3"), or its date and time text with a zone, asto_j_zdtreads it ("2025-03-03T09:30 America/New_York","2025-03-03T09:30:00 ET"). Deephaven text that names a day and a zone but no time ("2025-03-03 ET") is refused, since Deephaven reads it as that midnight. Deephaven's instant parser is never used: it reads bare digits as an epoch count; - a
date, or a timezone-awaredatetime, apandas.Timestampamong them (its nanoseconds are kept and moved outward to a microsecond like a Java instant's); - a Java
java.time.LocalDate(a date), or a JavaInstantorZonedDateTime(an instant, moved outward to a microsecond: a start down, an end up), the values Deephaven's own time functions return, such asdeephaven.time.dh_now()andto_j_local_date("2025-03-03"), andInstantandLocalDatecells read as Java values (throughiter_dict, for one).dh_today()returns ISO text, the first form; - a
numpy.datetime64: a date at day precision (numpy.datetime64("2025-03-03")), otherwise an instant in UTC, as Deephaven reads it (to_numpygives anInstantcolumn so), moved outward to a microsecond like a Java instant. A week, month, or year is refused: as anendit would shrink the range to its first day, and a numpy week starts on a Thursday.
These are the inputs Deephaven's own deephaven.time converters take, except a bare integer
(epoch nanoseconds there, which would silently misread a date written as 20250303) and text
Deephaven reads only as such a count.
Type checkers see Deephaven's Java values as Any, so the alias does not name them. A naive
datetime or pandas.Timestamp, or an ISO string with a time but no UTC offset, raises a
ValueError that names the parameter and the fix ("needs a timezone: pass an aware datetime or
a date"), since a time without a zone cannot be placed. A date-only value is a whole day in the
asset class's day zone.
FilterValue
module-attribute
¶
FilterValue: TypeAlias = str | int | float | bool | date | datetime | np.datetime64 | Sequence[str | int | float | date | np.datetime64]
A value in the filters mapping, which narrows a dataset by any of Massive's parameters.
filters passes Massive's own query parameters that a dataset method has no argument for, keyed
by the wire parameter name with its dots written as underscores, such as strike_price_gte or
ticker_any_of. Annotate your own code with it, as dm.FilterValue, when you build such a
mapping.
A sequence is the value of an _any_of key: text items, numbers for a list of numbers
(strike_price_any_of), or dates for a list of dates (date_any_of). A date or time takes
every object DateLike names: a date, an aware datetime or pandas.Timestamp, a Java
LocalDate, Instant, or ZonedDateTime, or a numpy.datetime64; a sequence of dates takes
the day forms. Whether text is a date or a time depends on the parameter, so a filter reads
only ISO-8601 text as one.
ALL
module-attribute
¶
ALL: Final = AllSymbols.ALL
Every symbol: a stream of the whole market, a whole flat file, or a full-market snapshot.
ALL is accepted by the stream methods, by every per-class snapshots(), and by history()
when a flat file or a grouped-daily REST path exists. Everywhere else it raises ValueError
naming the alternative.
SymbolsLike
module-attribute
¶
SymbolsLike: TypeAlias = str | Sequence[str] | Table | AllSymbols
What a market-data dataset method takes as its symbols: the instruments it reads.
Annotate your own code with it when you pass symbols through to a dataset method, such as a helper that takes either a list of tickers or a watchlist table. It is one of:
- a
str: one symbol, such as"AAPL"; - a sequence of
str: several symbols, read when the query is built; - a Deephaven
Tablewith aSymbolcolumn: a static table is read when a query method runs, and a live table works as a watchlist, which the query's methods follow as you add and delete rows; dm.ALL: every symbol, in the datasets that take it.
Each symbol, and each row of a table, is Massive's exact ticker, such as "C:EURUSD", not
"EUR/USD"; dm.canonical_symbol and dm.canonicalize_symbols convert other spellings.
Example
from deephaven.table import Table
import deephaven_massive as dm
def latest_quotes(m: dm.MassiveSession, symbols: dm.SymbolsLike) -> Table:
return m.stocks.quotes(symbols).last_by()
Classes¶
MassiveConfig
dataclass
¶
MassiveConfig(*, api_key: str = _env_api_key(), s3_access_key_id: str | None = _env_s3_access_key_id(), s3_secret_access_key: str | None = _env_s3_secret_access_key(), websocket_hosts: Mapping[AssetClass, str] = dict(), subscription_confirmation_timeout: float = 5.0, reconnect_backoff: float = 30.0, max_reconnect_backoff: float = 120.0, connection_taken: ConnectionTaken = ConnectionTaken.FAIL, max_outage: float = 300.0, flat_file_symbol_threshold: int = 50, max_concurrency: int = 8, rest_requests_per_minute: Mapping[Subscription, int] = dict(), delayed_subscriptions: Set[Subscription] = frozenset(), flush_interval: float = 0.05, rest_base_url: str = 'https://api.massive.com', s3_endpoint_url: str = 'https://files.massive.com', s3_bucket: str = 'flatfiles', on_error: ErrorPolicy = ErrorPolicy())
Everything a MassiveSession needs to know: credentials, plan, hosts, timeouts, limits.
Construct it with keyword arguments; any field left out takes its default, and the
credentials default to the environment. Every value is checked when you create it, and
none can change afterward, so one config can serve several sessions. Its repr leaves out
your secrets.
Example
import deephaven_massive as dm
cfg = dm.MassiveConfig() # MASSIVE_API_KEY from the environment
# Real-time stocks; options from Massive's delayed feed.
mixed = dm.MassiveConfig(delayed_subscriptions={dm.Subscription.OPTIONS})
# Stocks streams always from Massive's real-time host, socket.massive.com; at
# most 4 REST requests or flat-file reads at once.
pinned = dm.MassiveConfig(
websocket_hosts={dm.AssetClass.STOCKS: "socket.massive.com"},
max_concurrency=4,
)
m = dm.MassiveSession(pinned)
MassiveConfig.from_file() builds one from a settings file instead; see there. Every
setting, with its settings-file spelling, its values, and its default, is on
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/configuration.md.
Attributes:
| Name | Type | Description |
|---|---|---|
api_key |
str
|
The Massive API key. Defaults to the |
s3_access_key_id |
str | None
|
The flat-file S3 access key id. Defaults to the
|
s3_secret_access_key |
str | None
|
The flat-file S3 secret. Defaults to the
|
delayed_subscriptions |
Set[Subscription]
|
Lists the subscriptions whose data Massive serves you delayed, so
their streams use Massive's delayed feed and their snapshots accept its Massive labels such data Leave a delayed subscription out, and a call for its current data fails with
|
rest_requests_per_minute |
Mapping[Subscription, int]
|
Gives each subscription's REST request limit on your plan, so its requests keep to it from the first one. Defaults to an empty mapping. List each subscription Massive limits, with its limit in requests a minute, such as
5 for Leave a limited subscription out, and the session learns its limit from Massive's
first rate-limit error, after a pause. Every session in this server that uses your key shares one limit per subscription. When sessions list different limits, the lowest applies. |
websocket_hosts |
Mapping[AssetClass, str]
|
Streams an asset class from a WebSocket host you name instead of the one
the library picks, such as Set A host you set moves every stream of its asset class. Fair market value streams
are the exception: they always use The host you set is used as given, whatever Massive's label says. When Massive doesn't serve your key there, the stream fails with Massive's refusal.
Write the lower-case hostname alone: |
subscription_confirmation_timeout |
float
|
Sets how many seconds Massive has to confirm a stream's channel before the library asks again. Defaults to 5 seconds. Raise it on a slow network, where confirmations arrive late. It must be below 60 seconds. |
reconnect_backoff |
float
|
Sets the shortest wait, in seconds, before reconnecting a dropped stream. Defaults to 30 seconds. Lower it to reconnect sooner after a brief drop. It must be at least 15 seconds,
which limits reconnect churn, and at most Each failure in a row doubles the wait, up to |
max_reconnect_backoff |
float
|
Sets the longest wait, in seconds, before reconnecting a dropped stream. Defaults to 120 seconds. Lower it to retry more often during a long outage, or raise it to retry less often.
It must be at least |
connection_taken |
ConnectionTaken
|
Decides what a live table does when another connection with the same
API key takes over its own. Defaults to Massive allows your account one WebSocket connection per asset class, and keeps the newest. When another program, or a session with different streaming settings, connects with the same key, Massive closes this session's connection.
Sessions with the same key and streaming settings share one connection whatever this setting. See https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#live-table-messages. |
max_outage |
float
|
Sets how many seconds a live table waits out an outage or Massive's rate limits before it fails. Defaults to 300 seconds. Set a larger value when your tables should ride out longer outages, or
A symbol whose reads keep failing with a temporary error, or with an A failed table stays failed, so call the method again for a new one. See https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#live-table-messages. |
flat_file_symbol_threshold |
int
|
Sets how many symbols in a list make a Lower it to read flat files for shorter lists, or raise it to keep them on requests. Each flat file holds a whole day of data, and a flat-file read downloads all of it, however few symbols you ask for. A call for this many symbols or more reads flat files when all of these hold:
A |
max_concurrency |
int
|
Sets how many REST requests the session runs at a time, and separately how many flat files it reads at a time. Defaults to 8. Raise it to run more at once, or lower it to open fewer connections. Each limit
covers all the session's calls together. The same number limits the downloads of
|
flush_interval |
float
|
Sets how many seconds pass between the batches of streamed rows added to live tables. Defaults to 0.05 seconds (50 ms). A shorter interval shows each row sooner, and a longer one adds more rows in each update. |
rest_base_url |
str
|
Sets the URL REST requests go to. Defaults to Change it only to reach a server other than Massive's, such as a local test server.
The config refuses a URL with a path, a query, a fragment, a user and password, or
port 0. It also refuses an |
s3_endpoint_url |
str
|
Sets the URL flat files are read from. Defaults to
Change it only to reach a server other than Massive's. |
s3_bucket |
str
|
Sets the S3 bucket flat files are read from. Defaults to Change it only with |
on_error |
ErrorPolicy
|
Decides what one bad symbol or row does: fail the table, or skip it and keep
going. Defaults to Set a cause to A dataset method's |
Methods:¶
from_file
classmethod
¶
from_file(path: str | PathLike[str] | None = None) -> MassiveConfig
Build a configuration from a YAML settings file, for settings shared between scripts.
The file is a mapping of setting names, the attribute names of this class, to values;
a setting it leaves out takes its default. Precedence is code, then the file, then the
defaults: override a setting of the file in code with dataclasses.replace. The credentials
are never read from the file; they come from code or from their environment variables, as
for MassiveConfig(). Every scalar is read as text and converted by the setting's own rule,
so a ticker such as ON or NO stays text, and an enum word is taken only as spelled
exactly (raise, not Raise). Every setting's spelling, values, and default, with an
example file, are on
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/configuration.md.
Example
import dataclasses
import deephaven_massive as dm
# settings.yaml holds, for example:
# delayed_subscriptions: [options]
# max_outage: 600
cfg = dm.MassiveConfig.from_file("~/massive/settings.yaml")
cfg = dataclasses.replace(cfg, max_concurrency=4) # code wins over the file
m = dm.MassiveSession(cfg)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str] | None
|
The file, as a |
None
|
Returns:
| Type | Description |
|---|---|
MassiveConfig
|
The validated configuration. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
FileNotFoundError
|
If the file does not exist; the message names it, and the environment variable when the path came from there. |
OSError
|
If the file exists but cannot be read. |
AuthenticationError
|
If no API key is in the environment. |
Side effects
Reads the file once, and logs one INFO line naming it and the settings it set.
AllSymbols ¶
The type of dm.ALL, the value that asks a dataset for every symbol.
Pass dm.ALL itself, as in m.stocks.trades(dm.ALL); name dm.AllSymbols only in a type
hint, as dm.SymbolsLike does. dm.ALL is its one member, and an enum member stays itself
through a copy or an unpickle, so code tests for it with symbols is dm.ALL. It is not a
str, so it is never mistaken for a ticker.
LogOutput ¶
Where enable_debug_logging writes the log, when it is not a file.
Pass a member, or a file path (str or os.PathLike), as output.
Example
import deephaven_massive as dm
dm.enable_debug_logging(dm.LogOutput.STDERR) # the default
dm.enable_debug_logging("/tmp/massive.log") # a file instead
AssetClass ¶
An asset class, such as stocks or crypto.
Pin a streaming host with it in MassiveConfig.websocket_hosts, and filter the reference
datasets m.reference.ticker_types, m.reference.exchanges, and m.reference.conditions by
it. The diagnostics tables show it too.
Example
import deephaven_massive as dm
config = dm.MassiveConfig(websocket_hosts={dm.AssetClass.STOCKS: "socket.massive.com"})
ConditionDataType ¶
The kind of tick a condition code applies to (m.reference.conditions).
Example
import deephaven_massive as dm
assert dm.ConditionDataType("trade") is dm.ConditionDataType.TRADE
ConnectionTaken ¶
What a live table does when another connection with the same API key takes over its own.
Massive allows your account one WebSocket connection per asset class. When another program
connects with the same key, Massive keeps the newer connection and closes the older one.
Another session on this server does the same when its streaming settings, such as
max_outage, differ from this one's. MassiveConfig.connection_taken
picks what the older connection's live tables do:
FAIL, the default: they fail at once, with aMassiveErrorthat names the time and the fix.RECONNECT: they reconnect afterreconnect_backoffand take the connection back. Meanwhile, theirm.streams()row'sErrorsays when the connection was taken and when it is taken back. They miss the data of each gap, and if the other program does the same, the two take turns indefinitely.
Sessions with the same key and streaming settings share one connection whatever this setting, and each table follows its own session's setting.
Example
import deephaven_massive as dm
assert dm.ConnectionTaken("reconnect") is dm.ConnectionTaken.RECONNECT
config = dm.MassiveConfig(connection_taken=dm.ConnectionTaken.RECONNECT)
ContractType ¶
The type of an options contract, for the contract_type argument of the options datasets.
The chain, the contracts, and the open interest filter by it. Its values are the
contract_type values those endpoints accept: calls and puts.
Example
import deephaven_massive as dm
m = dm.MassiveSession()
puts = m.options.chain("AAPL", contract_type=dm.ContractType.PUT).fetch()
assert dm.ContractType("call") is dm.ContractType.CALL
Direction ¶
Which side of the market movers() returns.
Example
import deephaven_massive as dm
m = dm.MassiveSession()
gainers = m.crypto.movers(dm.Direction.GAINERS).poll(60)
assert dm.Direction("losers") is dm.Direction.LOSERS
FuturesVenue ¶
A futures exchange, which picks the flat files a futures history() reads.
A futures dataset's venues argument takes a set of members. Left out, a read takes every
exchange the plan allows and skips each one Massive refuses with a warning; the
refused_venues cause of dm.ErrorPolicy says what happens when Massive refuses an
exchange the call names. Both apply only to flat files: streams cover every exchange.
Example
import deephaven_massive as dm
assert dm.FuturesVenue("cme") is dm.FuturesVenue.CME
HistorySource ¶
Where history() reads from.
AUTO: the library picks flat files or REST. The choice depends on whether you set S3 keys, the dataset, the bars andadjusted, and how many symbols you ask for. When REST can serve them, it reads from REST any day whose file is missing or isn't in your plan.REST: Massive's REST API.FLAT_FILES: Massive's flat files, the daily CSV files it publishes on S3. They need S3 keys. Each file holds a whole day of data, and a read downloads all of it, however few symbols or short a range you ask for.
Example
import deephaven_massive as dm
assert dm.HistorySource("flat_files") is dm.HistorySource.FLAT_FILES
Locale ¶
The locale the reference endpoints filter by.
Example
import deephaven_massive as dm
assert dm.Locale("us") is dm.Locale.US
Market ¶
The market m.reference.tickers filters by.
Example
import deephaven_massive as dm
assert dm.Market("otc") is dm.Market.OTC
OnError ¶
What a problem does: fail, or keep going with or without a log record.
One bad symbol or row never stops a table by default. The members:
RAISE: fail whatever met the problem. A check at the call raises, and so does a call withwait=True. A live table fails, a watchlist read byfetch()orhistory()included: one symbol's problem fails the whole table, not only that symbol.LOG: skip the value and keep going.m.problems()lists each problem, and the first of each cause on each table logs one WARNING that points there; the rest log at DEBUG. A row of Massive's data the library can't read whole is never published, under any setting.IGNORE: keep going asLOGdoes, with nothing logged above DEBUG.
Each cause has its own setting in dm.ErrorPolicy, set for the session
(MassiveConfig.on_error) or for one call (a dataset method's on_error=); its docstring
lists the causes. The symbol converters take a member directly: the on_error argument of
canonicalize_symbols (default LOG), and of canonical_symbol and the per-class
converters (default RAISE, where LOG and IGNORE return None), for a value that
doesn't convert.
Example
import deephaven_massive as dm
assert dm.OnError("log") is dm.OnError.LOG
strict = dm.MassiveConfig(
on_error=dm.ErrorPolicy(noncanonical_symbols=dm.OnError.RAISE)
)
Order ¶
The sort direction of a REST list endpoint (the order parameter).
Example
import deephaven_massive as dm
assert dm.Order("desc") is dm.Order.DESC
PollMode ¶
How a poll() table combines one poll's rows with the last.
AUTO, the default ofpoll(): the mode the dataset's page names. It'sAPPENDfor the news and filings feeds,UPSERTfor IPOs, andREPLACEfor the rest.REPLACE: a keyed table that holds exactly the latest poll's rows. A key the poll doesn't return is deleted, even when the poll returns no rows.UPSERT: a keyed table that adds and updates rows but never deletes them.APPEND: an append-only table that adds only rows it hasn't seen. The dataset's keys identify a row, such as a news article's id. A snapshot's update time is part of its key, soAPPENDon a snapshot records each new state of a symbol. A later revision that changes none of the key columns isn't added.UPSERTfollows revisions.
Example
import deephaven_massive as dm
assert dm.PollMode("append") is dm.PollMode.APPEND
Reread ¶
Whether history() of a watchlist downloads a symbol again when you add it back.
A history() of a watchlist reads each symbol you add over the call's range. It drops each
symbol you delete. This setting decides what happens when a deleted symbol comes back. It has no
effect when symbols isn't a live table.
ALWAYS, the default: the symbol is downloaded again and shows Massive's current data. It has no rows until the download lands.NEVER: the symbol gets its earlier rows back at once, with no request. The result keeps every download in memory for as long as it lives, andReadAtinm.symbol_reads()says when each was made.
A symbol whose download failed is downloaded again when it comes back, under either member.
Example
import deephaven_massive as dm
assert dm.Reread("never") is dm.Reread.NEVER
SeriesType ¶
The bar price an indicator is computed from.
Example
import deephaven_massive as dm
assert dm.SeriesType("close") is dm.SeriesType.CLOSE
Sip ¶
The securities information processor a condition code belongs to.
The values are upper case, as Massive spells them.
Example
import deephaven_massive as dm
assert dm.Sip("OPRA") is dm.Sip.OPRA
Subscription ¶
One of Massive's five subscriptions, each with its own plan.
Massive sells its data as five subscriptions, one per asset class, with forex and crypto
sharing CURRENCIES. A subscription's plan may limit how many REST requests a minute it
makes. All the API keys of your account share the limits.
Give each limited subscription's limit in MassiveConfig.rest_requests_per_minute, so its
requests keep to it from the first one. Without it, the library slows down after Massive's
first rate-limit error. m.rate_limits() shows each subscription's state. Datasets Massive
assigns to no subscription share a limit of their own, other. Reference, economy, and
partner data are among them. The library learns that limit from Massive's rate-limit errors.
Example
import deephaven_massive as dm
# Options and currencies (forex and crypto) limited to 5 requests a minute.
config = dm.MassiveConfig(
rest_requests_per_minute={dm.Subscription.OPTIONS: 5, dm.Subscription.CURRENCIES: 5}
)
SymbolConvention ¶
The convention a symbol is written in, which canonical_symbol converts from.
Massive writes a share class as .B (BRK.B) and a preferred as a lower-case p and its
series (KIMpL), as the CTA's CQS convention does, so CQS text needs no conversion. The
other members name the exact grammar of one other US stock convention; only plain
tickers, share classes, and preferreds convert, because Massive documents no spelling for
warrants, units, rights, or when-issued shares.
MASSIVE: Massive's own spelling, the default. A canonical ticker comes back unchanged; a forex, crypto, index, or option symbol in another unambiguous spelling of its class converts (EUR/USDtoC:EURUSD,SPXtoI:SPXfor the indices class); a stock ticker in another convention's spelling raises, since-means a class to Yahoo and a preferred to Nasdaq. It is the only member every class takes.YAHOO: Yahoo Finance; a class is-B(BRK-B), a preferred-Pand its series (BAC-PL).NASDAQ: the Nasdaq Integrated Platform symbology (the "NASDAQ Symbol" column ofnasdaqtraded.txt); a class is.B, a preferred-and its optional series (KIM-L).CMS: the root, a space, and a suffix, as many broker and FIX systems write it; a class isB(BRK B), a preferredPRand its optional series (BAC PRL).
YAHOO, NASDAQ, and CMS apply to stocks only. Each names a source of symbols, not an
exchange: pick the one the tickers came from, not where the stock trades. NASDAQ reads
BRK-B as a preferred, BRKpB, whatever exchange lists Berkshire.
Example
import deephaven_massive as dm
dm.canonical_symbol(
"BAC-PL", dm.AssetClass.STOCKS, convention=dm.SymbolConvention.YAHOO
) # 'BACpL'
TickerType ¶
The type code of a ticker, which m.reference.tickers filters by.
The values are Massive's codes, upper case as Massive spells them; m.reference.ticker_types()
lists them with their descriptions.
Example
import deephaven_massive as dm
assert dm.TickerType("ETF") is dm.TickerType.ETF
Timeframe ¶
The reporting period of the m.stocks.financials statements.
ANNUAL is a fiscal year and QUARTERLY a fiscal quarter. TRAILING_TWELVE_MONTHS sums the
four most recent quarters. The income and cash flow statements offer it, and a balance sheet,
which is a snapshot at the period's end, doesn't.
Example
import deephaven_massive as dm
assert dm.Timeframe("annual") is dm.Timeframe.ANNUAL
Timespan ¶
The unit of a bar or an indicator window.
For bars(), the timespan also decides whether the bars stream: one-second and one-minute bars
(SECOND and MINUTE with multiplier=1) stream, and every other bar is history only.
SESSION is a futures trading session, and Massive serves it only for futures bars. A
futures DAY bar also spans one session. The previous day's bar is a dataset of its own,
previous_day_bar().
Example
import deephaven_massive as dm
span = dm.Timespan("minute") # text converts to a member
assert span is dm.Timespan.MINUTE
ErrorPolicy
dataclass
¶
ErrorPolicy(every: OnError | None = None, /, *, noncanonical_symbols: OnError | None = None, unreadable_symbols: OnError | None = None, unavailable_symbols: OnError | None = None, refused_symbols: OnError | None = None, undocumented_errors: OnError | None = None, unrequested_symbols: OnError | None = None, unreadable_keys: OnError | None = None, unconvertible_values: OnError | None = None, malformed_rows: OnError | None = None, unlisted_contracts: OnError | None = None, unscheduled_products: OnError | None = None, refused_venues: OnError | None = None)
What each kind of problem does: fail the table, or skip it and keep going.
A problem is one bad symbol, row, file line, or refused futures exchange, such as a
watchlist row that isn't Massive's ticker. Each kind of problem is a cause. Each cause
takes one dm.OnError member:
dm.OnError.RAISEfails the call or the live table that met it.dm.OnError.LOGskips it, keeps going, and logs a warning.dm.OnError.IGNOREdoes the same, logging only atDEBUG.
m.problems() lists each problem a table met, with its cause and the setting
that applied. Under RAISE, the error that fails the call names the problem. Under LOG,
the first problem of each cause on each table logs one warning that points to
m.problems(); the later ones log at DEBUG only.
A row of Massive's data the library can't read whole is never published, whatever the
setting: its cause's setting decides only whether the table fails and how loudly the log
reports it. When the library can read none of the rows of your symbols inside your call's
window whole, across all the pages or files the call read, the call fails whatever the
setting, since the table would otherwise hold nothing and show no error. Rows outside the
window, and rows of a symbol the call didn't ask for, count neither way. In a fetch() or
history(), neither do the rows of a symbol that failed, nor REST rows of a day the flat
files serve. Under LOG
and IGNORE, one symbol's failure never takes another's rows: a call that names symbols
returns the rows of those that didn't fail, and m.problems() lists each that did. Under
RAISE, a symbol's problem of that cause fails the whole call or table. Whatever the
setting, a call fails when every symbol it names fails. A live stream judges runs of rows,
and
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/configuration.md#read-failures
lists how each read and stream judges.
Set a session's policy with dm.MassiveConfig(on_error=...). Set one call's policy with any
dataset method's on_error= argument. Each cause takes the first setting it finds: the
call's, then the session's, then ErrorPolicy.DEFAULTS. A call that leaves on_error out,
or passes None, sets no cause, so the session decides. By default every cause logs,
except refused_venues, which raises. A live call whose policy changes any cause's
setting gets its own stream in m.streams().
Example
import deephaven_massive as dm
# Fail on a bad watchlist row; every other cause keeps its default.
cfg = dm.MassiveConfig(on_error=dm.ErrorPolicy(noncanonical_symbols=dm.OnError.RAISE))
# Fail on everything but a symbol Massive has no data for.
strict = dm.ErrorPolicy(dm.OnError.RAISE, unavailable_symbols=dm.OnError.LOG)
m = dm.MassiveSession(cfg)
trades = m.stocks.trades(["AAPL", "MSFT"], on_error=strict) # this call only
day = trades.history("2026-10-30", "2026-10-30")
Attributes:
| Name | Type | Description |
|---|---|---|
noncanonical_symbols |
OnError | None
|
Decides what happens to a row of a watchlist or other table you
pass whose value isn't Massive's exact ticker or futures product code, such as
Set This setting covers only tables. A symbol you pass in code must be Massive's exact
ticker, or the call raises |
unreadable_symbols |
OnError | None
|
Decides whether a row of Massive's data whose symbol the library
can't read as Massive's ticker fails the table; the row is left out either way.
Defaults to Set A listed crypto pair is unreadable too when its ticker isn't its two currencies
written together. Under |
unavailable_symbols |
OnError | None
|
Decides what happens to a symbol Massive has no data for.
Defaults to Set
A symbol Massive answers with no rows and no error has no rows, whatever this setting says. |
refused_symbols |
OnError | None
|
Decides what happens to a symbol Massive refuses, usually because
your plan doesn't serve it. Defaults to Set |
undocumented_errors |
OnError | None
|
Decides what happens to a symbol Massive answers with an Set Such an answer may not last, so a A snapshot answers a ticker it can't serve with an
Every other code follows this setting. |
unrequested_symbols |
OnError | None
|
Decides whether a row Massive returns for a symbol the call
didn't ask for fails the table; the row is left out either way. Defaults to
Set
|
unreadable_keys |
OnError | None
|
Decides whether a row of Massive's data whose key the library can't
read fails the table; the row is left out either way. Defaults to A key can't be read when it is one of these:
A symbol that is present but isn't Massive's ticker is |
unconvertible_values |
OnError | None
|
Decides whether a row of Massive's data holding a value the
library can't read as its column's type fails the table; the row is left out
either way. Defaults to A value the library can't read is one of these:
In those other columns a time of 0 is a null, as Massive means it, and the row is kept. Set |
malformed_rows |
OnError | None
|
Decides what happens to a line of a Massive flat file that isn't a
readable row: it doesn't split into the header's fields, or it isn't UTF-8 text.
Defaults to Set
Only a |
unlisted_contracts |
OnError | None
|
Decides what happens to the rows of a futures ticker Massive
streams that neither its futures snapshot nor its contracts list has held for 30
minutes. Defaults to A futures stream dates each row from its product's trading schedule, which it finds through those lists, and holds the rows until then. Massive's lists sometimes lag its stream, so a ticker missing from both waits and is asked about again, at 2, 8, and 30 seconds and then every minute. After 30 minutes its rows are left out, then and later, until a list holds it.
|
unscheduled_products |
OnError | None
|
Decides what happens to the rows of a futures product that
Massive's schedules give no session for: none at all, or none that holds the row's
time. Defaults to A futures stream dates each row from its product's trading schedule. A row no session holds waits while the library loads the schedule again. If Massive's answer still has no session for it, the library can't date the row, so it leaves the row out. A product with no session at all is asked about again each day, and once Massive publishes its sessions, its rows are dated and published again.
|
refused_venues |
OnError | None
|
Decides what a futures It applies only to exchanges a call names. A call that leaves
It applies only when REST can't serve the call: |
Set each cause you name, and every other one to every.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
every
|
OnError | None
|
The setting for every cause you don't name. Pass it by position. Defaults to None, which leaves those causes unset. |
None
|
noncanonical_symbols
|
OnError | None
|
A watchlist row that isn't Massive's exact ticker. |
None
|
unreadable_symbols
|
OnError | None
|
A symbol in Massive's data that the library can't read. |
None
|
unavailable_symbols
|
OnError | None
|
A symbol Massive has no data for. |
None
|
refused_symbols
|
OnError | None
|
A symbol Massive refuses. |
None
|
undocumented_errors
|
OnError | None
|
A symbol Massive answers with an error code its documentation doesn't list. |
None
|
unrequested_symbols
|
OnError | None
|
A row Massive returns for a symbol the call didn't ask for. |
None
|
unreadable_keys
|
OnError | None
|
A row of Massive's data whose key the library can't read. |
None
|
unconvertible_values
|
OnError | None
|
A row of Massive's data with a value the library can't read. |
None
|
malformed_rows
|
OnError | None
|
A flat-file line that isn't a readable row. |
None
|
unlisted_contracts
|
OnError | None
|
A futures ticker Massive streams that its lists don't hold. |
None
|
unscheduled_products
|
OnError | None
|
A futures row Massive's schedules give no session for. |
None
|
refused_venues
|
OnError | None
|
A futures exchange the call names whose flat files Massive refuses. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If an argument is neither None nor a |
AuthenticationError ¶
AuthenticationError(*args: object, status: int | None = None, request_id: str | None = None, source: ErrorSource | None = None, is_retryable: bool | None = None, is_bug: bool | None = None)
Your API key is missing, or Massive refused your API key or your flat-file S3 keys.
dm.MassiveConfig() raises it when MASSIVE_API_KEY isn't set and you pass no api_key. A
fetch() or history() with wait=True raises it when Massive rejects the API key (HTTP
401); without wait=True, the table fails with it instead. A live table fails with it when
Massive's streaming server rejects the key, and so does every other stream on that
connection. Massive may give the same answer to a plan without streams of the asset class,
so the message says that too.
If S3 rejects your flat-file keys, history() reads REST instead and logs a warning. It
raises this error only under source=dm.HistorySource.FLAT_FILES, or when REST can't serve
the read. The message names s3_access_key_id and s3_secret_access_key.
Its source is ErrorSource.USER when the key is missing, and ErrorSource.MASSIVE when
Massive refused it.
Example
import deephaven_massive as dm
try:
config = dm.MassiveConfig()
except dm.AuthenticationError:
config = dm.MassiveConfig(api_key="...")
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
The exception's arguments, as for |
()
|
status
|
int | None
|
The HTTP status of the response the error came from, or |
None
|
request_id
|
str | None
|
The |
None
|
source
|
ErrorSource | None
|
What stopped the call, or |
None
|
is_retryable
|
bool | None
|
Whether the same call may succeed later, or |
None
|
is_bug
|
bool | None
|
Whether a defect caused the error, or |
None
|
Attributes¶
default_source
class-attribute
¶
default_source: ErrorSource = ErrorSource.MASSIVE
The source of an error of this class created without one; a subclass whose every
instance has another source sets its own.
default_is_retryable
class-attribute
¶
default_is_retryable: bool = False
Whether every error of this class created without is_retryable may succeed later, an
answer that means "try again" whatever its status; a subclass of such answers sets it.
default_is_bug
class-attribute
¶
default_is_bug: bool = False
Whether an error of this class created without is_bug is a bug; a subclass whose every
instance is a user's bug sets it. A LIBRARY error is a bug whatever this says.
status
property
¶
status: int | None
The HTTP status of the response behind the error, or None when there was none.
Usually Massive's, such as 404 or 429. A flat file's comes from S3, and a proxy that refused its credentials gives its own 407.
request_id
property
¶
request_id: str | None
The request_id of Massive's response, for a support request to Massive, or None.
source
property
¶
source: ErrorSource
What stopped the call: Massive, the network, your code or settings, or a bug.
is_retryable
property
¶
is_retryable: bool
Whether the same call may succeed if you make it again later.
True for:
- a rate limit (HTTP 429);
- a failure on Massive's side (HTTP 500, 502, 503, or 504);
- no answer (
ErrorSource.NETWORK); - HTTP 404 on a later page of one symbol's REST read;
- S3's
RequestTimeouton a flat file; - a flat file Massive hasn't published yet;
- a page Massive answered with another
adjustedthan the call asked for; - a
poll()cycle in which the library couldn't read any row Massive sent for a symbol, or fordm.ALL, since the next cycle may read them whole.
A fetch() or history() of a watchlist whose every symbol failed is retryable only
when every symbol's error is. False for any other HTTP status, an AuthenticationError,
an EntitlementError, a SessionClosedError, or a bug.
Before it raises, the library has retried a server failure or a failed connection a few times. A read that Massive keeps refusing fails with a rate-limit error once waiting out the refusals would take longer than:
- for a call you wait for (
wait=True, or opening a stream withappend_only()orlast_by()): 10 minutes, or 90 seconds inside a console command; - for a read that feeds a live table (a
fetch()orhistory()withoutwait=True, a watchlist's reads after the call returns, apoll()cycle, or a stream's lookups):max_outageinMassiveConfig.
Wait before you call again.
is_bug
property
¶
is_bug: bool
Whether a defect caused the error: a bug in the library, or one in your code.
True for every ErrorSource.LIBRARY error; its message says how to report it. True too
for a bug in your code that the library caught, such as a watchlist table that failed
or an argument that one of the watchlist's symbols doesn't take; its message names the
fix. The library logs a bug at ERROR, and any other error below ERROR.
EntitlementError ¶
EntitlementError(*args: object, status: int | None = None, request_id: str | None = None, source: ErrorSource | None = None, is_retryable: bool | None = None, is_bug: bool | None = None)
Your key is valid, but your plan doesn't include what you asked for.
Massive refused a REST request with HTTP 403, a flat file, or a stream subscription. A
refused subscription fails only the table that asked, and other tables on the same
connection keep running. The library raises it too when Massive marks the data delayed
and the data's subscription isn't in MassiveConfig.delayed_subscriptions. The message
then names the setting to change. Its source is ErrorSource.MASSIVE when Massive
refused, and ErrorSource.USER when delayed_subscriptions refused delayed data.
When Massive refused, the message quotes its answer. A refused flat-file history() also
names source=dm.HistorySource.REST when REST can serve the read.
Example
Read a day of trades, and report it when your plan lacks them:
import deephaven_massive as dm
m = dm.MassiveSession()
try:
day = m.stocks.trades("AAPL").history("2025-06-06", "2025-06-06", wait=True)
except dm.EntitlementError as e:
print(f"not on this plan: {e}")
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
The exception's arguments, as for |
()
|
status
|
int | None
|
The HTTP status of the response the error came from, or |
None
|
request_id
|
str | None
|
The |
None
|
source
|
ErrorSource | None
|
What stopped the call, or |
None
|
is_retryable
|
bool | None
|
Whether the same call may succeed later, or |
None
|
is_bug
|
bool | None
|
Whether a defect caused the error, or |
None
|
Attributes¶
default_source
class-attribute
¶
default_source: ErrorSource = ErrorSource.MASSIVE
The source of an error of this class created without one; a subclass whose every
instance has another source sets its own.
default_is_retryable
class-attribute
¶
default_is_retryable: bool = False
Whether every error of this class created without is_retryable may succeed later, an
answer that means "try again" whatever its status; a subclass of such answers sets it.
default_is_bug
class-attribute
¶
default_is_bug: bool = False
Whether an error of this class created without is_bug is a bug; a subclass whose every
instance is a user's bug sets it. A LIBRARY error is a bug whatever this says.
status
property
¶
status: int | None
The HTTP status of the response behind the error, or None when there was none.
Usually Massive's, such as 404 or 429. A flat file's comes from S3, and a proxy that refused its credentials gives its own 407.
request_id
property
¶
request_id: str | None
The request_id of Massive's response, for a support request to Massive, or None.
source
property
¶
source: ErrorSource
What stopped the call: Massive, the network, your code or settings, or a bug.
is_retryable
property
¶
is_retryable: bool
Whether the same call may succeed if you make it again later.
True for:
- a rate limit (HTTP 429);
- a failure on Massive's side (HTTP 500, 502, 503, or 504);
- no answer (
ErrorSource.NETWORK); - HTTP 404 on a later page of one symbol's REST read;
- S3's
RequestTimeouton a flat file; - a flat file Massive hasn't published yet;
- a page Massive answered with another
adjustedthan the call asked for; - a
poll()cycle in which the library couldn't read any row Massive sent for a symbol, or fordm.ALL, since the next cycle may read them whole.
A fetch() or history() of a watchlist whose every symbol failed is retryable only
when every symbol's error is. False for any other HTTP status, an AuthenticationError,
an EntitlementError, a SessionClosedError, or a bug.
Before it raises, the library has retried a server failure or a failed connection a few times. A read that Massive keeps refusing fails with a rate-limit error once waiting out the refusals would take longer than:
- for a call you wait for (
wait=True, or opening a stream withappend_only()orlast_by()): 10 minutes, or 90 seconds inside a console command; - for a read that feeds a live table (a
fetch()orhistory()withoutwait=True, a watchlist's reads after the call returns, apoll()cycle, or a stream's lookups):max_outageinMassiveConfig.
Wait before you call again.
is_bug
property
¶
is_bug: bool
Whether a defect caused the error: a bug in the library, or one in your code.
True for every ErrorSource.LIBRARY error; its message says how to report it. True too
for a bug in your code that the library caught, such as a watchlist table that failed
or an argument that one of the watchlist's symbols doesn't take; its message names the
fix. The library logs a bug at ERROR, and any other error below ERROR.
ErrorSource ¶
What stopped a call that raised a MassiveError: Massive, the network, you, or a bug.
Read it from an error's source to decide what to do. Massive's refusals and errors
are MASSIVE, an answer that never came is NETWORK, a problem in your code or settings is
USER, and a bug in the library is LIBRARY. Later versions may add members, so end a
match on it with case _:. The values are the library's own names, not values Massive
sends.
Example
Tell a library bug from a problem in your code or settings:
import deephaven_massive as dm
m = dm.MassiveSession()
try:
dividends = m.stocks.dividends(["AAPL", "MSFT"]).fetch(wait=True)
except dm.MassiveError as e:
if e.source is dm.ErrorSource.LIBRARY:
print(f"please report: {e}")
elif e.source is dm.ErrorSource.USER:
print(f"fix this: {e}")
else:
print(f"failed: {e}")
Attributes¶
MASSIVE
class-attribute
instance-attribute
¶
MASSIVE = 'massive'
Massive refused or failed the request: an HTTP error such as 403 or 503, a rejected key, a plan without the data, a WebSocket status message, Massive's reference data lacking what you asked for, or a row Massive sent that the library can't read. When Massive answered, the message quotes it.
NETWORK
class-attribute
instance-attribute
¶
NETWORK = 'network'
No answer came: a connection failed through every retry the library made, or a live
table got nothing for longer than MassiveConfig.max_outage.
USER
class-attribute
instance-attribute
¶
USER = 'user'
Your code or settings stopped the call, such as a missing API key, delayed data your
MassiveConfig doesn't allow, a certificate or proxy setting that fails, a closed session,
or a watchlist table of yours that failed. The message names the fix.
LIBRARY
class-attribute
instance-attribute
¶
LIBRARY = 'library'
A bug in the library, or data from Massive it can't read. The message says how to report it.
MassiveError ¶
MassiveError(*args: object, status: int | None = None, request_id: str | None = None, source: ErrorSource | None = None, is_retryable: bool | None = None, is_bug: bool | None = None)
The base class of every error Massive or the library reports.
One except dm.MassiveError catches them all. Its subclasses AuthenticationError,
EntitlementError, and SessionClosedError name three failures you can act on. Every
other failure raises MassiveError itself, such as a network error, an HTTP error other
than 401 or 403, a rate limit longer than the read waits out, or a bug. The message names
what failed, and quotes Massive's text when Massive answered. To branch on the failure,
read is_retryable, is_bug, source, or status instead of the message.
A fetch() or history() with wait=True raises the error. Without wait=True, a
failure after the call returns fails their table instead, as it fails a live table: the
table shows the error, the log records it, and m.streams() lists it. A closed session or
a wrong argument still raises at the call.
Example
Catch any MassiveError, and branch on the HTTP status:
import deephaven_massive as dm
m = dm.MassiveSession()
try:
dividends = m.stocks.dividends(["AAPL", "MSFT"]).fetch(wait=True)
except dm.MassiveError as e:
if e.status == 429:
print(f"slow down (request {e.request_id}): {e}")
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
The exception's arguments, as for |
()
|
status
|
int | None
|
The HTTP status of the response the error came from, or |
None
|
request_id
|
str | None
|
The |
None
|
source
|
ErrorSource | None
|
What stopped the call, or |
None
|
is_retryable
|
bool | None
|
Whether the same call may succeed later, or |
None
|
is_bug
|
bool | None
|
Whether a defect caused the error, or |
None
|
Attributes¶
default_source
class-attribute
¶
default_source: ErrorSource = ErrorSource.MASSIVE
The source of an error of this class created without one; a subclass whose every
instance has another source sets its own.
default_is_retryable
class-attribute
¶
default_is_retryable: bool = False
Whether every error of this class created without is_retryable may succeed later, an
answer that means "try again" whatever its status; a subclass of such answers sets it.
default_is_bug
class-attribute
¶
default_is_bug: bool = False
Whether an error of this class created without is_bug is a bug; a subclass whose every
instance is a user's bug sets it. A LIBRARY error is a bug whatever this says.
status
property
¶
status: int | None
The HTTP status of the response behind the error, or None when there was none.
Usually Massive's, such as 404 or 429. A flat file's comes from S3, and a proxy that refused its credentials gives its own 407.
request_id
property
¶
request_id: str | None
The request_id of Massive's response, for a support request to Massive, or None.
source
property
¶
source: ErrorSource
What stopped the call: Massive, the network, your code or settings, or a bug.
is_retryable
property
¶
is_retryable: bool
Whether the same call may succeed if you make it again later.
True for:
- a rate limit (HTTP 429);
- a failure on Massive's side (HTTP 500, 502, 503, or 504);
- no answer (
ErrorSource.NETWORK); - HTTP 404 on a later page of one symbol's REST read;
- S3's
RequestTimeouton a flat file; - a flat file Massive hasn't published yet;
- a page Massive answered with another
adjustedthan the call asked for; - a
poll()cycle in which the library couldn't read any row Massive sent for a symbol, or fordm.ALL, since the next cycle may read them whole.
A fetch() or history() of a watchlist whose every symbol failed is retryable only
when every symbol's error is. False for any other HTTP status, an AuthenticationError,
an EntitlementError, a SessionClosedError, or a bug.
Before it raises, the library has retried a server failure or a failed connection a few times. A read that Massive keeps refusing fails with a rate-limit error once waiting out the refusals would take longer than:
- for a call you wait for (
wait=True, or opening a stream withappend_only()orlast_by()): 10 minutes, or 90 seconds inside a console command; - for a read that feeds a live table (a
fetch()orhistory()withoutwait=True, a watchlist's reads after the call returns, apoll()cycle, or a stream's lookups):max_outageinMassiveConfig.
Wait before you call again.
is_bug
property
¶
is_bug: bool
Whether a defect caused the error: a bug in the library, or one in your code.
True for every ErrorSource.LIBRARY error; its message says how to report it. True too
for a bug in your code that the library caught, such as a watchlist table that failed
or an argument that one of the watchlist's symbols doesn't take; its message names the
fix. The library logs a bug at ERROR, and any other error below ERROR.
SessionClosedError ¶
SessionClosedError(*args: object, status: int | None = None, request_id: str | None = None, source: ErrorSource | None = None, is_retryable: bool | None = None, is_bug: bool | None = None)
The session is closed, so it reads nothing more.
After m.close(), a query method such as fetch() raises it, and so do m.streams()
and a call that the close cut short. A live table that was running when the session
closed fails with it. The message says so and names the fix: "This session is closed.
Open a new dm.MassiveSession() to read again.". Its source is ErrorSource.USER, and
is_retryable is False.
Example
import deephaven_massive as dm
m = dm.MassiveSession()
m.close()
try:
m.stocks.dividends("AAPL").fetch()
except dm.SessionClosedError:
m = dm.MassiveSession()
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
The exception's arguments, as for |
()
|
status
|
int | None
|
The HTTP status of the response the error came from, or |
None
|
request_id
|
str | None
|
The |
None
|
source
|
ErrorSource | None
|
What stopped the call, or |
None
|
is_retryable
|
bool | None
|
Whether the same call may succeed later, or |
None
|
is_bug
|
bool | None
|
Whether a defect caused the error, or |
None
|
Attributes¶
default_is_retryable
class-attribute
¶
default_is_retryable: bool = False
Whether every error of this class created without is_retryable may succeed later, an
answer that means "try again" whatever its status; a subclass of such answers sets it.
default_is_bug
class-attribute
¶
default_is_bug: bool = False
Whether an error of this class created without is_bug is a bug; a subclass whose every
instance is a user's bug sets it. A LIBRARY error is a bug whatever this says.
status
property
¶
status: int | None
The HTTP status of the response behind the error, or None when there was none.
Usually Massive's, such as 404 or 429. A flat file's comes from S3, and a proxy that refused its credentials gives its own 407.
request_id
property
¶
request_id: str | None
The request_id of Massive's response, for a support request to Massive, or None.
source
property
¶
source: ErrorSource
What stopped the call: Massive, the network, your code or settings, or a bug.
is_retryable
property
¶
is_retryable: bool
Whether the same call may succeed if you make it again later.
True for:
- a rate limit (HTTP 429);
- a failure on Massive's side (HTTP 500, 502, 503, or 504);
- no answer (
ErrorSource.NETWORK); - HTTP 404 on a later page of one symbol's REST read;
- S3's
RequestTimeouton a flat file; - a flat file Massive hasn't published yet;
- a page Massive answered with another
adjustedthan the call asked for; - a
poll()cycle in which the library couldn't read any row Massive sent for a symbol, or fordm.ALL, since the next cycle may read them whole.
A fetch() or history() of a watchlist whose every symbol failed is retryable only
when every symbol's error is. False for any other HTTP status, an AuthenticationError,
an EntitlementError, a SessionClosedError, or a bug.
Before it raises, the library has retried a server failure or a failed connection a few times. A read that Massive keeps refusing fails with a rate-limit error once waiting out the refusals would take longer than:
- for a call you wait for (
wait=True, or opening a stream withappend_only()orlast_by()): 10 minutes, or 90 seconds inside a console command; - for a read that feeds a live table (a
fetch()orhistory()withoutwait=True, a watchlist's reads after the call returns, apoll()cycle, or a stream's lookups):max_outageinMassiveConfig.
Wait before you call again.
is_bug
property
¶
is_bug: bool
Whether a defect caused the error: a bug in the library, or one in your code.
True for every ErrorSource.LIBRARY error; its message says how to report it. True too
for a bug in your code that the library caught, such as a watchlist table that failed
or an argument that one of the watchlist's symbols doesn't take; its message names the
fix. The library logs a bug at ERROR, and any other error below ERROR.
MassiveSession ¶
MassiveSession(config: MassiveConfig | None = None)
Your connection to Massive: its datasets and the live tables you make from them.
Create a session inside a Deephaven server, in its console or an application script. Its
settings come from dm.MassiveConfig. Without one, it reads your API key from
MASSIVE_API_KEY.
Each dataset is a method of a namespace, such as m.stocks.bars, and returns a query. A method
of the query, such as history() or last_by(), returns a table. A live table updates while
anything uses it. m.release(table) drops your variable's hold on one, and m.close() stops
them all. In a with block, the session closes when the block ends. See
https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#stop-live-tables.
No public attribute or repr of the session shows your key, so the key stays out of the
console's variables.
You can use a session from several threads at once.
Messages name the session by its label, such as MassiveSession #1.
You can open several sessions with the same API key, and they share Massive's limits for
that key. They share one request rate, and Massive allows your account one streaming
connection per asset class. Sessions share that connection when their streaming settings
match, such as websocket_hosts and max_outage. Otherwise each opens its own, and the newer
connection takes the older one's place. The live tables on the older one then fail, or
reconnect if their session's MassiveConfig.connection_taken is RECONNECT. A WARNING names
the clash when you create the second session. A session that no variable holds and that runs
no live table closes by itself, with no warning.
Example
import deephaven_massive as dm
m = dm.MassiveSession()
apple = m.stocks.bars("AAPL", dm.Timespan.DAY).history("2026-10-26", "2026-10-30")
streams = m.streams() # each live table's state and errors
m.close()
Create a session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MassiveConfig | None
|
The session's settings. Leave it out for |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
AuthenticationError
|
If |
ValueError
|
If:
- it runs on a Deephaven update-graph thread, such as inside a table listener;
- for the first session of the process, |
OSError
|
For the first session of the process, if |
MassiveError
|
If it runs on a thread with no Deephaven execution context, or in one made
by |
Attributes¶
stocks
property
¶
stocks: StocksNamespace
US equities: trades, quotes, bars, snapshots, fundamentals, and filings.
options
property
¶
options: OptionsNamespace
US options: trades, quotes, bars, chains, snapshots, and contracts.
futures
property
¶
futures: FuturesNamespace
US futures: trades, quotes, bars, snapshots, contracts, products, and schedules.
forex
property
¶
forex: ForexNamespace
Forex: quotes, bars, snapshots, movers, and currency conversion.
crypto
property
¶
crypto: CryptoNamespace
Crypto: trades, quotes, bars, fair market value, snapshots, and movers.
reference
property
¶
reference: ReferenceNamespace
Reference data: tickers, news, exchanges, conditions, market status, and holidays.
indicators
property
¶
indicators: IndicatorsNamespace
Technical indicators: SMA, EMA, RSI, and MACD.
economy
property
¶
economy: EconomyNamespace
US economic data: treasury yields, inflation, labor market, and funding conditions.
partners
property
¶
partners: PartnersNamespace
Datasets from Massive's partners: benzinga, etf_global, tmx, and fable.
Methods:¶
snapshots ¶
snapshots(symbols: SymbolsLike, *, sort: str | None = None, order: Order | None = None, limit: int | None = None, filters: Mapping[str, FilterValue] | None = None, on_error: ErrorPolicy | None = None) -> FetchQuery
The current state of tickers of any asset class, from Massive's unified snapshot.
Each row holds one ticker's latest trade, quote, and minute bar, and its session's open,
high, low, close, and change. An option's row adds its greeks, implied volatility, and open
interest. A column of another asset class is null. A ticker Massive doesn't know gets no
row, and m.problems() lists it as unavailable_symbols. One your plan doesn't cover
gets no row either, and m.problems() lists it as refused_symbols with Massive's
answer. One Massive answers with an error its documentation doesn't list gets no row
either, listed as undocumented_errors with Massive's answer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
SymbolsLike
|
Tickers of any asset class, such as |
required |
sort
|
str | None
|
The field to sort by, such as |
None
|
order
|
Order | None
|
The direction of |
None
|
limit
|
int | None
|
The most rows to return, in total. A watchlist's |
None
|
filters
|
Mapping[str, FilterValue] | None
|
Further endpoint parameters, except |
None
|
on_error
|
ErrorPolicy | None
|
What a bad symbol or row does in this call ( |
None
|
Returns:
| Type | Description |
|---|---|
FetchQuery
|
A query. Its columns, plans, and methods: https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/datasets/snapshots.md. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an argument has the wrong type. |
ValueError
|
If:
- |
Example
mixed = m.snapshots(["AAPL", "C:EURUSD", "X:BTCUSD", "I:SPX"]).fetch()
connections ¶
connections() -> Table
Return a live table of the session's streaming connections to Massive.
Look here when a stream gets no data. Each row says whether a connection is up, whether its
data is real-time or delayed, and its last error. A connection that another session with the
same key shares shows in both sessions' tables. The table also has a REST row for each
asset class and kind of data whose feed the session has found. Each call returns a new
table, which keeps its final rows after close(). What to do about each state:
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#diagnostics.
Returns:
| Type | Description |
|---|---|
Table
|
A live table keyed by
A connection's problems, such as an outage, are rows of |
Raises:
| Type | Description |
|---|---|
SessionClosedError
|
If the session is closed. |
MassiveError
|
If the session's diagnostics tables failed when their writer thread died. |
streams ¶
streams() -> Table
Return a live table of the session's streams, polls, and background reads.
Start here when a live table looks wrong. Each row is one stream, poll() table, or
background read. The tables of identical queries share one stream and one row. Each call
returns a new table, which keeps its final rows after close().
What to do about each state:
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#diagnostics.
Returns:
| Type | Description |
|---|---|
Table
|
A live table keyed by
The problems of a table that keeps running, such as rows the library withheld or
an outage, are rows of |
Raises:
| Type | Description |
|---|---|
SessionClosedError
|
If the session is closed. |
MassiveError
|
If the session's diagnostics tables failed when their writer thread died. |
rate_limits ¶
rate_limits() -> Table
Return a live table of Massive's REST request limits, one row per subscription.
Massive may limit each subscription's REST requests per minute, at a number your plan
sets.
The limit counts every request your account makes, from every key and session. Each row
is one subscription, or other for the datasets Massive assigns to none. Sessions in this
server that use the same key share these rows. Each call returns a new table, which keeps
its final rows after close(). What to do about each state:
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#diagnostics.
Returns:
| Type | Description |
|---|---|
Table
|
A live table keyed by
|
Raises:
| Type | Description |
|---|---|
SessionClosedError
|
If the session is closed. |
MassiveError
|
If the session's diagnostics tables failed when their writer thread died. |
symbol_reads ¶
symbol_reads() -> Table
Return a live table of each symbol of each history() or fetch() of a watchlist.
A history() or fetch() of a watchlist reads each symbol you add and drops each one you
delete. This table shows each symbol's read, so you can find the ones that failed and why.
A read that fails with a temporary error, such as a rate limit or a network error, is
RETRYING. It's tried again 2, 8, and 30 seconds later, then every minute. It's FAILED
once it has failed for MassiveConfig.max_outage seconds. Any other failure is FAILED
at once. To read a failed symbol again, delete its row from the
watchlist and add it back.
The rows stay for the session's life. Each call returns a new table, which keeps its final
rows after close(). What to do about each state:
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#diagnostics.
Returns:
| Type | Description |
|---|---|
Table
|
A live table keyed by
|
Raises:
| Type | Description |
|---|---|
SessionClosedError
|
If the session is closed. |
MassiveError
|
If the session's diagnostics tables failed when their writer thread died. |
Example
failed = m.symbol_reads().where("State = `FAILED`")
problems ¶
problems() -> Table
Return a live table of every problem with the session's data feed.
Start here when a table looks wrong. Each row is one problem of one table: rows the
library left out because it couldn't read them whole, a watchlist value that isn't
Massive's ticker, a symbol Massive has no data for, a connection outage, a rate-limit
pause, a failed table. Rows of a problem that happens again add up in place. A problem
that lasts, such as an outage or a skipped watchlist value, is a span: its row gets an
EndedAt when it clears, such as when you fix or delete the watchlist row. Valid data
is never a problem: a null Massive sent, or a symbol with no rows in the range, has no
row here. The rows stay for the session's life. Each call returns a new table, which
keeps its final rows after close(). Every cause, and what to do about it:
https://github.com/deephaven-examples/deephaven-massive/blob/main/docs/troubleshooting.md#problem-causes.
Returns:
| Type | Description |
|---|---|
Table
|
A live table keyed by
|
Raises:
| Type | Description |
|---|---|
SessionClosedError
|
If the session is closed. |
MassiveError
|
If the session's diagnostics tables failed when their writer thread died. |
Example
problems = m.problems()
lasting = problems.where("!isNull(SpanStart) && isNull(EndedAt)")
per_table = m.streams().natural_join(
problems.count_by("Problems", "StreamId"), "StreamId"
)
release ¶
release(table: Table) -> None
Release one live table now, instead of waiting for Python to reclaim it.
The table stops updating once nothing else uses it, such as a table made from it or a panel
open in the Deephaven IDE. Its poll or background read then stops. Its stream unsubscribes
once no other table of the stream is in use. In a console command, the release takes effect
when the command ends. Releasing a table twice does nothing, and release() works after
close(). A static table needs no release. See
https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#stop-live-tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
A live table that a query method of this session returned. For a table made from one, release the table it came from. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
close ¶
close() -> None
Stop every live table of the session. Calling it again does nothing.
Each live table, and each table made from one, fails with MassiveError("This session
was closed, so this table no longer updates. Open a new dm.MassiveSession() to read
again."). It keeps its rows, and t.snapshot() gives a static copy to keep working
with. In a console command, close() returns at once. The tables show their final
state when the command ends.
Connections that no other session uses are closed. Afterward, the query methods and the
diagnostics methods, such as m.streams(), raise MassiveError. Building queries and
release() still work. See
https://github.com/deephaven-examples/deephaven-massive/blob/main/README.md#stop-live-tables.
Raises:
| Type | Description |
|---|---|
ValueError
|
If called on a Deephaven update-graph thread, such as inside a table listener. |
Example
trades = m.stocks.trades("AAPL").append_only()
m.close()
kept = trades.snapshot() # a static copy of the rows received before the close
Functions:¶
datasets ¶
datasets() -> Table
List every dataset the library serves, one row each, as a static table.
Use it to find a dataset without reading the namespaces one by one: filter it in the
console, or open a row's Documentation link for its columns and plans. It reads only the
dataset catalog, which exists once the library is imported, so it needs no session and no
API key and makes no network call.
Returns:
| Type | Description |
|---|---|
Table
|
A static table, in the order the namespaces declare their datasets, with the columns
|
Example
import deephaven_massive as dm
catalog = dm.datasets()
streams = catalog.where("Arrays.asList(Methods).contains(`blink`)")
news = catalog.where("Summary.toLowerCase().contains(`news`)")
canonical_symbol ¶
canonical_symbol(text: str | None, asset_class: AssetClass, *, convention: SymbolConvention = SymbolConvention.MASSIVE, on_error: OnError = OnError.RAISE) -> str | None
Convert a symbol of a named asset class to Massive's exact REST ticker.
Use it to turn symbols from another source into the form every dataset takes and every
Symbol column holds, before passing them as symbols=. Under SymbolConvention.MASSIVE,
the default, canonical text comes back unchanged; another spelling of the class converts
(EUR/USD to C:EURUSD, SPX to I:SPX); anything else raises. Under another convention,
only that convention's grammar applies, so text it does not spell raises even when it
happens to be a Massive ticker. For futures, a single contract (ESZ5) or a spread in one
of Massive's spellings (GCQ6-GCZ6) comes back unchanged and anything else raises, with
the message of canonical_symbol_future; a futures dataset's symbols take the same two
forms. The class is never guessed: SPX is an index only because
the caller says so. Text that does not convert does what on_error says: raises, the
default, or comes back as None with one log record per distinct value, so a column of
mixed spellings in Python can be converted without failing on the first bad one. The same
verdict and on_error apply to every row of dm.canonicalize_symbols. A Deephaven query
string passes positional arguments only: call a convention's function
(canonical_symbol_stock_yahoo), or give on_error= through a functools.partial of the
function, imported under a bare name. A function called through the module
(dm.canonical_symbol(...)) makes an Object column unless cast with (String).
Thread-safe.
Example
import deephaven_massive as dm
dm.canonical_symbol("EUR/USD", dm.AssetClass.FOREX) # 'C:EURUSD'
dm.canonical_symbol(
"BRK-B", dm.AssetClass.STOCKS, convention=dm.SymbolConvention.YAHOO
) # 'BRK.B'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The symbol, or None. |
required |
asset_class
|
AssetClass
|
The symbol's class, whose rules apply. Required: nothing is inferred. |
required |
convention
|
SymbolConvention
|
The convention the text comes from. |
MASSIVE
|
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
The canonical ticker; None for None, or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
canonical_symbol_crypto ¶
canonical_symbol_crypto(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert a crypto pair to Massive's ticker: BTC-USD to X:BTCUSD.
Accepts BTC-USD, BTC/USD, and BTCUSD, with or without X:, in any case, whatever the
quote currency, and joins the two codes; any such ticker is canonical. A stream, the
last-trade path, and the daily open/close path need the pair split into its two codes, and
take the split only from Massive's crypto ticker list, so they refuse a pair that list does
not hold; every other verb takes any pair. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_crypto) for a String column; called through the module it makes an Object
column unless cast: (String) dm.canonical_symbol_crypto(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The pair, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_forex ¶
canonical_symbol_forex(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert a currency pair to Massive's forex ticker: EUR/USD to C:EURUSD.
Accepts EUR/USD, EUR-USD, and EURUSD, with or without C:, in any case. Thread-safe.
Example
from deephaven import new_table
from deephaven.column import string_col
from deephaven_massive import canonical_symbol_forex
pairs = new_table([string_col("Pair", ["EUR/USD", "GBP-USD"])])
pairs = pairs.update(["Symbol = canonical_symbol_forex(Pair)"])
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_forex) for a String column; called through the module it makes an Object
column unless cast: (String) dm.canonical_symbol_forex(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The pair, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_future ¶
canonical_symbol_future(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Check a single futures contract ticker, which Massive's text is exactly: ESZ5.
A contract ticker is a root of upper-case letters and digits, a month code, and one to
three digits, taken as written: nothing is converted or re-cased. Most contracts end in a
one- or two-digit year (ESZ5, NGZ26), and daily contracts in three digits (0AF704,
GCBX602). A spread is refused with the function that takes it
(canonical_symbol_future_spread). Beware the year: Massive writes it with one digit for
most products (ESZ5 is December 2025) and with two for some (NGZ26, 0NGH39), so
ESZ25 is not ESZ5. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_future) for a String column; called through the module it makes an
Object column unless cast: (String) dm.canonical_symbol_future(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The contract ticker, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
The ticker unchanged, or None for None or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_future_spread ¶
canonical_symbol_future_spread(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Check a futures combo ticker, exactly as Massive writes it: GCQ6-GCZ6, BOB 02-01 U6.
Any combo (spread, strip, pack, or bundle) Massive writes is accepted: runs of upper-case
letters and digits joined by single -, :, or spaces (GCQ6-GCZ6, BOB 02-01 U6,
CL:BF Q6-U6-V6, 6A:XF:AUDUSD:Q6). Massive documents no grammar for combos, so the shape
is checked rather than a list of forms. Canonical text comes back unchanged; no ticker is
built from its legs. A single contract is refused with canonical_symbol_future. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_future_spread) for a String column; called through the module it makes
an Object column unless cast: (String) dm.canonical_symbol_future_spread(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The spread ticker, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
The ticker unchanged, or None for None or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_index ¶
canonical_symbol_index(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert an index ticker to Massive's: SPX to I:SPX.
The prefix is added because the caller names the class by calling this function; no ticker is ever recognized as an index by its name. Case is kept. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_index) for a String column; called through the module it makes an Object
column unless cast: (String) dm.canonical_symbol_index(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The index ticker, with or without |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_option ¶
canonical_symbol_option(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert an OCC option symbol to Massive's: AAPL250117C00150000 to O:AAPL250117C00150000.
Accepts the symbol with or without O: and the 21-character OSI form whose root is padded
with spaces, in any case. The root is never changed: SPXW stays SPXW and an adjusted
root such as AAPL1 stays AAPL1. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_option) for a String column; called through the module it makes an Object
column unless cast: (String) dm.canonical_symbol_option(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The option symbol, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_stock ¶
canonical_symbol_stock(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Check a stock ticker in Massive's own spelling, for Python code and query strings.
Massive's spelling is the only one accepted: a ticker from Yahoo, Nasdaq, or a CMS feed
goes through the function of its convention (canonical_symbol_stock_yahoo), because the
same - means a class in one and a preferred in another. Thread-safe.
Example
from deephaven import new_table
from deephaven.column import string_col
from deephaven_massive import canonical_symbol_stock
t = new_table([string_col("Ticker", ["AAPL", "KIMpL"])])
t = t.update(["Symbol = canonical_symbol_stock(Ticker)"])
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_stock) for a String column; called through the module it makes an Object
column unless cast: (String) dm.canonical_symbol_stock(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The ticker, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
The ticker unchanged, or None for None or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_stock_cms ¶
canonical_symbol_stock_cms(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert a CMS stock ticker to Massive's: BRK B to BRK.B, BAC PRL to BACpL.
The CMS convention (the root, a space, and a suffix, as many broker and FIX systems write
it) spells a class as X and a preferred as PR and its optional series. Its other
suffixes (WS, U, RT, WI) are refused, since Massive documents no spelling for
them. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_stock_cms) for a String column; called through the module it makes an
Object column unless cast: (String) dm.canonical_symbol_stock_cms(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The CMS ticker, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
Massive's ticker, or None for None or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_stock_nasdaq ¶
canonical_symbol_stock_nasdaq(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert a Nasdaq Integrated Platform stock ticker to Massive's: KIM-L to KIMpL.
Nasdaq's own symbology (the "NASDAQ Symbol" column of nasdaqtraded.txt) writes a class as
.X and a preferred as - and its optional series. Its other suffixes (+ warrants, =
units, ^ rights, # when issued) are refused, since Massive documents no spelling for
them. The ACT symbology of the same files writes .W for warrants and .V for both a
class and when-issued, so it is ambiguous and not supported. Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_stock_nasdaq) for a String column; called through the module it makes an
Object column unless cast: (String) dm.canonical_symbol_stock_nasdaq(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The Nasdaq ticker, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
Massive's ticker, or None for None or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
canonical_symbol_stock_yahoo ¶
canonical_symbol_stock_yahoo(text: str | None, *, on_error: OnError = OnError.RAISE) -> str | None
Convert a Yahoo Finance stock ticker to Massive's: BRK-B to BRK.B, BAC-PL to BACpL.
Yahoo writes a share class as -X and a preferred as -P and its series. Only plain
tickers, classes, and preferreds with a series convert: Yahoo's bare -P is refused (a
generic preferred and class P read alike), and warrants (-WT), units (-UN), and rights
(-RI) are refused, since Massive documents no spelling for them, and so is a ticker with a
dot, Yahoo's mark of a listing outside the US (VOD.L). Thread-safe.
In a Deephaven query string, import it by bare name (from deephaven_massive import
canonical_symbol_stock_yahoo) for a String column; called through the module it makes an
Object column unless cast: (String) dm.canonical_symbol_stock_yahoo(Col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The Yahoo ticker, or None. |
required |
on_error
|
OnError
|
What text that does not convert does. |
RAISE
|
Returns:
| Type | Description |
|---|---|
str | None
|
Massive's ticker, or None for None or, under |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
Under |
disable_debug_logging ¶
disable_debug_logging() -> None
Turn the library's log off again, whichever switch turned it on and at whatever level.
Call it once a bug report has its lines, or to quiet a console after
enable_debug_logging() or DEEPHAVEN_MASSIVE_LOG. It logs one INFO line saying the log
is off, removes the output either switch added, and sets the deephaven_massive logger's
level back to NOTSET. WARNING and ERROR records then reach stderr through Python's
last-resort handler, as they do at import, and lower levels are dropped. A handler you
added yourself stays, but the logger's level goes back to NOTSET even if you set it. A
later first session doesn't turn the log back on from the environment variables;
enable_debug_logging() does. With the log already off, it changes nothing.
Example
import deephaven_massive as dm
dm.enable_debug_logging()
# ... run the failing code, save the lines ...
dm.disable_debug_logging()
enable_debug_logging ¶
enable_debug_logging(output: LogOutput | str | PathLike[str] = LogOutput.STDERR) -> None
Send every record of the library, DEBUG and up, to stderr or to a file.
Call it from a Deephaven console when something goes wrong, run the failing code again, and
attach the lines to the bug report: they hold what the library decided and why, the
requests it made with their status and request_id, and the values it could not read.
They never hold the API key or the S3 secret.
It sets the deephaven_massive logger to DEBUG and logs one INFO line describing the
environment. A second call replaces the first one's output. Once you call it, the
environment variable DEEPHAVEN_MASSIVE_LOG no longer applies.
A file that cannot be opened for appending raises its OSError (from open), and the
previous handler, if any, stays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
LogOutput | str | PathLike[str]
|
|
STDERR
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Example
import deephaven_massive as dm
dm.enable_debug_logging() # or dm.enable_debug_logging("/tmp/massive.log")
m = dm.MassiveSession()
t = m.stocks.last_trade(["AAPL"]).fetch() # its requests are now in the log
canonicalize_symbols ¶
canonicalize_symbols(table: Table, asset_class: AssetClass, *, column: str = 'Symbol', convention: SymbolConvention = SymbolConvention.MASSIVE, on_error: OnError = OnError.LOG) -> Table
Return a table whose symbol column holds Massive's exact tickers, converted row by row.
Use it to turn a watchlist written in another ticker format (EUR/USD, Yahoo's BRK-B)
into one you can pass as symbols=. Each row converts as dm.canonical_symbol(value,
asset_class, convention=convention) would. A null stays null. The current rows convert
when you call. On a live table, each row added or changed later converts as it arrives.
By default, a value that doesn't convert gets a null symbol. Every query skips a null symbol, so one such value never stops your table.
A query that reads the returned table lists each such value in m.problems() under the
cause noncanonical_symbols. A table you make from the returned one, with where or
rename_columns, doesn't list them, so filter or rename before you convert.
Set on_error=dm.OnError.RAISE to fail instead. A value in the current rows then raises
ValueError from this call. A row added later with such a value fails the returned table
and every live table that reads it as symbols=.
Example
from deephaven import new_table
from deephaven.column import string_col
import deephaven_massive as dm
pairs = new_table([string_col("Symbol", ["EUR/USD", "GBP-USD"])])
watchlist = dm.canonicalize_symbols(pairs, dm.AssetClass.FOREX)
# watchlist.Symbol: C:EURUSD, C:GBPUSD
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Any table with a |
required |
asset_class
|
AssetClass
|
The class of every symbol in the column. Required: nothing is inferred, so a table that mixes classes is converted one class's rows at a time. |
required |
column
|
str
|
The column to convert, |
'Symbol'
|
convention
|
SymbolConvention
|
The convention the symbols come from: |
MASSIVE
|
on_error
|
OnError
|
What happens to a value that doesn't convert:
The |
LOG
|
Returns:
| Type | Description |
|---|---|
Table
|
A table with the same rows and columns, whose |
Raises:
| Type | Description |
|---|---|
ValueError
|
Under |
A table that is not a Deephaven Table, a column that is not a str, or an
asset_class, convention, or on_error of the wrong type raises TypeError (an enum's
names the member to use); a column that is not a String column of the table, or a
stock convention for a class other than stocks, raises ValueError.