Skip to main content
Range-based models in Systematica implement trading strategies that identify price ranges within specific time periods and generate signals based on price behavior relative to these ranges. These models use time-based grouping rather than rolling windows, making them fundamentally different from other model types in the framework.

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 use vbt.Splitter.from_grouper to create discrete time periods, contrasting with rolling window approaches used by other models:

RangeBreakout

The RangeBreakout class implements trend-following breakout strategies by detecting when prices break above or below established ranges. Range breakout model implementation using 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 the by period. Integer values are NOT supported and will cause errors during cross-validation.
  • When using with Optuna optimization, define training_window as:
Signal Model Compatibility: This model outputs discrete position values (-1, 0, 1) and works with the “crossover” signal model. For successful signal generation:
  • 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
Common Issues and Solutions:
  1. Integer training_window causes “Must provide at least one range” error
  2. All Optuna trials pruned with NaN metrics
Examples: Basic usage with string training window:
Optuna optimization setup:
See Also:
  • systematica.signals.Crossover : Signal model used with this indicator
  • examples/scripts/models/range_breakout/example_range_breakout.py : Complete example
Method generated by attrs for class RangeBreakout.

Ancestors

  • systematica.models.base.BaseStatArb
  • abc.ABC

Static methods

apply_between_time

Helper function to clean data using pandas between_time. More information in the Pandas Documentation Parameters: Returns:

Instance variables

  • by: str: Split data temporarily. Defaults to D for daily.
  • custom_splitter: str: Custom splitter function, if provided. Defaults to None.
  • custom_splitter_kwargs: Dict[str, Any]: Additional arguments for the custom splitter. Defaults to None.
  • end_time: str: End time as a time filter limit. If None, no processing is done. Defaults to 00: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 using parse_index_freq. If a string is provided: If auto, the frequency is detected with auto_detect_freq. If the string starts with index_, the corresponding method (obtained after stripping the prefix) is applied to the differences between consecutive index values. If freq_from_n is an integer (positive or negative), the index is limited to the first or last N elements respectively. Defaults to auto.
  • splitter: str: Splitter method for cross-validation, by default from_grouper.
  • start_time: str: Initial time as a time filter limit. If None, no processing is done. Defaults to None.
  • tol: float: Range tolerance to trigger a long/short signal such as trigger = tol * range_values. Defaults to 0.5.
  • training_window: str | float: Specification for further splitting of each range. The split size of the training window used in splitter.from_grouper. It could be a float (e.i. 0.5, which split each range in half) or a string (e.i. 4h or 4 hours. which takes the first 4 hours of the range). Defaults to 2h (2 hours).

Methods

check_training_window

Validate training_window. Parameters: Raises:

plot_model_output

Plot range breakout. Parameters: Returns:

plot_signals

Plot range breakout. Parameters: Returns: