Notebook

Alphalens boilerplate

In [1]:
from quantopian.research import run_pipeline
from quantopian.pipeline import Pipeline
from quantopian.pipeline import factors, filters, classifiers
from quantopian.pipeline.classifiers import Classifier
from quantopian.pipeline.factors import CustomFactor, Returns, AverageDollarVolume, SimpleMovingAverage
from quantopian.pipeline.filters import StaticAssets, Q500US, Q1500US, Q3000US, QTradableStocksUS
from quantopian.pipeline.filters.fundamentals import IsPrimaryShare
from quantopian.pipeline.classifiers.fundamentals import Sector  
from quantopian.pipeline.data.builtin import USEquityPricing

import alphalens
import math
import datetime
import numpy as np
import pandas as pd

## Helper functions

def high_volume_universe(top_liquid):
    """
    Computes a security universe of liquid stocks and filtering out
    hard to trade ones
    Returns
    -------
    high_volume_tradable - zipline.pipeline.filter
    """
    
    if top_liquid == 'QTradableStocksUS':
        universe = QTradableStocksUS()
    elif top_liquid == 500:
        universe = Q500US()
    elif top_liquid == 1500:
        universe = Q1500US()
    elif top_liquid == 3000:
        universe = Q3000US()        
    else:        
        universe = filters.make_us_equity_universe(
            target_size=top_liquid,
            rankby=factors.AverageDollarVolume(window_length=200),
            mask=filters.default_us_equity_universe_mask(),
            groupby=Sector(),
            max_group_weight=0.3,
            smoothing_func=lambda f: f.downsample('month_start'),
        )
       
    return universe

def run_pipeline_chunks(pipe, start_date, end_date, chunks_len = None):
    """
    Drop-in replacement for run_pipeline.
    run_pipeline fails over a very long period of time (memery usage),
    so we need to split in chunks the pipeline and concatenate the results
    """
    chunks  = []
    current = pd.Timestamp(start_date)
    end     = pd.Timestamp(end_date)
    step    = pd.Timedelta(weeks=70) if chunks_len is None else chunks_len
    
    while current <= end:
        
        current_end = current + step
        if current_end > end:
            current_end = end
        
        print 'Running pipeline:', current, ' - ', current_end
        results = run_pipeline(pipe, current.strftime("%Y-%m-%d"), current_end.strftime("%Y-%m-%d"))
        chunks.append(results)
        
        # pipeline returns more days than requested (if no trading day), so get last date from the results
        current_end = results.index.get_level_values(0)[-1].tz_localize(None)
        current = current_end + pd.Timedelta(days=1)

    return pd.concat(chunks)
       
def construct_factor_history(factor_cls, start_date='2015-10-1', end_date='2016-2-1', 
                             factor_name='factor', top_liquid=500,
                             sector_column=None):
    """
    Creates a DataFrame containing daily factor values and sector codes for a liquidity 
    constrained universe. The returned DataFrame is can be used in the factor tear sheet.
    """
    ok_universe = high_volume_universe(top_liquid)
       
    factor = factor_cls(mask=ok_universe)
    sector = Sector(mask=ok_universe)    
       
    pipe = Pipeline()
    pipe.add(factor, factor_name)
    if sector_column is not None:
        pipe.add(sector, sector_column)  
    pipe.set_screen(ok_universe)

    daily_factor = run_pipeline_chunks(pipe, start_date=start_date, end_date=end_date)
    #daily_factor = run_pipeline(pipe, start_date=start_date, end_date=end_date, chunksize=250)
       
    return daily_factor.dropna()

def get_daily_price(sid_universe, start_date, end_date, extra_days_before=0, extra_days_after=0):
    """
    Creates a DataFrame containing daily percentage returns and price
    """   
    extra_days = math.ceil(extra_days_before * 365.0/252.0) + 3 # just to be sure
    start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d") - datetime.timedelta(days=extra_days)
    start_date = start_date.strftime("%Y-%m-%d")
    
    extra_days = math.ceil(extra_days_after * 365.0/252.0) + 3 # just to be sure
    end_date = datetime.datetime.strptime(end_date, "%Y-%m-%d") + datetime.timedelta(days=extra_days)
    end_date = end_date.strftime("%Y-%m-%d")
    
    pricing = get_pricing(sid_universe, start_date=start_date, end_date=end_date, fields='open_price')
    
    return pricing

