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

# Custom Splitter

> systematica.utils.custom_splitter

## `CustomSplitter`

```python theme={null}
CustomSplitter(
    wrapper: vectorbtpro.base.wrapping.ArrayWrapper,
    index: pandas.core.indexes.base.Index,
    splits_arr: numpy.ndarray,
    **kwargs,
)
```

Custom splitter.

### Ancestors

* `vectorbtpro.generic.splitting.base.Splitter`
* `vectorbtpro.generic.analyzable.Analyzable`
* `vectorbtpro.base.wrapping.Wrapping`
* `vectorbtpro.utils.config.Configured`
* `vectorbtpro.utils.config.HasSettings`
* `vectorbtpro.utils.caching.Cacheable`
* `vectorbtpro.utils.checks.Comparable`
* `vectorbtpro.utils.pickling.Pickleable`
* `vectorbtpro.utils.formatting.Prettified`
* `vectorbtpro.utils.chaining.Chainable`
* `vectorbtpro.base.wrapping.HasWrapper`
* `vectorbtpro.base.indexing.ExtPandasIndexer`
* `vectorbtpro.base.indexing.PandasIndexer`
* `vectorbtpro.base.indexing.IndexingBase`
* `vectorbtpro.utils.params.ItemParamable`
* `vectorbtpro.utils.params.Itemable`
* `vectorbtpro.utils.params.Paramable`
* `vectorbtpro.base.indexes.IndexApplier`
* `vectorbtpro.utils.attr_.AttrResolverMixin`
* `vectorbtpro.generic.stats_builder.StatsBuilderMixin`
* `vectorbtpro.generic.plots_builder.PlotsBuilderMixin`
* `vectorbtpro.utils.base.Base`

### Static methods

#### `from_custom_rolling`

```python theme={null}
from_custom_rolling(
    index: pandas.core.indexes.base.Index,
    length: int,
    offset: int = 0,
    offset_anchor: str = 'prev_end',
    offset_anchor_set: int = 0,
    offset_space: str = 'prev',
    backwards: str | bool = False,
    split: int = None,
    split_range_kwargs: Dict[str, Any] = None,
    range_bounds_kwargs: Dict[str, Any] = None,
    template_context: Dict[str, Any] = None,
    freq: str = None,
    **kwargs,
) ‑> ~SplitterT
```

Create a custom `Splitter` instance from a rolling range of fixed length.

Superset `Splitter.from_rolling` by adding the first (if backwards is sorted)
or last remaining split. Creates a rolling sequence of slices based on the provided index.
The first slice uses a length defined by `length`, and each subsequent
slice begins after an offset from the previous slice's right boundary.

Uses `Splitter.from_splits` to generate an array of splits and
corresponding labels, and then construct the `Splitter` instance. See `Splitter.from_rolling` for further informations.

**Parameters**:

