JSON Export
JSON export is configured only through CLI flags.
You can get backtest results in JSON by adding --json to the command.
whale-e strategy.toml --jsonIn JSON mode, Whale‑E writes output to stdout and automatically disables console/file logs, SQLite result writes, and Pine Script export. It does not disable the market cache or the indicator cache.
JSON options
| Option | Description |
|---|---|
--json-pretty | Pretty-prints JSON output. |
--json-objective-limit N | Caps exported backtests per objective at N. Default: 1. |
--json-include-trades | Includes the detailed trade table. |
--json-include-block-usage | Includes block usage counters. |
--json-include-strategy | Appends the source TOML as strategy_toml. |
--json-include-all-grid-parameters | Includes all grid parameters, including non-varying ones, in grid_parameters. |
--json-include-all-hyperparameters | Includes all hyperparameters, including non-varying ones, in hyperparameters. |
All these options require --json. Using them without --json returns an argument error.
In --analyze --json mode, only --json-pretty is allowed. Preflight details are documented in Analyze (dry run).
In --search-symbol --json mode, only --json-pretty is allowed. Search-specific payload details are documented in Symbol Search.
Success envelope
Backtest JSON mode uses _schema: "whale-e.backtests.v2".
success: truemode: "backtest"backtest_count: integerobjective_limit: integerinclude_trades: booleaninclude_block_usage: booleaninclude_all_grid_parameters: booleaninclude_all_hyperparameters: booleaninclude_strategy_toml: booleanwhale_e_version: stringtrade_columns: [...]only when--json-include-tradesis enabledbacktests: [...]strategy_name: stringstrategy_tomlonly when--json-include-strategyis enabled
Each entry in backtests always contains rank, a 1-based integer that represents the backtest rank within its objective, together with blocks such as context, performance, trade_analysis, and risk.
When trades are enabled, the shared trade schema is emitted once in trade_columns, and each backtest contains only trades.rows.
The performance block notably includes total_pnl and total_pnl_percent.
The risk block notably includes the margin_call, margin_call_long, and margin_call_short counters.
All absolute timestamps in the payload use Unix UTC milliseconds, without an _ms suffix in field names.
Example (truncated):
{
"success": true,
"_schema": "whale-e.backtests.v2",
"mode": "backtest",
"strategy_name": "ema-crossover",
"backtest_count": 1,
"backtests": [
{
"rank": 1,
"context": { "combination_code": "G3C123" },
"performance": { "total_pnl": { "value": 123.45, "type": "quote_amount", "side": "all" } },
"risk": { "margin_call": { "value": 0, "type": "count", "side": "all" } }
}
],
"strategy_toml": "[backtest]\n..."
}Error envelopes
Generic CLI errors:
success: false_schema: "whale-e.error.v1"mode: "backtest"for CLI backtests,mode: "analyze"for--analyze --json,mode: "search_symbol"for--search-symbol --jsonerror: { type: string, message: string }
Example:
{
"success": false,
"_schema": "whale-e.error.v1",
"mode": "backtest",
"error": { "type": "invalid_arguments", "message": "--json cannot be combined with --export-pinescript" }
}TOML parse errors:
- returned on
stdoutas a JSON object success: false_schema: "whale-e.error.v1"mode: "backtest"ormode: "analyze"depending on contexterror: { type: "toml_parse_error", message: string, details: string[], strategy_file: string }
Example:
{
"success": false,
"_schema": "whale-e.error.v1",
"mode": "backtest",
"error": {
"type": "toml_parse_error",
"message": "Invalid key at line 12",
"details": ["..."],
"strategy_file": "strategy.toml"
}
}Examples
Pretty JSON with trades and strategy TOML:
whale-e strategy.toml --json --json-pretty --json-include-trades --json-include-strategyCompact JSON with 5 results per objective:
whale-e strategy.toml --json --json-objective-limit 5