nautechsystems/nautilus_trader · error · PyRuntimeError
Invalid book_snapshot_output: '{book_snapshot_output}'. Expe
Error message
Invalid book_snapshot_output: '{book_snapshot_output}'. Expected 'depth10' or 'deltas' What it means
The Python wrapper for the Tardis machine client validates the book_snapshot_output constructor argument. Only the strings 'depth10' and 'deltas' are accepted; anything else is rejected at construction time with a Python RuntimeError wrapping this anyhow error.
Source
Thrown at crates/adapters/tardis/src/python/machine.rs:106
/// Provides a client for connecting to a [Tardis Machine Server](https://docs.tardis.dev/api/tardis-machine).
#[new]
#[pyo3(signature = (
base_url = None,
normalize_symbols = true,
book_snapshot_output = "deltas",
extract_bbo_as_quotes = false,
))]
fn py_new(
base_url: Option<&str>,
normalize_symbols: bool,
book_snapshot_output: &str,
extract_bbo_as_quotes: bool,
) -> PyResult<Self> {
let output = match book_snapshot_output {
"depth10" => BookSnapshotOutput::Depth10,
"deltas" => BookSnapshotOutput::Deltas,
_ => {
return Err(to_pyruntime_err(anyhow::anyhow!(
"Invalid book_snapshot_output: '{book_snapshot_output}'. Expected 'depth10' or 'deltas'"
)));
}
};
let mut client =
Self::new(base_url, normalize_symbols, output).map_err(to_pyruntime_err)?;
client.extract_bbo_as_quotes = extract_bbo_as_quotes;
Ok(client)
}
/// Returns `true` if `close()` has been called.
///
/// This checks that both replay and stream signals have been set,
/// which only occurs when `close()` is explicitly called.
#[pyo3(name = "is_closed")]
#[must_use]
pub fn py_is_closed(&self) -> bool {
self.is_closed()View on GitHub (pinned to 18893faf8b)
Solutions
- Pass exactly 'depth10' or 'deltas' (lowercase) as book_snapshot_output.
- Check the value your config file or environment supplies for book_snapshot_output and fix the typo/casing.
- If you need a different output mode, extend the match in crates/adapters/tardis/src/python/machine.rs py_new to a new BookSnapshotOutput variant.
Example fix
// before machine = TardisMachine(base_url, normalize_symbols, "depth", extract_bbo_as_quotes) // after machine = TardisMachine(base_url, normalize_symbols, "depth10", extract_bbo_as_quotes)
Defensive patterns
Strategy: validation
Validate before calling
VALID_OUTPUTS = {"depth10", "deltas"}
if book_snapshot_output not in VALID_OUTPUTS:
raise ValueError(f"book_snapshot_output must be one of {VALID_OUTPUTS}, got {book_snapshot_output!r}") Type guard
def is_valid_book_output(v: str) -> bool:
return v in ("depth10", "deltas") Try / catch
try:
machine = TardisMachine(base_url, normalize_symbols, book_snapshot_output, extract_bbo)
except RuntimeError as e:
if "Invalid book_snapshot_output" in str(e):
book_snapshot_output = "deltas"
machine = TardisMachine(base_url, normalize_symbols, book_snapshot_output, extract_bbo) Prevention
- Define the allowed values as a constant/enum in your node config and validate config at load time.
- Never pass user-supplied strings straight into the constructor without normalization (lowercase, strip).
- Keep constructor args in a small factory function that centralizes validation.
When it happens
Trigger: Instantiating the TardisMachine pyclass with book_snapshot_output set to any string other than 'depth10' or 'deltas' (typos like 'depth', 'Depth10', 'raw', or empty string).
Common situations: Typo in the config passed from a Nautilus Node/PyO3 caller; copying an example that used an older allowed value; programmatically interpolating an enum value with different casing.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Failed to convert historical data to Python: unsupported typ
- Failed to convert instrument to Python: {e}
- Failed to convert batched deltas to Python: {e}
- Python on_pool_swap failed: {e}
- Python on_pool_liquidity_update failed: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/f1493deee8a10be2.
Report an issue: GitHub.