Building a Five-Month Moving Average from Daily Stock Data
Summary
A user asks how to calculate a five-month moving average for closing prices in a stock-factor table. The discussion contrasts a daily moving-average function, which accepts a number of observations, with a monthly average, which requires monthly data rather than simply using the number five on daily prices. The reply recommends grouping the data by month to construct monthly bars, then calculating the desired average from that monthly series.
For someone unfamiliar with SQL, the response suggests processing daily data with pandas and mentions an AI assistant as a way to help with monthly aggregation. The exchange provides no example query, pandas implementation, definition of which monthly price to average, or validation of the resulting series. Those details need to be decided and checked for the intended use, including whether the monthly observation should use a close or another price field.
Key ideas
- A five-period daily average and a five-month average use different observation intervals.
- Create a monthly time series by grouping daily records by month before computing a monthly moving average.
- Pandas can be used to aggregate daily price data when SQL is unfamiliar.
- The discussion does not specify the monthly price field or provide implementation details.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.