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

# Twin Spread

> systematica.signals.twin_spread

## `run_twin_spread_nb`

```python theme={null}
run_twin_spread_nb(
    model_output: numpy.ndarray,
    long_entries: float,
    long_exits: float,
    short_entries: float,
    short_exits: float,
    clean: bool = True,
) ‑> systematica.signals.base.Signals
```

Compute trading signals based on a spread strategy.

The function generates long and short entry/exit signals based on two
opposite indicators. It checks the conditions where one asset is up and the other is down
at the same time for initiating positions.

**Parameters**:

| Name            | Type      | Default | Description                                               |
| --------------- | --------- | ------- | --------------------------------------------------------- |
| `model_output`  | `ndarray` | `--`    | A 2d array representing model predictions for two assets. |
| `long_entries`  | `float`   | `--`    | Threshold values for initiating long positions.           |
| `long_exits`    | `float`   | `--`    | Threshold values for exiting long positions.              |
| `short_entries` | `float`   | `--`    | Threshold values for initiating short positions.          |
| `short_exits`   | `float`   | `--`    | Threshold values for exiting short positions.             |
| `clean`         | `bool`    | `to`    | `True` Clean signals. Defaults to `True`.                 |

**Returns**:

| Type      | Description                                                                                                |
| --------- | ---------------------------------------------------------------------------------------------------------- |
| `Signals` | A `Signals` object containing boolean arrays for long entries, long exits, short entries, and short exits. |
