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

# Nb

> systematica.portfolio.metrics.nb

## `get_total_returns_nb`

```python theme={null}
get_total_returns_nb(
    close: numpy.ndarray,
    sim_out: vectorbtpro.portfolio.enums.SimulationOutput,
)
```

Calculate the total returns.

**Parameters**:

| Name      | Type                | Default | Description                                 |
| --------- | ------------------- | ------- | ------------------------------------------- |
| `close`   | `tp.Array2d`        | `--`    | Array of close prices.                      |
| `sim_out` | `SimulationOutputT` | `--`    | Simulation output containing order records. |

**Returns**:

| Type    | Description    |
| ------- | -------------- |
| `float` | Total returns. |

## `get_expectancy_nb`

```python theme={null}
get_expectancy_nb(
    close: numpy.ndarray,
    sim_out: vectorbtpro.portfolio.enums.SimulationOutput,
)
```

Calculate the expectancy.

**Parameters**:

| Name      | Type                | Default | Description                                 |
| --------- | ------------------- | ------- | ------------------------------------------- |
| `close`   | `tp.Array2d`        | `--`    | Array of close prices.                      |
| `sim_out` | `SimulationOutputT` | `--`    | Simulation output containing order records. |

**Returns**:

| Type    | Description |
| ------- | ----------- |
| `float` | Expectancy. |

## `get_sharpe_nb`

```python theme={null}
get_sharpe_nb(
    close: numpy.ndarray,
    sim_out: <function NamedTuple at 0x104ff8040>,
    ann_factor: int,
) ‑> float
```

Calculate the Sharpe ratio.

<Note>
  Note on `ddof`:

  * Use `ddof=0` for population variance, where you have data for the entire population.
  * Use `ddof=1` for sample variance, to correct for bias when estimating the variance of a population from a sample.
</Note>

**Parameters**:

| Name         | Type            | Default | Description                           |
| ------------ | --------------- | ------- | ------------------------------------- |
| `close`      | `tp.Array2d`    | `--`    | Array of close prices.                |
| `sim_out`    | `tp.NamedTuple` | `--`    | Simulation output containing returns. |
| `ann_factor` | `int`           | `--`    | Annualization factor.                 |

**Returns**:

| Type    | Description   |
| ------- | ------------- |
| `float` | Sharpe ratio. |