| Name                  | Type               | Default    | Description                                                                                                                                                                       |
| --------------------- | ------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index`               | `tp.IndexLike`     | `--`       | The index to use for the splits. Must be a datetime-like index.                                                                                                                   |
| `length`              | `int`              | `--`       | The length of each rolling slice. Can be an `int`, `Float`, or `timedelta`.                                                                                                       |
| `offset`              | `int`              | `0`        | The offset to apply to the start of each slice after the first one. Can be an integer, float, or timedelta.                                                                       |
| `offset_anchor`       | `str`              | `prev_end` | The anchor point for the offset. Can be `prev_end` or `start`.                                                                                                                    |
| `offset_anchor_set`   | `int`              | `0`        | The index of the anchor point to use for the offset. If `None`, uses the last anchor point.                                                                                       |
| `offset_space`        | `str`              | `prev`     | The space in which the offset is applied. Can be `prev` or `all`.                                                                                                                 |
| `backwards`           | `bool`             | `False`    | If `True`, the rolling slices are created in reverse order. If 'sorted', the first slice is sorted in reverse order. If `False`, the rolling slices are created in forward order. |
| `split`               | `tp.SplitLike`     | `None`     | If provided, the rolling slices will be split further according to this parameter. Can be a single split or a list of splits.                                                     |
| `split_range_kwargs`  | `tp.KwargsLike`    | `None`     | Additional keyword arguments to pass to the `split_range` method.                                                                                                                 |
| `range_bounds_kwargs` | `tp.KwargsLike`    | `None`     | Additional keyword arguments to pass to the `get_range_bounds` method.                                                                                                            |
| `template_context`    | `tp.KwargsLike`    | `None`     | Context for template rendering, if applicable.                                                                                                                                    |
| `freq`                | `tp.FrequencyLike` | `None`     | Frequency of the index. If `None`, it will be inferred from the index.                                                                                                            |
| `kwargs`              | `tp.Kwargs`        | `--`       | Additional keyword arguments to pass to the `Splitter.from_splits` method.                                                                                                        |

**Raises**:

| Type         | Description                                             |
| ------------ | ------------------------------------------------------- |
| `ValueError` | If `backwards` is a string that is not `sorted`.        |
| `ValueError` | If the `length` is negative when `backwards` is `True`. |

**Returns**:

| Type        | Description                                                               |
| ----------- | ------------------------------------------------------------------------- |
| `SplitterT` | An instance of `Splitter` containing the rolling slices and their labels. |

#### `from_custom_expanding`

```python theme={null}
from_custom_expanding(
    index: pandas.core.indexes.base.Index,
    min_length: int,
    offset: int,
    split: int = None,
    split_range_kwargs: Dict[str, Any] = None,
    range_bounds_kwargs: Dict[str, Any] = None,
    template_context: Dict[str, Any] = None,
    freq: str = None,
    **kwargs,
) ‑> ~SplitterT
```

Create a `Splitter` instance from an expanding range.

Creates an expanding sequence of slices based on the provided index.
The first slice uses a minimum length defined by min\_length, and each
subsequent slice begins after an offset from the previous slice's right
boundary.

Uses `Splitter.from_expanding` by adding the last remaining split. See `Splitter.from_expanding` for further informations.

**Parameters**:

| Name                  | Type               | Default | Description                                                                                                                     |
| --------------------- | ------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `index`               | `tp.IndexLike`     | `--`    | The index to use for the splits. Must be a datetime-like index.                                                                 |
| `min_length`          | `int`              | `--`    | The minimum length of each expanding slice. Can be an `int`, `float`, or `timedelta`.                                           |
| `offset`              | `int`              | `--`    | The offset to apply to the start of each slice after the first one. Can be an `int`, `Float`, or `timedelta`.                   |
| `split`               | `tp.SplitLike`     | `None`  | If provided, the expanding slices will be split further according to this parameter. Can be a single split or a list of splits. |
| `split_range_kwargs`  | `tp.KwargsLike`    | `None`  | Additional keyword arguments to pass to the `split_range` method.                                                               |
| `range_bounds_kwargs` | `tp.KwargsLike`    | `None`  | Additional keyword arguments to pass to the `get_range_bounds` method.                                                          |
| `template_context`    | `tp.KwargsLike`    | `None`  | Context for template rendering, if applicable.                                                                                  |
| `freq`                | `tp.FrequencyLike` | `None`  | Frequency of the index. If `None`, it will be inferred from the index.                                                          |
| `kwargs`              | `tp.Kwargs`        | `--`    | Additional keyword arguments to pass to the `Splitter.from_splits` method.                                                      |

**Raises**:

| Type         | Description                               |
| ------------ | ----------------------------------------- |
| `ValueError` | If the `min_length` is negative.          |
| `ValueError` | If the `offset` is negative.              |
| `ValueError` | If the `split` is not a valid split type. |

**Returns**:

| Type        | Description                                                                 |
| ----------- | --------------------------------------------------------------------------- |
| `SplitterT` | An instance of `Splitter` containing the expanding slices and their labels. |