#
# 'run_tear_sheet' glues all the function together to make life easier to run the tear sheet on a pipeline factor
#

def run_tear_sheet(factor,
                   factor_name,
                   start_date,
                   end_date,
                   top_liquid,
                   show_sector_plots,
                   avgretplot,
                   periods,
                   quantiles,
                   bins,
                   filter_zscore,
                   long_short,
                   group_neutral,
                   prices_cache = None):
     
    sector_column = 'sector_code' if (show_sector_plots or group_neutral) else None
    days_before, days_after = (0,0)

    if avgretplot is not None:   
        days_before, days_after = avgretplot
        days_after = max(days_after, max(periods) + 1)
    
    #
    ## Run the Pipeline
    #
    print 'construct factor history'
    factor = construct_factor_history(factor, start_date=start_date, end_date=end_date, 
                                      factor_name=factor_name, top_liquid=top_liquid,
                                      sector_column=sector_column)
    #
    ## Get prices
    #
    sid_universe = set( factor.index.levels[1].unique() )
    if prices_cache is not None:
        cached_sids = set(prices_cache.columns)
        sid_universe -= cached_sids
        
    print 'Get pricing for %d entries' % len(sid_universe)
    if sid_universe:
        prices = get_daily_price(sid_universe, start_date=start_date, end_date=end_date, 
                                 extra_days_before=days_before, extra_days_after=days_after)
        if prices_cache is not None:
            prices = pd.concat([prices, prices_cache], axis=1)
    else:
        prices = prices_cache

    #
    ## Use Alphalens to create a factor tear sheet
    #
    print 'Alphalens'
    
    if len(np.isinf(factor[factor_name])) > 0:
        print 'Dropping inf or -inf values from factor'
        factor[factor_name] = factor[factor_name].replace([np.inf, -np.inf], np.nan)

    sector_labels = dict(Sector.SECTOR_NAMES)
    sector_labels[-1] = "Unknown" # no dataset is perfect, better handle the unexpected

    sectors_series = factor[sector_column] if sector_column is not None else None
    factor_data = alphalens.utils.get_clean_factor_and_forward_returns(factor=factor[factor_name],
                                                                       prices=prices,
                                                                       groupby=sectors_series,
                                                                       binning_by_group=group_neutral,
                                                                       quantiles=quantiles,
                                                                       bins=bins,
                                                                       periods=periods,
                                                                       filter_zscore=filter_zscore,
                                                                       groupby_labels=sector_labels,
                                                                       max_loss=0.35)

    if avgretplot:
        alphalens.tears.create_event_returns_tear_sheet(factor_data=factor_data,
                                                        prices=prices,
                                                        avgretplot=avgretplot,
                                                        long_short=long_short,
                                                        group_neutral=group_neutral,
                                                        std_bar=False,
                                                        by_group=show_sector_plots)

    alphalens.tears.create_returns_tear_sheet(factor_data=factor_data,
                                              long_short=long_short,
                                              group_neutral=group_neutral,
                                              by_group=show_sector_plots)
 
    return prices

Define our factor

In [2]:
import statsmodels.api as sm

from sklearn.decomposition import PCA
#from sklearn.decomposition import FastICA as PCA
        

def _get_residuals(data, factors):
    model = sm.OLS(data, factors).fit()
    return model.resid

def get_PCA_regressions(data, n_components=3):
    pca = PCA(n_components=n_components)
    pca.fit(data)
    factors = pca.transform(data)
    # calculate regression residuals
    factors = sm.add_constant(factors)
    resids = np.apply_along_axis(_get_residuals, 0, data, factors)
    return resids

