Notebook JSON export
All plugins

Plugin libraryReports

Plugin

Notebook JSON export

Writes a whole run as one versioned, documented JSON file plus a trades CSV and a JSON Schema, ready for pandas or any notebook.

ExporterNo networkDesktop onlyv1.0.0

About

For your own analysis in Jupyter, pandas or any other tool: the run as one JSON file with what ran (instrument, timeframe, period, seed, currency, engine), its configuration, the statistics, the equity curve, every trade with every field the engine recorded, and the monthly returns. The trades also come as a CSV, and the file's JSON Schema comes along, so the export explains itself wherever it is copied.

The file says "format": "orionquant-notebook" and "formatVersion": 1. Version 1 only ever gains fields; a change of meaning would be version 2, so code written against version 1 keeps working. Keys are camelCase as in the engine's result, times are ISO 8601 in UTC, money is in run.resultCurrency.

In pandas:

pythonimport json
import pandas as pd

with open("notebook_EURUSD_42.json", encoding="utf-8") as fh:
    nb = json.load(fh)
trades = pd.DataFrame(nb["trades"])
equity = pd.DataFrame(nb["equity"]).assign(ts=lambda d: pd.to_datetime(d["ts"])).set_index("ts")
trades_csv = pd.read_csv("notebook_EURUSD_42_trades.csv", parse_dates=["entryTs", "exitTs"])

Configuration

FieldTypeDefaultDescription
equityEquity pointsselect"all"all: one equity point per bar. daily: the last point of each UTC day, which keeps the file small for a long run on a short timeframe.Options: all, daily
fileNameFile namestring"notebook"The start of the file names; the instrument and the run's seed are added.

Use it in a strategy

Not called from a strategy: after a run, choose it in the result's export menu. Exports are part of the plans that include CSV export. The pandas lines above read the files it writes.

What it provides

notebook_<instrument>_<seed>.jsonFileThe run: run, config, stats, costsUsed, equitySampling, equity, trades and monthlyReturns, as the schema describes.
notebook_<instrument>_<seed>_trades.csvFileOne row per trade, columns named as in the JSON (id, symbol, direction, entryTs, exitTs, prices, lots, P&L, costs, exitReason, mae, mfe and more).
notebook_json_export.schema.jsonFileThe JSON Schema (draft 2020-12) of the JSON file, with a description of every field that needs one.

Limits

  • The strategy's source code is left out of the configuration (strategy.code and strategy.files), so a shared file does not share your strategy.
  • The price bars and indicator series are not included; a long run on a short timeframe still gives a large file, which equity daily makes smaller.
  • A number that is not finite (an infinite profit factor, say) is written as null, because JSON has no Infinity.
OrionQuant