Пример #1
0
    def alpha(self, factor_returns, risk_free=0.):
        """Annualized alpha.

        Args:
            factor_returns (array_like): Benchmark return to compare returns against. Will broadcast.
            risk_free (float or array_like): Constant risk-free return throughout the period."""
        factor_returns = reshape_fns.broadcast_to(
            reshape_fns.to_2d(factor_returns, raw=True),
            reshape_fns.to_2d(self._obj, raw=True))
        risk_free = np.broadcast_to(risk_free, (len(self.columns),))
        return self.wrap_reduced(nb.alpha_nb(self.to_2d_array(), factor_returns, self.ann_factor, risk_free))
Пример #2
0
    def alpha(self, benchmark_rets, risk_free=0., wrap_kwargs=None):
        """Annualized alpha.

        Args:
            benchmark_rets (array_like): Benchmark return to compare returns against. Will broadcast.
            risk_free (float or array_like): Constant risk-free return throughout the period."""
        benchmark_rets = reshape_fns.broadcast_to(
            reshape_fns.to_2d(benchmark_rets, raw=True),
            reshape_fns.to_2d(self._obj, raw=True))
        wrap_kwargs = merge_dicts(dict(name_or_index='alpha'), wrap_kwargs)
        return self.wrapper.wrap_reduced(nb.alpha_nb(
            self.to_2d_array(), benchmark_rets, self.ann_factor, risk_free
        ), **wrap_kwargs)
Пример #3
0
    def alpha(self,
              benchmark_rets: tp.ArrayLike,
              risk_free: float = 0.,
              wrap_kwargs: tp.KwargsLike = None) -> tp.MaybeSeries:
        """Annualized alpha.

        Args:
            benchmark_rets (array_like): Benchmark return to compare returns against. Will broadcast.
            risk_free (float): Constant risk-free return throughout the period."""
        benchmark_rets = broadcast_to(to_2d(benchmark_rets, raw=True),
                                      to_2d(self._obj, raw=True))
        result = nb.alpha_nb(self.to_2d_array(), benchmark_rets,
                             self.ann_factor, risk_free)
        wrap_kwargs = merge_dicts(dict(name_or_index='alpha'), wrap_kwargs)
        return self.wrapper.wrap_reduced(result, **wrap_kwargs)