class PCAregress(CustomFactor):  
    #inputs = [Returns, LogReturns, USEquityPricing.close ...]  
    params = ('n_components', 'variable_components', )
    window_safe = True
    
    def compute(self, today, assets, out, returns, n_components, variable_components):
        try:
            if variable_components is not None:
                n_components = len(assets) / variable_components
                if n_components <= 0: n_components = 1
            returns = np.nan_to_num(returns)
            resids = get_PCA_regressions(returns, n_components)
            zscores = (resids - resids.mean()) / resids.std()
            zscores = zscores[-1]
            out[:] = -zscores
        except Exception:
            out[:] = 0.

class JoinFactors(CustomFactor):
    #inputs = [factor1, factor2, ...]
    window_length = 1
    
    def compute(self, today, assets, out, *inputs):
        array = np.concatenate(inputs, axis=0)
        out[:] = np.nansum(array, axis=0)
        out[ np.all(np.isnan(array), axis=0) ] = np.nan

def make_PCA_factor(mask, window_length, n_components, variable_components=None):
    PCAs = []
    returns = Returns(window_length=2, mask=mask)
    sector = Sector(mask=mask)    
    for sector_code in Sector.SECTOR_NAMES.keys():
        sector_mask = sector.eq(sector_code)
        pca = PCAregress(mask=sector_mask, inputs=[returns],
                         window_length=window_length,
                         n_components=n_components,
                         variable_components=variable_components)
        PCAs.append(pca)
    return JoinFactors(mask=mask, inputs=PCAs)

Define settings

In [3]:
factor_name = 'factor'

start_date  = '2005-01-01'
#start_date  = '2015-12-01'
end_date    = '2016-01-01'
top_liquid  = 'QTradableStocksUS'
show_sector_plots = False

# alphalens specific
periods = (1, 3, 5, 7, 12, 20)
quantiles = 7
bins      = None
avgretplot  = (0, 20)  # use None to avoid plotting or (days_before, days_after)
filter_zscore = None
long_short  = True
group_neutral = True

prices_cache = None # this saves lots of time when running tear sheet multiple times

Run the tear sheet

In [4]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=30, n_components=0.90)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 4025 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f74c3b62bd0>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.008 0.003 0.002 0.002 0.003 0.002
beta 0.004 0.009 0.009 0.009 0.004 0.004
Mean Period Wise Return Top Quantile (bps) 0.556 -0.052 -0.052 -0.026 -0.025 -0.110
Mean Period Wise Return Bottom Quantile (bps) -0.778 -0.411 -0.295 -0.339 -0.298 -0.322
Mean Period Wise Spread (bps) 1.207 0.305 0.220 0.300 0.269 0.206
<matplotlib.figure.Figure at 0x7f74ca17cbd0>
In [5]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=75, n_components=0.90)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 0 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f74c3b6e690>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.010 0.007 0.005 0.004 0.004 0.004
beta 0.005 0.006 0.006 0.006 0.005 0.006
Mean Period Wise Return Top Quantile (bps) 0.618 0.375 0.222 0.129 0.139 0.116
Mean Period Wise Return Bottom Quantile (bps) -1.237 -0.718 -0.439 -0.400 -0.287 -0.231
Mean Period Wise Spread (bps) 1.733 1.025 0.634 0.526 0.426 0.347
<matplotlib.figure.Figure at 0x7f74ca72ef90>
In [ ]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=150, n_components=0.90)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 0 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f740fadaf90>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.012 0.008 0.006 0.005 0.005 0.004
beta 0.004 0.006 0.008 0.006 0.006 0.006
Mean Period Wise Return Top Quantile (bps) 1.121 0.607 0.500 0.378 0.311 0.269
Mean Period Wise Return Bottom Quantile (bps) -1.155 -0.596 -0.354 -0.283 -0.244 -0.196
Mean Period Wise Spread (bps) 2.149 1.140 0.836 0.664 0.570 0.477
<matplotlib.figure.Figure at 0x7f74bdfc5f90>
In [4]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=252, n_components=0.90)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 4025 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f9ea4716b10>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.016 0.012 0.009 0.007 0.006 0.004
beta 0.004 0.006 0.010 0.009 0.008 0.007
Mean Period Wise Return Top Quantile (bps) 1.282 0.655 0.490 0.422 0.393 0.321
Mean Period Wise Return Bottom Quantile (bps) -1.125 -0.567 -0.359 -0.326 -0.278 -0.171
Mean Period Wise Spread (bps) 2.274 1.187 0.848 0.756 0.689 0.508
<matplotlib.figure.Figure at 0x7f9e911f4fd0>
In [5]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=252, n_components=0.80)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 0 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f9de2be7c90>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.013 0.010 0.008 0.007 0.006 0.005
beta 0.007 0.011 0.013 0.012 0.010 0.010
Mean Period Wise Return Top Quantile (bps) 1.222 0.658 0.520 0.390 0.346 0.273
Mean Period Wise Return Bottom Quantile (bps) -1.448 -0.851 -0.719 -0.553 -0.456 -0.343
Mean Period Wise Spread (bps) 2.524 1.469 1.236 0.962 0.822 0.637
<matplotlib.figure.Figure at 0x7f9e98835c50>
In [6]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=252, n_components=0.60)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 0 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f9de6921810>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.011 0.007 0.007 0.007 0.007 0.005
beta 0.016 0.021 0.022 0.019 0.014 0.010
Mean Period Wise Return Top Quantile (bps) 1.336 0.792 0.520 0.370 0.215 0.130
Mean Period Wise Return Bottom Quantile (bps) -1.853 -1.141 -1.167 -1.005 -0.797 -0.629
Mean Period Wise Spread (bps) 2.979 1.855 1.664 1.379 1.012 0.763
<matplotlib.figure.Figure at 0x7f9e86c09b50>
In [7]:
def factor(mask):
    return make_PCA_factor(mask=mask, window_length=252, n_components=3)

