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

# Pipelines

> systematica.portfolio.pipelines

## `portfolio_pipeline`

```python theme={null}
portfolio_pipeline(
    data: vectorbtpro.data.base.Data,
    s1: str,
    s2: str,
    model_func: Callable,
    signal_func: Callable,
    long_entries: float,
    long_exits: float,
    short_entries: float,
    short_exits: float,
    preprocess_func: Callable = None,
    metrics: str | List[str] = None,
    use_close: bool = True,
    size: float | numpy.ndarray = 50,
    size_type: str | numpy.ndarray = 'valuepercent100',
    allow_partial: float | numpy.ndarray = None,
    fees: float | numpy.ndarray = None,
    fixed_fees: float | numpy.ndarray = None,
    slippage: float | numpy.ndarray = None,
    min_size: float | numpy.ndarray = None,
    max_size: float | numpy.ndarray = None,
    size_granularity: float | numpy.ndarray = None,
    sl_stop: float | numpy.ndarray = None,
    tsl_stop: float | numpy.ndarray = None,
    tp_stop: float | numpy.ndarray = None,
    accumulate: bool | str | numpy.ndarray = None,
    init_cash: float | numpy.ndarray = None,
    cash_sharing: bool = True,
    group_by: bool = True,
    call_seq: str | bool = 'auto',
    fill_pos_info: bool = False,
    log: bool | numpy.ndarray = None,
    portfolio_kwargs: Dict[str, Any] = None,
    **model_params,
) ‑> vectorbtpro.portfolio.base.Portfolio | float | List[float] | pandas.core.series.Series | pandas.core.frame.DataFrame
```

Executes the portfolio pipeline.

**Parameters**:

| Name               | Type          | Default           | Description                                                |
| ------------------ | ------------- | ----------------- | ---------------------------------------------------------- |
| `data`             | `vbt.Data`    | `--`              | The input data.                                            |
| `s1`               | `str`         | `--`              | First symbol.                                              |
| `s2`               | `str`         | `--`              | Second symbol.                                             |
| `model_func`       | `tp.Callable` | `--`              | Function to compute model output.                          |
| `signal_func`      | `tp.Callable` | `--`              | Function to generate signals.                              |
| `long_entries`     | `float`       | `--`              | Long entry signals.                                        |
| `long_exits`       | `float`       | `--`              | Long exit signals.                                         |
| `short_entries`    | `float`       | `--`              | Short entry signals.                                       |
| `short_exits`      | `float`       | `--`              | Short exit signals.                                        |
| `preprocess_func`  | `tp.Callable` | `None`            | Preprocessing function(s) to apply (default is None).      |
| `metrics`          | `str`         | `None`            | Metrics to compute (default is None).                      |
| `use_close`        | `bool`        | `True`            | Whether to use 'Close' prices (default is True).           |
| `size`             | `float`       | `50`              | Size of each order (default is 50).                        |
| `size_type`        | `str`         | `valuepercent100` | Type of size (default is "valuepercent100").               |
| `allow_partial`    | `float`       | `None`            | Whether to allow partial fills (default is None).          |
| `fees`             | `float`       | `None`            | Fees per order (default is None).                          |
| `fixed_fees`       | `float`       | `None`            | Fixed fees per order (default is None).                    |
| `slippage`         | `float`       | `None`            | Slippage per order (default is None).                      |
| `min_size`         | `float`       | `None`            | Minimum size of each order (default is None).              |
| `max_size`         | `float`       | `None`            | Maximum size of each order (default is None).              |
| `size_granularity` | `float`       | `None`            | Granularity of size (default is None).                     |
| `sl_stop`          | `float`       | `None`            | Stop-loss level (default is None).                         |
| `tsl_stop`         | `float`       | `None`            | Trailing stop-loss level (default is None).                |
| `tp_stop`          | `float`       | `None`            | Take-profit level (default is None).                       |
| `accumulate`       | `bool`        | `None`            | Whether to accumulate orders (default is None).            |
| `init_cash`        | `float`       | `None`            | Initial cash (default is None).                            |
| `cash_sharing`     | `bool`        | `True`            | Whether to share cash between assets (default is True).    |
| `group_by`         | `bool`        | `True`            | Whether to group by symbol (default is True).              |
| `call_seq`         | `bool`        | `auto`            | Call sequence (default is "auto").                         |
| `fill_pos_info`    | `bool`        | `False`           | Whether to fill position info (default is False).          |
| `log`              | `bool`        | `None`            | Whether to log orders (default is None).                   |
| `portfolio_kwargs` | `tp.Kwargs`   | `None`            | Additional keyword arguments for the portfolio simulation. |
| `model_params`     | `tp.Kwargs`   | `--`              | Additional parameters for `model_func`.                    |

**Returns**:

| Type                                                         | Description                             |
| ------------------------------------------------------------ | --------------------------------------- |
| `vbt.Portfolio or float or tp.List[float] or tp.SeriesFrame` | The result of the portfolio simulation. |

## `portfolio_pipeline_nb`

```python theme={null}
portfolio_pipeline_nb(
    open: numpy.ndarray,
    high: numpy.ndarray,
    low: numpy.ndarray,
    close: numpy.ndarray,
    preprocess_func_nb: Callable,
    model_func_nb: Callable,
    metrics_func_nb: Callable,
    signal_func_nb: Callable,
    long_entries: float = -1.0,
    long_exits: float = 0.0,
    short_entries: float = 1.0,
    short_exits: float = 0.0,
    size: int | float = 50,
    sl_stop: float = nan,
    tsl_stop: float = nan,
    tp_stop: float = nan,
) ‑> Any
```

Executes the portfolio pipeline.

**Parameters**:

| Name                 | Type          | Default  | Description                                                |
| -------------------- | ------------- | -------- | ---------------------------------------------------------- |
| `open`               | `tp.Array1d`  | `--`     | Open prices.                                               |
| `high`               | `tp.Array1d`  | `--`     | High prices.                                               |
| `low`                | `tp.Array1d`  | `--`     | Low prices.                                                |
| `close`              | `tp.Array1d`  | `--`     | Close prices.                                              |
| `model_func_nb`      | `tp.Callable` | `--`     | Function to compute model output.                          |
| `metrics_func_nb`    | `tp.Callable` | `--`     | Function to compute metrics.                               |
| `signal_func_nb`     | `tp.Callable` | `--`     | Function to generate signals.                              |
| `long_entries`       | `float`       | `-1.0`   | Long entry signals. Defaults to `-1.0`.                    |
| `long_exits`         | `float`       | `0.0`    | Long exit signals. Defaults to `0.0`.                      |
| `short_entries`      | `float`       | `1.0`    | Short entry signals. Defaults to `1.0`.                    |
| `short_exits`        | `float`       | `0.0`    | Short exit signals. Defaults to `0.0`.                     |
| `preprocess_func_nb` | `tp.Callable` | `None`   | Preprocessing function(s) to apply. Defaults to `None`.    |
| `size`               | `int`         | `--`     | or float, default 50 Size of each order. Defaults to `50`. |
| `sl_stop`            | `float`       | `np.nan` | Stop-loss level. Defaults to `np.nan`.                     |
| `tsl_stop`           | `float`       | `np.nan` | Trailing stop-loss level. Defaults to `np.nan`.            |
| `tp_stop`            | `float`       | `np.nan` | Take-profit level. Defaults to `np.nan`.                   |

**Returns**:

| Type     | Description                             |
| -------- | --------------------------------------- |
| `tp.Any` | The result of the portfolio simulation. |
