Back to Community
multi-factor example algo

Any suggestions for improving the basic framework?

Clone Algorithm
5
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5b37d4528890c042f2fb718a
There was a runtime error.
3 responses

@Grant,
Looks good to me...is clean...and is pretty much the overall structure we are using. Thanks for publishing your template!

The only thing I'd add is an enhancement to do everything you are doing, but inside sectors or other types of clusters, on the hope that would allow a focus more on signal and less on noise. Grouping smaller amounts of assets together that have a common thread will allow for an overall reduction of computational power needed to use more sophisticated factor computations.

The economic thesis that I see here is an implicit assumption that your combined alpha factor uses top vs. bottom assets as an arbitrage that produces positive alpha over all time and all conditions. Even with sector/cluster confinement, this is a tall task.
We've been looking at getting arbitrage inside sectors/clusters, with more risk_on/risk_off regime signals.
No overall success yet...of course, as soon as we get success, we'll go dark!...grin...
alan

Thanks Alan -

I suppose you are saying run the factors independently on each of the 11 risk model sectors (see https://www.quantopian.com/papers/risk), using Pipeline masking?

For example, my first factor would be:

    combined_alpha_materials = None  
    for name, f in factors.iteritems():  
        if combined_alpha_materials == None:  
            combined_alpha_materials = f(mask=universe_materials)  
        else:  
            combined_alpha_materials += f(mask=universe_materials)  

Would I then sum over all 11 combined_alpha terms, yielding the final combined_alpha?

And then apply:

    longs = combined_alpha.top(NUM_LONG_POSITIONS)  
    shorts = combined_alpha.bottom(NUM_SHORT_POSITIONS)  
    long_short_screen = (longs | shorts)  
    pipe = Pipeline(columns = {  
        'combined_alpha':combined_alpha,  
    },  
    screen = long_short_screen)  
    return pipe  

Sounds relatively straightforward to code.

One thought would be to use the sector ETFs for volatility weighting of the factors.

Any that are importable can be experimented with like this

from quantopian.pipeline.experimental import BasicMaterials, CommunicationServices, ConsumerCyclical, ConsumerDefensive, Energy, FinancialServices, HealthCare, Industrials, Momentum, RealEstate, ShortTermReversal, Size, Technology, Utilities, Value, Volatility

                                      # alone but only one week just for illustration  
    bmt = BasicMaterials()            # -  .14  
    com = CommunicationServices()     # - 1.1  
    cyc = ConsumerCyclical()          # - 1.5  
    cdf = ConsumerDefensive()         #   2.5  
    eng = Energy()                    #    .48  
    fin = FinancialServices()         # - 1.2  
    hlt = HealthCare()                # - .46  
    ind = Industrials()               # - .72  
    mom = Momentum()                  # -1.16  
    rst = RealEstate()                #   .86  
    siz = Size()                      #   .02  
    srv = ShortTermReversal()         # - .25  
    tec = Technology()                # -1.1  
    utl = Utilities()                 #  1.1  
    val = Value()                     #   .64  
    vlt = Volatility()                # -1.2  
Clone Algorithm
7
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5b3acd2ed273fb448941d682
There was a runtime error.