I am building a simple stock model with Pandas and part of that is calculating moving averages.
I would like to understand what are and how to measure accuracy implications of using strict vs dynamic time window size when calculating long-term moving averages.
Here is an example what I mean:
I have a csv file with TLSA stock history between 1.1.2000 - 28.2.2017
df = pd.read_csv('TSLA.csv', index_col=0, parse_dates=True) # add new col to dataframe consisting of a 100 day moving avarage df['100ma'] = df['Adj Close'].rolling(window=100, min_periods=0).mean()
min_periods=0 allows me to calculate moving average for the first 100 days where don't have 100 days using first 0, 1, 2, 3... moving average.
My alternative to this is call
df.dropna() it would drop first 100 rows that don't have a 100-day moving average. Downside I would have exact average but fewer data points.
I am building a tool using a large number of moving averages. What would be a correct method to figure which data frame to use? Correlation to a moving average of a representing stock index? Also which technique is usually applied in the quant world?
Intuitively I think dynamic version is more representing but is that true also with minute and shorter timeframe data?