Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Alphalens template?

Is there an Alphalens template? Specifically, I'm interested in the running the style factors in the Q risk model, using the QTradableStocksUS (QTU) and running as far back as the data would allow (I guess this requires running Pipeline in chunks).

If someone could provide a working, up-to-date template, it would be most appreciated.

I'd also like to run Alphalens on my contest algo factors, which are Pipeline-based, so I should be able to plug them into the same template.

10 responses

One Notebook, Grant that Luca posted to share his study on technical indicators may be of interest to you?

I found the study fascinating, eg. IchimokuKinkoHyo, FastStochasticOscillator, AnnualizedVolatility - a head start for you to add RSI/short_term_reversal, momentum and the Q Risk Model factors?

There is also a study by Luca on the cumulative returns of the risk factors in 11 sectors and 5 styles in the Q Risk Model.

Hope this helps. Keen to see your findings.

Thanks. Will take a look as time allows. If you learn anything more about the risk model factors, please let me know. I guess they are built-in Pipeline factors, but were released under quantopian.pipeline.experimental. They are the same as in quantopian.pipeline.factors described here, I suppose.

Thanks Luca, when I try to run it, I get:

In [4]: 

    prices_cache, factor, factor_data = \

    run_tear_sheet( factor       = -Momentum,

                    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)


TypeErrorTraceback (most recent call last)  
<ipython-input-4-43b7d72b8ee4> in <module>()  
----> 1 prices_cache, factor, factor_data =     run_tear_sheet( factor       = -Momentum,  
      2                     factor_name  = factor_name,  
      3                     start_date   = start_date,  
      4                     end_date     = end_date,  
      5                     top_liquid   = top_liquid,

TypeError: bad operand type for unary -: 'ABCMeta'

Here is an updated NB

Here's the whole enchilada from Luca--thanks! Interpretations? My working hypothesis is that the Quantopian style risk factors are weakly predictive, at best, and just noise, worst-case. As "common" factors, they would have had the life sucked out of them a long time ago. But I could be wrong.

EDIT - TO DO: Note, this should be run as far back as the data will support. The time frame is too limited, at this point.

@ Luca -

I'm trying:

start_date  = '2006-01-01'  
end_date    = '2018-06-01'  

Seems to be hanging, but maybe I just need to be patient. How many years would you expect it to handle?

No limits Grant, the line

daily_factor = run_pipeline(pipe, start_date=start_date, end_date=end_date, chunksize=250)  

set the chunk size to 250 days so it shouldn't run out of memory. I successfully ran it many times with 15 years of data

Thanks Luca. It does run, although slowly. Q engineering needs to shovel a bit more coal into the firebox.

By the way, will a notebook keep running in the background? Or do I need to keep it open in the browser?

Finally got it to run. I used:

start_date  = '2016-03-08'  
end_date    = '2018-06-04'  

These dates cover the current contest.

At a high level, is there a conventional pass-fail for assessing factors? For example, a 95% confidence level that a given factor is predictive?

Basic fund template alphalens