TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit/llms.txt
Use this file to discover all available pages before exploring further.
Performance class exposes aggregated execution timing statistics collected automatically during every Backtest and Live run. No setup is required: the engine emits PerformanceContract events via performanceEmitter after each measured operation, and PerformanceMarkdownService accumulates them into per-strategy buckets. Call Performance.getData, Performance.getReport, or Performance.dump at any point during or after a run to inspect timing data.
Performance tracking is built-in and enabled by default. It is useful for identifying bottlenecks—slow getSignal implementations, expensive candle fetches, or oversized signal windows—before running large production backtests.
Metric Types
Four metric types are tracked automatically:| Metric | Description |
|---|---|
backtest_total | Total wall-clock duration of a complete backtest run from start to finish. |
backtest_timeframe | Duration to process a single timeframe iteration (one tick in the frame). |
backtest_signal | Duration to process one signal: tick() + getNextCandles() + backtest(). This is the hot-path metric. |
live_tick | Duration of a single live trading tick iteration: tick() + event emission + sleep calculation. |
getData()
PerformanceStatisticsModel
Strategy name associated with these metrics.
Total number of performance events recorded across all metric types.
Sum of all execution durations in milliseconds.
Statistics grouped by metric type. Each key is one of the four
PerformanceMetricType values.All raw performance events in the order they were emitted.
MetricStats Fields
Each entry inmetricStats is a MetricStats object:
The metric this entry describes.
Number of recorded samples for this metric.
Mean execution duration in milliseconds.
Fastest recorded sample in milliseconds.
Slowest recorded sample in milliseconds.
Standard deviation of durations. High
stdDev indicates inconsistent execution time.50th percentile duration in milliseconds.
95th percentile duration. Useful for identifying occasional slow outliers.
99th percentile duration. Identifies extreme tail latencies.
Total execution time across all samples for this metric.
Average time between consecutive events of this type.
Minimum gap between consecutive events.
Maximum gap between consecutive events.
getReport()
- A summary table listing
count,avg,min,max,stdDev,median,P95, andP99for each metric type. - A bottleneck section highlighting which operations consumed the most total time.
- Time-distribution percentages so you can see which phase dominates.
dump()
./dump/performance/.
Example
Listening to Raw Events
Subscribe toperformanceEmitter directly for real-time metric streaming:
Performance tracking is completely passive—it adds no overhead to your strategy logic and requires no registration or opt-in. The
PerformanceMarkdownService is subscribed to performanceEmitter automatically when the framework initializes. The maximum number of stored events is controlled by CC_MAX_PERFORMANCE_MARKDOWN_ROWS (default: 10,000), which is higher than other report limits to enable accurate statistical analysis over large backtests.