Previous topic

fynance.features.metrics.perf_index

Next topic

fynance.features.metrics.perf_strat

fynance.features.metrics.perf_returns

fynance.features.metrics.perf_returns(R, kind='raw', base=100.0, axis=0, dtype=None)

Compute performance of returns along time axis.

Parameters:
R : np.ndarray[dtype, ndim=1 or 2]

Time-series of returns.

kind : {‘raw’, ‘log’, ‘pct’}
  • If ‘raw’ (default), then considers returns as following \(R_t = X_t - X_{t-1}\).
  • If ‘log’, then considers returns as following \(R_t = log(\frac{X_t}{X_{t-1}})\).
  • If ‘pct’, then considers returns as following \(R_t = \frac{X_t - X_{t-1}}{X_{t-1}}\).
base : float, optional

Initial value for measure the performance, default is 100.

axis : {0, 1}, optional

Axis along wich the computation is done. Default is 0.

dtype : np.dtype, optional

The type of the output array. If dtype is not given, infer the data type from X input.

Returns:
np.ndarray[dtype, ndim=1 or 2]

Performances along time axis.

Examples

>>> R = np.array([0., 20., 30., -10., 20., 20., -20.])
>>> perf_returns(R, base=100.)
array([100., 120., 150., 140., 160., 180., 160.])