When I output the stock data to the framework from Yahoo, I want to be able to calculate the average value for 5 days, excluding the current date.
Is there a way to use a moving average with an offset? For example, a 5-day average that excludes the current day and is based on the previous 5 days.
When I run the following code
r = DataReader("BBRY", "yahoo", '2015-01-01','2015-01-31')
r['ADV']=pd.rolling_mean(r['Volume'], window=5)
It returns a 5-day volume, including the current date, so when you look below, 1/8 has an average volume of 1 / 2.1 / 5.1 / 6.1 / 7 and 1/8. I would like 1/9 to be the first date that returns the average volume, and it contains data from 1 / 2,1 / 5,1 / 6,1 / 7 and 1/8.
Date Open High Low Close Volume Adj Close Symbol ADV
1/2/2015 11.01 11.11 10.79 10.82 9733200 10.82 BBRY
1/5/2015 10.6 10.77 10.37 10.76 12318100 10.76 BBRY
1/6/2015 10.8 10.85 10.44 10.62 10176400 10.62 BBRY
1/7/2015 10.65 10.8 10.48 10.67 10277400 10.67 BBRY
1/8/2015 10.75 10.78 10.57 10.63 6868300 10.63 BBRY 9,874,680.00
1/9/2015 10.59 10.65 10.28 10.38 7745600 10.38 BBRY 9,477,160.00
thanks for the help