Skip to main content
A backtest is a walk over an ordered list of timestamps. PulseIndex holds that list and tracks where the walk currently is. You rarely touch it directly - the strategy drives it for you.

PulseIndex

PulseIndex is constructed from a list[datetime] and keeps a single cursor into it. pulses_per_year is derived from the timestamp span (len(datetimes) * 365 / span_days), so a daily SPX run lands near 252, an hourly 24/7 BTC run near 8760. It is cached and recomputed when timestamps are appended.

The clock advances before your logic

Strategy.pulse() runs the same fixed order every step:
  1. pulse_index.pulse() - move the clock to the next timestamp.
  2. on_update() - your logic, reading data as of the new last_pulse.
  3. The broker fills any orders, the portfolio books and reprices.
The cursor starts at index 0, and the clock is advanced first. So on_update() first runs on the second timestamp in the list, never the first. The first timestamp is only ever the starting mark the clock advances away from.
You drive the clock through the strategy, not by handrun_sequentially builds the PulseIndex from your datetimes and loops it while has_next() is True. Reach the current time through self.last_pulse; you should not call pulse() yourself inside a strategy.

Where the timestamps come from

Unless you pass datetimes= explicitly, the environment builds the calendar from the underlying’s own settlement dates:
unified=True intersects the underlying’s instrument families (options, futures, spot), so every pulse is a timestamp where every family has data - a mixed options-plus-futures book can be marked on each one. With more than one underlying the per-underlying calendars are intersected again. available_settlements also takes start_datetime / end_datetime bounds and an instrument_type filter, so you can restrict a run to one period or to a single family and pass the result as datetimes=:

Counting back, not stepping back

There is no calendar-step type: history is measured in rows, not in days. datafeed.instrument.history(instrument, as_of_time, count) returns the last count observations at or before as_of_time, and pulse_index.pulse_history(pulse_index.index - 1) names the previous pulse. Both count in pulses, so they follow the run’s own cadence (daily or hourly) instead of assuming one. Related: Architecture and the pulse loop · DataFeed and market data · Orders, trades and the broker · Portfolio, equity and PnL
Last modified on November 4, 2026