Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Seeking Help in Mean Reversion on Futures

Hi guys, currently I am studying this lecture : Quantopian Lecture Series: Mean Reversion on Futures

I clone the algorithm in the lecture, and start to perform backtesting. Everything run perfectly, until I changed some code from :

context.futures_pairs = [  
        (  
            continuous_future(  
                'LC',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
            continuous_future(  
                'FC',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
        ),  
        (  
            continuous_future(  
                'CL',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
            continuous_future(  
                'XB',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
        ),  
        (  
            continuous_future(  
                'SM',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
            continuous_future(  
                'BO',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
        ),  
    ]  

to :

context.futures_pairs = [  
        (  
            continuous_future(  
                'SM',                                                             //here is what I changed, from LC -> SM  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
            continuous_future(  
                'GC',                                                         //here is what I changed, from FC -> GC  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
        ),  
        (  
            continuous_future(  
                'CL',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
            continuous_future(  
                'XB',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
        ),  
        (  
            continuous_future(  
                'SM',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
            continuous_future(  
                'BO',  
                offset=month_idx,  
                roll='calendar',  
                adjustment='mul',  
            ),  
        ),  
    ]  

It raises an error : ValueError: shapes (62,2) and (62,2) not aligned: 2 (dim 1) != 62 (dim 0) There was a runtime error on line 97.

Line 97 is : pvalue = coint(Y, X)[1]

I am confused about why there is an error. Can anyone explain it with example ?

Thank you.