TimeStrategy

time.TimeStrategy(self, time_frame, selection, grouping, aggregation)

A strategy for dealing with the time axis, e.g., in processing results. Strategies can include selection of a subset, grouping, and aggregation.

Typically you will create one of these by calling methods on a TimeSelector instance.

TimeStrategy is a frozen dataclass.

Parameters

time_frame: TimeFrame

The original simulation time frame.

selection: tuple[slice, int | None]

The selected subset of the time frame: described as a date slice and an optional tau step index.

grouping: TimeGrouping | None

A method for grouping the time series data.

aggregation: TimeAggMethod | None

A method for aggregating the time series data (if no grouping is specified, the time series is reduced to a scalar).

Attributes

time_frame: TimeFrame

The original time frame.

selection: tuple[slice, int | None]

The selected subset of the time frame: described as a date slice and an optional tau step index.

grouping: TimeGrouping | None

A method for grouping the time series data.

aggregation: TimeAggMethod | None

A method for aggregating the time series data (if no grouping is specified, the time series is reduced to a scalar).

group_format: Literal['date', 'tick', 'day', 'other']

What scale describes the result of the grouping? Are the group keys dates? Simulation ticks? Simulation days? Or some arbitrary other type?

date_bounds: tuple[date, date]

The bounds of the selection, given as the first and last date included.

Methods

Name Description
to_time_frame Creates a TimeFrame that has the same bounds as this TimeStrategy. NOTE: this does not mean the TimeFrame contains the same number of entries (group keys) as the result of applying this strategy – groups can skip days whereas TimeFrames are contiguous.
selection_ticks Converts this into a slice for which ticks are selected (by index).