# What is the difference between Rolling Returns and Moving Average and how to calculate them?

So I understand what a moving average is and how to calculate it. I'm using this numpy function for it.

I am somehow confused about how to calculate rolling returns. Different sites explain it differently, and some conflate the two. After careful digging, however, I think I've understood the following:

n-period Moving Average: is just the average of the last n periods for every period.

n-period Rolling Returns: is just the n-period Moving Average of returns where returns are defined as:

def rolling_returns(positions, n=3):
returns = (positions-positions[0])/positions
return moving_average(returns,n)


Where positions is just a vector/numpy array of our position as a function of time. Am I missing/conflating something? I'm not really sure if this is right. Any help would be appreciated