prices_cache = \
run_tear_sheet( factor       = factor,
                factor_name  = factor_name,
                start_date   = start_date,
                end_date     = end_date,
                top_liquid   = top_liquid,
                show_sector_plots = show_sector_plots,
                avgretplot   = avgretplot,               
                periods      = periods,
                quantiles    = quantiles,
                bins         = bins,
                filter_zscore = filter_zscore,
                long_short   = long_short,
                group_neutral = group_neutral,
                prices_cache = prices_cache)
construct factor history
Running pipeline: 2005-01-01 00:00:00  -  2006-05-06 00:00:00
Running pipeline: 2006-05-09 00:00:00  -  2007-09-11 00:00:00
Running pipeline: 2007-09-12 00:00:00  -  2009-01-14 00:00:00
Running pipeline: 2009-01-15 00:00:00  -  2010-05-20 00:00:00
Running pipeline: 2010-05-21 00:00:00  -  2011-09-23 00:00:00
Running pipeline: 2011-09-24 00:00:00  -  2013-01-26 00:00:00
Running pipeline: 2013-01-29 00:00:00  -  2014-06-03 00:00:00
Running pipeline: 2014-06-04 00:00:00  -  2015-10-07 00:00:00
Running pipeline: 2015-10-08 00:00:00  -  2016-01-01 00:00:00
Get pricing for 0 entries
Alphalens
Dropping inf or -inf values from factor
Dropped 0.2% entries from factor data: 0.2% in forward returns computation and 0.0% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
max_loss is 35.0%, not exceeded: OK!
<matplotlib.figure.Figure at 0x7f9e9d328c10>
Returns Analysis
1D 3D 5D 8D 13D 21D
Ann. alpha 0.008 0.008 0.008 0.008 0.008 0.006
beta 0.019 0.026 0.027 0.023 0.015 0.012
Mean Period Wise Return Top Quantile (bps) 0.946 0.669 0.524 0.389 0.246 0.142
Mean Period Wise Return Bottom Quantile (bps) -1.704 -1.343 -1.243 -1.041 -0.908 -0.815
Mean Period Wise Spread (bps) 2.460 1.935 1.739 1.436 1.156 0.961
<matplotlib.figure.Figure at 0x7f9ea62db550>