quantlab.utils.jsonable#

Convert arbitrary result payloads into strictly standard JSON values.

Backtest statistics carry NaN, infinities, pd.Timestamp, pd.Timedelta (including NaT) and numpy scalars. Plain json.dump either emits the non-standard NaN and Infinity tokens, which strict parsers reject, or raises on the timestamp types. Every JSON artifact a backtest run persists is passed through to_jsonable first.

The conversion either keeps every value or fails with an error; it never silently loses data. Arrays, Series, Indexes and sets become full lists, dict keys that collide after str() raise ValueError, and an unsupported type raises TypeError instead of being stringified. This module has no project-internal imports, so any layer can use it.

Functions

to_jsonable

Return value rebuilt from JSON-safe types only.