perf_returns¶
Defined in fynance.features.metrics
- perf_returns(R, kind='raw', base=100., axis=0, dtype=None)[source]
Compute performance of returns along time axis.
- Parameters:
- Rnp.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}}\).
- basefloat, optional
Initial value for measure the performance, default is 100.
- axis{0, 1}, optional
Axis along wich the computation is done. Default is 0.
- dtypenp.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.
See also
perf_index,perf_strat
Examples
>>> R = np.array([0., 20., 30., -10., 20., 20., -20.]) >>> perf_returns(R, base=100.) array([100., 120., 150., 140., 160., 180., 160.])