sigmaquant.performance.returns.cum_returns#

sigmaquant.performance.returns.cum_returns(returns, kind='simple', starting_value=0.0)#

Compute cumulative performance over time.

This function transforms a sequence of returns or profit-and-loss (PnL) values into a cumulative performance series. The aggregation method depends on the selected kind parameter.

Parameters:
  • returns (array-like) –

    Input sequence of returns or PnL values. The interpretation of the input depends on the kind parameter.

    This is typically a one-dimensional array-like object such as a numpy.ndarray or pandas.Series.

  • kind ({"simple", "pnl", "log"}, optional) –

    Type of input values.

    • "simple": simple (decimal) returns, compounded multiplicatively

    • "log": log-returns, aggregated additively

    • "pnl": additive profit-and-loss values

  • starting_value (float, optional) – Initial cumulative level.

Returns:

Cumulative performance series. The output type matches the input type when possible.

Return type:

pandas.Series or numpy.ndarray

Notes

For simple returns, cumulative performance is computed using multiplicative compounding:

\[R_t = \prod_{i=1}^{t} (1 + r_i) - 1\]

For log-returns and PnL values, cumulative performance is computed using an additive aggregation:

\[R_t = \sum_{i=1}^{t} r_i\]

Missing values (NaNs) in the input series are treated as zeros prior to aggregation.