Weighted Moving Average (WMA)
Calculate the Weighted Moving Average (WMA) for a given price series.
The Weighted Moving Average (WMA) is a moving average that assigns a linearly increasing weight to more recent prices, making it more responsive to recent price changes than a Simple Moving Average.
The formula is as follows:
\[\text{WMA} = (\text{Sum of} (\text{Price} \cdot \text{Weight})) / (\text{Sum of Weights})\]Also known as: WMA, linearly weighted moving average.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Weighted Moving Average (WMA) for you. Just ask in plain English.
Calculate the Weighted Moving Average (WMA) in Python
The Weighted Moving Average (WMA) is available in the Technicals module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_weighted_moving_average as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(tickers=["AAPL", "MSFT"])
toolkit.technicals.get_weighted_moving_average()
Which returns:
| Date | AAPL | MSFT | Benchmark |
|---|---|---|---|
| 2026-06-18 | 300.742 | 408.527 | 745.79 |
| 2026-06-22 | 300.078 | 401.871 | 744.779 |
| 2026-06-23 | 298.585 | 397.059 | 742.923 |
| 2026-06-24 | 297.358 | 392.639 | 741.423 |
| 2026-06-25 | 294.781 | 387.266 | 739.795 |
| 2026-06-26 | 293.098 | 384.145 | 739.184 |
| 2026-06-29 | 291.684 | 381.061 | 739.311 |
| 2026-06-30 | 291.599 | 378.891 | 740.005 |
| 2026-07-01 | 291.799 | 377.956 | 741.457 |
| 2026-07-02 | 292.727 | 377.967 | 741.959 |
Parameters
get_weighted_moving_average accepts the following parameters:
- period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
- close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
- window (int, optional): Number of periods to consider for the WMA. The number of periods (time intervals) over which to calculate the WMA.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the WMA. Defaults to False.
- lag (int | list[int], optional): The lag to use for the growth calculation.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.
Related Overlap Indicators
The Technicals module page introduces the module, and the sidebar lists all of its functions.