Hello am doing the Real Estate Analysis in the finanacial analysis with python i have an array of closing prices. Say I want to calculate the simple return: (closing price t+1 - Closing price t )/closing price t.
The code in the example for a function is
def rate_of_return(adj_closings):
daily_simple_ror=np.diff(adj_closings)/adj_closings[:-1]
return daily_simple_ror
I understand the np.diff but i dont seem to get around the adj_closings[:-1] which for me seems to be all the array except the last digit.But the function seems to gather only one value and in the formula (closing price t+1 - Closing price t )/closing price t… it gets the closing price t. Can someone explain me the logic behind it?