Getting pyfolio input from alphalens

However, pyfolio also integrates with alphalens directly and permits the creation of pyfolio input data using create_pyfolio_input:

from alphalens.performance import create_pyfolio_input

qmin, qmax = factor_data.factor_quantile.min(),
factor_data.factor_quantile.max()
input_data = create_pyfolio_input(alphalens_data,
period='1D',
capital=100000,
long_short=False,
equal_weight=False,
quantiles=[1, 5],
benchmark_period='1D')
returns, positions, benchmark = input_data

There are two options to specify how portfolio weights will be generated: 

  • long_short: If False, weights will correspond to factor values divided by their absolute value so that negative factor values generate short positions. If True, factor values are first demeaned so that long and short positions cancel each other out and the portfolio is market neutral.
  • equal_weight: If True, and long_short is True, assets will be split into two equal-sized groups with the top/bottom half making up long/short positions.

Long-short portfolios can also be created for groups if factor_data includes, for example, sector info for each asset.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.78.95