fynance.features.metrics.perf_strat¶
-
fynance.features.metrics.
perf_strat
(X, S=None, base=100.0, axis=0, dtype=None, reinvest=False)¶ Compute the performance of strategies for each X’ series.
With respect to this underlying and signal series along time axis.
Parameters: - X : np.ndarray[dtype, ndim=1 or 2]
Time-series of prices or index values.
- S : np.ndarray[dtype, ndim=1 or 2]
Time-series of signals, if None considering a long only position.
S
array must have the same shape thanX
. Default is None.- base : float, optional
Initial value for measure the performance, default is 100.
- reinvest : bool, optional
- If True, then reinvest profit to compute the performance.
- Otherwise (default), compute the performance without reinvesting.
- 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.
See also
Examples
>>> X = np.array([10., 12., 15., 14., 16., 18., 16.]) >>> S = np.array([1., 1., 1., 0., 1., 1., -1.]) >>> perf_strat(X, S, base=100.) array([100., 120., 150., 150., 170., 190., 210.]) >>> perf_strat(X, S, base=100., reinvest=True) array([100. , 120. , 150. , 150. , 171.42857143, 192.85714286, 214.28571429])