Skip to content

AlgorithmSpeedTracker

QuantConnect.Lean.Engine.Results.Analysis.AlgorithmSpeedTracker

Bases: Object

Accumulates periodic samples of the engine's speed counters (data points processed, history data points, backtest days processed) while a backtest runs, and computes the throughput and progress metrics consumed by the in-run Analyses.AlgorithmSpeedAnalysis. All rates are computed between samples, so setup time before the first sample is excluded.

RECENT_WINDOW_SAMPLES

RECENT_WINDOW_SAMPLES: int = 5

The number of trailing samples that make up the "recent" window used by the windowed rates. At the ~30 second in-run analysis cadence this spans roughly the last two minutes.

sample_count

sample_count: int

The number of samples recorded so far.

total_days

total_days: int

The total number of calendar days the backtest will run.

processed_days

processed_days: int

The number of calendar days the backtest has processed as of the latest sample.

progress

progress: float

The backtest progress as of the latest sample, in the <0, 1> range.

elapsed

elapsed: timedelta

The wall-clock time elapsed since the backtest started, as of the latest sample.

sampled_span

sampled_span: timedelta

The wall-clock time between the first and the latest sample, that is, the period the rates are measured over.

has_data_point_counts

has_data_point_counts: bool

Whether the main loop data point counter is being fed. When the counter is not wired in (it reads zero), data-point-based rates are not meaningful and should not be used.

data_points_per_second

data_points_per_second: Optional[float]

The average data points processed per second over the whole sampled span, including history data points to match the speed the engine reports on completion. Null when there are not enough samples to measure.

initial_data_points_per_second

initial_data_points_per_second: Optional[float]

The average data points processed per second over the first RECENT_WINDOW_SAMPLES samples, used as the early-run baseline for degradation detection. Null when there are not enough samples to measure.

add_sample

add_sample(sample: AlgorithmSpeedSample) -> None

Records a sample of the cumulative speed counters. Samples with a non-increasing elapsed time are ignored so rates are always computed over positive time deltas.

Parameters:

Name Type Description Default
sample AlgorithmSpeedSample

The sample of the cumulative speed counters.

required

estimated_remaining_time

estimated_remaining_time(
    skip_last: int = 0,
) -> Optional[timedelta]

The estimated wall-clock time left for the backtest to complete, projecting the recent calendar-days-per-second pace over the remaining backtest days.

Parameters:

Name Type Description Default
skip_last int

Number of trailing samples to skip, to evaluate the projection as of a previous run.

0

Returns:

Type Description
Optional[timedelta]

The estimate, zero when the backtest already reached its end date, or null when the recent pace is zero or there are not enough samples to measure.

recent_data_points_per_second

recent_data_points_per_second(
    skip_last: int = 0,
) -> Optional[float]

The average data points processed per second over the recent window, including history data points.

Parameters:

Name Type Description Default
skip_last int

Number of trailing samples to skip, to evaluate the window as of a previous run.

0

Returns:

Type Description
Optional[float]

The windowed rate, or null when there are not enough samples to measure.

recent_days_per_second

recent_days_per_second(
    skip_last: int = 0,
) -> Optional[float]

The average backtest calendar days processed per wall-clock second over the recent window.

Parameters:

Name Type Description Default
skip_last int

Number of trailing samples to skip, to evaluate the window as of a previous run.

0

Returns:

Type Description
Optional[float]

The windowed rate, or null when there are not enough samples to measure.

recent_history_data_points

recent_history_data_points(skip_last: int = 0) -> int

The number of history data points served over the recent window.

Parameters:

Name Type Description Default
skip_last int

Number of trailing samples to skip, to evaluate the window as of a previous run.

0

recent_history_data_points_share

recent_history_data_points_share(
    skip_last: int = 0,
) -> Optional[float]

The share of the data points processed over the recent window that were served by the history provider, in the <0, 1> range.

Parameters:

Name Type Description Default
skip_last int

Number of trailing samples to skip, to evaluate the window as of a previous run.

0

Returns:

Type Description
Optional[float]

The share, or null when there are not enough samples or no data points were processed in the window.