Overview and Architecture
Range-based models operate by dividing time series data into discrete temporal groups (e.g., daily, weekly periods) and defining trading ranges using a subset of each period. The framework provides two complementary strategies:- Range Breakout: Trend-following strategy that trades breakouts above/below established ranges
- Range Mean Reversion: Counter-trend strategy that trades reversals at range boundaries
Core Concepts: Time-Based Grouping vs Rolling Windows
Range-based models usevbt.Splitter.from_grouper to create discrete time periods, contrasting with rolling window approaches used by other models:
| Aspect | Range-Based Models | Rolling Window Models |
|---|---|---|
| Grouping Method | splitter.from_grouper | splitter.from_rolling |
| Period Definition | Fixed time periods (daily, weekly) | Sliding windows (N bars) |
| Range Calculation | First portion of each period | Continuous moving calculation |
| Signal Reset | Resets each period | Continuous evolution |
RangeBreakout
splitter.from_grouper.
This model identifies trading ranges during specific time periods and generates
signals when price breaks above or below these ranges. Unlike rolling window
models, this uses time-based grouping (e.g., daily, weekly) to define ranges.
Notes:
Parameter Requirements:
-
training_window: Must be a string in time format (e.g., “2h”, “4h”) or a float representing a fraction of thebyperiod. Integer values are NOT supported and will cause errors during cross-validation. -
When using with Optuna optimization, define
training_windowas:
- Set
long_entries < 1.0(e.g., 0.9) so signals cross the threshold - Set
short_entries > -1.0(e.g., -0.9) so signals cross the threshold - Exit thresholds should be within (-0.5, 0.5) for optimal results
-
Integer training_window causes “Must provide at least one range” error
-
All Optuna trials pruned with NaN metrics
systematica.signals.Crossover: Signal model used with this indicatorexamples/scripts/models/range_breakout/example_range_breakout.py: Complete example
Ancestors
systematica.models.base.BaseStatArbabc.ABC
Static methods
apply_between_time
between_time.
More information in the Pandas Documentation
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
data | vbt.Data | -- | Input data containing time series data. |
start_time | datetime.time | -- | Initial time as a time filter limit. |
end_time | datetime.time | -- | End time as a time filter limit. |
kwargs | tp.Kwargs | -- | Additional keyword arguments for between_time. |
| Type | Description |
|---|---|
vbt.Data | Slice data object. |
Instance variables
-
by: str: Split data temporarily. Defaults toDfor daily. -
custom_splitter: str: Custom splitter function, if provided. Defaults toNone. -
custom_splitter_kwargs: Dict[str, Any]: Additional arguments for the custom splitter. Defaults toNone. -
end_time: str: End time as a time filter limit. IfNone, no processing is done. Defaults to00:00. -
freq: str: Frequency of the index (e.g.,daily,15 min,index_mean). Infer or convert the frequency for a datetime index. If freq is None, the frequency is inferred usingparse_index_freq. If a string is provided: Ifauto, the frequency is detected withauto_detect_freq. If the string starts withindex_, the corresponding method (obtained after stripping the prefix) is applied to the differences between consecutive index values. Iffreq_from_nis an integer (positive or negative), the index is limited to the first or lastNelements respectively. Defaults toauto. -
splitter: str: Splitter method for cross-validation, by defaultfrom_grouper. -
start_time: str: Initial time as a time filter limit. IfNone, no processing is done. Defaults toNone. -
tol: float: Range tolerance to trigger a long/short signal such astrigger = tol * range_values. Defaults to0.5. -
training_window: str | float: Specification for further splitting of each range. The split size of the training window used insplitter.from_grouper. It could be a float (e.i.0.5, which split each range in half) or a string (e.i.4hor4 hours. which takes the first 4 hours of the range). Defaults to2h(2 hours).
Methods
check_training_window
| Name | Type | Default | Description |
|---|---|---|---|
attribute | tp.Type | -- | The attribute being validated. |
value | tp.Any | -- | The model instance. |
| Type | Description |
|---|---|
ValueError | If the training window size is greater than the temporal parameter by. |
plot_model_output
| Name | Type | Default | Description |
|---|---|---|---|
data | vbt.Data | -- | A data object containing asset prices and other relevant information. |
symbol | str | -- | The asset symbol to plot. |
use_close | bool | True | Use close price if set to True. Otherwise, use open price. |
layout_kwargs | tp.Kwargs | -- | Additional layout arguments for the figure. |
| Type | Description |
|---|---|
vbt.FigureWidget | A Plotly FigureWidget containing range breakout model. |
plot_signals
| Name | Type | Default | Description |
|---|---|---|---|
data | vbt.Data | -- | A data object containing asset prices and other relevant information. |
symbol | str | -- | The asset symbol to plot. |
use_close | bool | True | Use close price if set to True. Otherwise, use open price. |
layout_kwargs | tp.Kwargs | -- | Additional layout arguments for the figure. |
| Type | Description |
|---|---|
vbt.FigureWidget | A Plotly FigureWidget containing range breakout model. |

