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

I am doing some Pandas exercises and i am stuck in one point:
In the book 'python for data analysis the author says that we can compute a trend signal that simulates our strategy returns buy the sum of the past 'lookback' returns and this is ok, but then, why do we have to shift them, can someone explain me this last shifting?
I am referring to this formula

def trend_signal(rets, lookback, lag):  
    signal = pd.rolling_sum(rets, lookback, min_periods=lookback - 5)  
    return signal.shift(lag)  

where rets are the daily percent returns of SPY

you can llok at the orginal public page here
Thank you!