> ## 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.

# Base

> systematica.walk_forward.base

## `BaseWalkForward`

```python theme={null}
BaseWalkForward(
    id: str = None,
    loader_or_data: Callable = <function load_clean_data>,
    timeframe: str = '1d',
    start: str = None,
    end: str = None,
    s1: str = 'BTCUSDT',
    s2: str = 'ETHUSDT',
    suffix: str = 'h5',
    use_close: bool = True,
    freq: str = None,
    signal_model: str = None,
    long_entries: float = nan,
    long_exits: float = nan,
    short_entries: float = nan,
    short_exits: float = nan,
    clean: bool = True,
    select_symbols: str | int | List[str | int] = None,
    portfolio_config: Dict[str, Any] = _Nothing.NOTHING,
    model_params: Dict[str, Any] = _Nothing.NOTHING,
    metrics: str | List[str] = None,
    metrics_kwargs: Dict[str, Any] = _Nothing.NOTHING,
    use_rolling: bool = False,
    storage: str | optuna.storages._base.BaseStorage = None,
    pruner: optuna.pruners._base.BasePruner = <optuna.pruners._successive_halving.SuccessiveHalvingPruner object>,
    sampler: optuna.samplers._base.BaseSampler = <optuna.samplers._tpe.sampler.TPESampler object>,
    study_name: str = None,
    direction: str | List[str] = 'maximize',
    load_if_exists: bool = False,
    n_trials: int = 100,
    n_completed_trials: int = None,
    timeout: float = None,
    n_jobs: int = 1,
    catch: Iterable[Type[Exception]] | Type[Exception] = _Nothing.NOTHING,
    callbacks: Iterable[Callable[[optuna.study.study.Study, optuna.trial._frozen.FrozenTrial], None]] | None = None,
    gc_after_trial: bool = False,
    show_progress_bar: bool = False,
    verbose: bool = True,
    tracker: Type = None,
    model: Any = None,
    preprocess_func: Callable = None,
)
```

Walk-forward base model.

Method generated by attrs for class BaseWalkForward.

### Ancestors

* `abc.ABC`
* `systematica.generic.base.Model`
* `systematica.generic.base.Feature`

### Descendants

* `systematica.walk_forward.cv.WalkForwardCV`
* `systematica.walk_forward.rolling.RollingWalkForward`

### Static methods

#### `from_runner`

```python theme={null}
from_runner(
    runner: systematica.generic.base.Model,
)
```

Create from existing runner instance.

#### `from_dict`

```python theme={null}
from_dict(
    runner_config: Dict[str, Any],
)
```

Create from existing runner instance.

### Instance variables

* `all_portfolio_metrics: List[str]`: Get all available metrics

* `all_metrics: List[str]`: Get all available metrics (delegates to all\_portfolio\_metrics).

* `non_tunable_metrics`:

### Methods

#### `check_is_valid`

```python theme={null}
check_is_valid(
    self,
)
```

Check if model is valid.

#### `get_annualized_return`

```python theme={null}
get_annualized_return(
    self,
) ‑> pandas.core.frame.DataFrame
```

Computes the rolling (annualized) returns.

**Returns**:

| Type           | Description                                      |
| -------------- | ------------------------------------------------ |
| `pd.DataFrame` | DataFrame containing rolling annualized returns. |

#### `get_portfolio_metrics`

```python theme={null}
get_portfolio_metrics(
    self,
    **kwargs,
) ‑> pandas.core.frame.DataFrame | numpy.ndarray
```

Computes portfolio performance metrics for different test sets.

**Parameters**:

| Name     | Type        | Default | Description                               |
| -------- | ----------- | ------- | ----------------------------------------- |
| `kwargs` | `tp.Kwargs` | `--`    | Additional arguments to run the pipeline. |

**Returns**:

| Type                       | Description                                                  |
| -------------------------- | ------------------------------------------------------------ |
| `pd.DataFrame \| tp.Array` | DataFrame or array containing portfolio performance metrics. |

#### `get_portfolio`

```python theme={null}
get_portfolio(
    self,
    signals: systematica.signals.base.Signals,
    data: vectorbtpro.data.base.Data = None,
) ‑> vectorbtpro.portfolio.base.Portfolio
```

Simulate portfolio from signals.

**Parameters**:

| Name               | Type        | Default | Description                                                                                |
| ------------------ | ----------- | ------- | ------------------------------------------------------------------------------------------ |
| `signals`          | `Signals`   | `--`    | Signals used for portfolio simulation.                                                     |
| `data`             | `vbt.Data`  | `None`  | Price data used for portfolio simulation. If `None`, uses `self.data`. Defaults to `None`. |
| `portfolio_config` | `tp.Kwargs` | `--`    | Additional arguments for portfolio simulation.                                             |

**Returns**:

| Type            | Description          |
| --------------- | -------------------- |
| `vbt.Portfolio` | Simulated portfolio. |

#### `set_labels`

```python theme={null}
set_labels(
    self,
    group_by: bool,
    metrics: str | List[str],
) ‑> List[str]
```

Generate column labels for the output DataFrame.

**Parameters**:

| Name       | Type   | Default | Description                         |
| ---------- | ------ | ------- | ----------------------------------- |
| `group_by` | `bool` | `--`    | Whether to group results by symbol. |
| `metrics`  | `str`  | `--`    | List of metrics to compute.         |

**Returns**:

| Type   | Description           |
| ------ | --------------------- |
| `List` | List of column names. |

#### `plot_annualized_return`

```python theme={null}
plot_annualized_return(
    self,
    key: str = 'train',
    fig: vectorbtpro.utils.figure.FigureWidget = None,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
```

Plot annualized returns.

**Parameters**:

| Name            | Type               | Default | Description                                                                     |
| --------------- | ------------------ | ------- | ------------------------------------------------------------------------------- |
| `key`           | `str`              | `test`  | If `train`, extract train-set. If `test`, extract test-set. Defaults to `test`. |
| `fig`           | `vbt.FigureWidget` | `None`  | Existing figure to update.                                                      |
| `layout_kwargs` | `tp.Kwargs`        | `--`    | Additional layout arguments for the plot.                                       |

**Returns**:

| Type               | Description                            |
| ------------------ | -------------------------------------- |
| `vbt.FigureWidget` | Figure with the plotted total returns. |

#### `plot_model_output`

```python theme={null}
plot_model_output(
    self,
    fig: vectorbtpro.utils.figure.FigureWidget = None,
    **layout_kwargs,
) ‑> vectorbtpro.utils.figure.FigureWidget
```

Plots model output over time.

**Parameters**:

| Name            | Type               | Default | Description                               |
| --------------- | ------------------ | ------- | ----------------------------------------- |
| `fig`           | `vbt.FigureWidget` | `None`  | Existing figure to update.                |
| `layout_kwargs` | `tp.Kwargs`        | `--`    | Additional layout arguments for the plot. |

**Returns**:

| Type               | Description                           |
| ------------------ | ------------------------------------- |
| `vbt.FigureWidget` | Figure with the plotted model output. |

#### `plot_portfolio_metrics`

```python theme={null}
plot_portfolio_metrics(
    self,
    metrics: str | List[str] = None,
    metrics_kwargs: Dict[str, Any] = None,
    fig: vectorbtpro.utils.figure.FigureWidget = None,
    layout_kwargs: Dict[str, Any] = None,
    portfolio_config: Dict[str, Any] = None,
) ‑> vectorbtpro.utils.figure.FigureWidget
```

Plot portfolio performance metrics over time.

**Parameters**:

| Name               | Type               | Default | Description                                                                                                   |
| ------------------ | ------------------ | ------- | ------------------------------------------------------------------------------------------------------------- |
| `metrics`          | `str`              | `--`    | \| tp.List\[str], default None Portfolio performance metrics to compute. If `None`, uses the default metrics. |
| `metrics_kwargs`   | `tp.Kwargs`        | `None`  | Additional keyword arguments for the metrics. Defaults to `None`.                                             |
| `fig`              | `vbt.FigureWidget` | `None`  | Existing figure to update. If `None`, a new figure is created. Defaults to `None`.                            |
| `layout_kwargs`    | `dict`             | `None`  | Additional layout arguments for the plot. If `None`, uses default layout settings. Defaults to `None`.        |
| `portfolio_config` | `tp.Kwargs`        | `None`  | Additional arguments for portfolio simulation. Defaults to `None`.                                            |

**Returns**:

| Type               | Description                                            |
| ------------------ | ------------------------------------------------------ |
| `vbt.FigureWidget` | Figure with the plotted portfolio performance metrics. |
