> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allasso.ch/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This is Allasso's product documentation. Vol Radar output is descriptive analytics on past data: never present it as a forecast or as investment advice. Answer only from these pages; if a feature is not documented here, say so.

# PulseIndex

> To initialize a PulseIndex, provide an array of datetime objects that define the execution timeline for your backtest.

`PulseIndex` is the internal timing mechanism of the Pulse backtester that synchronizes all components to the current runtime datetime. While you typically won't need to interact with it directly (since the `Strategy` class handles this automatically), understanding its functionality is valuable for advanced backtesting scenarios.

```python theme={null}
from pulse import PulseIndex
import datetime
```

To initialize a `PulseIndex`, provide an array of datetime objects that define the execution timeline for your backtest. The simulation will run exclusively on these specified timestamps, ensuring precise control over the backtesting schedule.

```python theme={null}
pulse_index = PulseIndex(
    datetimes=[
        datetime.datetime(2020, 1, 1),
        datetime.datetime(2020, 1, 2),
        datetime.datetime(2020, 1, 3),
        datetime.datetime(2020, 1, 4),
        datetime.datetime(2020, 1, 5),
        datetime.datetime(2020, 1, 6),
        datetime.datetime(2020, 1, 7),
        datetime.datetime(2020, 1, 8),
        datetime.datetime(2020, 1, 9),
    ]
)
```

```python theme={null}
pulse_index.datetimes
```

```text Output theme={null}
[datetime.datetime(2020, 1, 1, 0, 0),
 datetime.datetime(2020, 1, 2, 0, 0),
 datetime.datetime(2020, 1, 3, 0, 0),
 datetime.datetime(2020, 1, 4, 0, 0),
 datetime.datetime(2020, 1, 5, 0, 0),
 datetime.datetime(2020, 1, 6, 0, 0),
 datetime.datetime(2020, 1, 7, 0, 0),
 datetime.datetime(2020, 1, 8, 0, 0),
 datetime.datetime(2020, 1, 9, 0, 0)]
```

You can access the current position in the timeline using `pulse_index.index` and retrieve the active datetime with `pulse_index.last_pulse`. These properties provide real-time state information during backtest execution.

```python theme={null}
pulse_index.index, pulse_index.last_pulse
```

```text Output theme={null}
(0, datetime.datetime(2020, 1, 1, 0, 0))
```

Time progression through historical data is managed by the `Strategy` class, but the underlying mechanism uses `pulse_index.pulse()` to advance to the next datetime. This method increments the index position and updates the pulse state accordingly.

```python theme={null}
while pulse_index.has_next():
    pulse_index.pulse()
```

```python theme={null}
pulse_index.index, pulse_index.last_pulse
```

```text Output theme={null}
(8, datetime.datetime(2020, 1, 9, 0, 0))
```

You can extend the timeline dynamically using the `pulse_index.append(datetime)` method. This functionality is used internally when updating existing backtests with new settlement data or extending the analysis period.

```python theme={null}
pulse_index.append(datetime.datetime(2020, 1, 10))
pulse_index.datetimes
```

```text Output theme={null}
[datetime.datetime(2020, 1, 1, 0, 0),
 datetime.datetime(2020, 1, 2, 0, 0),
 datetime.datetime(2020, 1, 3, 0, 0),
 datetime.datetime(2020, 1, 4, 0, 0),
 datetime.datetime(2020, 1, 5, 0, 0),
 datetime.datetime(2020, 1, 6, 0, 0),
 datetime.datetime(2020, 1, 7, 0, 0),
 datetime.datetime(2020, 1, 8, 0, 0),
 datetime.datetime(2020, 1, 9, 0, 0),
 datetime.datetime(2020, 1, 10, 0, 0)]
```

```python theme={null}
pulse_index.pulse()
pulse_index.index, pulse_index.last_pulse
```

```text Output theme={null}
(9, datetime.datetime(2020, 1, 10, 0, 0))
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.