Skip to content

Latest commit

 

History

History
81 lines (56 loc) · 3.11 KB

File metadata and controls

81 lines (56 loc) · 3.11 KB
title Weighted Moving Average (WMA)
permalink /indicators/Wma/
type moving-average
layout indicator

{{ page.title }}

get_wma(quotes, lookback_periods, candle_part=CandlePart.CLOSE)

Parameters

name type notes
quotes Iterable[Quote] Iterable of the Quote class or its sub-class.
See here for usage with pandas.DataFrame
lookback_periods int Number of periods (N) in the moving average. Must be greater than 0.
candle_part CandlePart, default CandlePart.CLOSE Specify candle part to evaluate. See CandlePart options below.

Historical quotes requirements

You must have at least N periods of quotes to cover the warmup periods.

quotes is an Iterable[Quote] collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

{% include candlepart-options.md %}

Return

WMAResults[WMAResult]
  • This method returns a time series of all available indicator values for the quotes provided.
  • WMAResults is just a list of WMAResult.
  • It always returns the same number of elements as there are in the historical quotes.
  • It does not return a single incremental indicator value.
  • The first N-1 periods will have None values since there's not enough data to calculate.

WMAResult

name type notes
date datetime Date
wma float, Optional Weighted moving average

Utilities

See Utilities and Helpers for more information.

Example

from stock_indicators import indicators
from stock_indicators import CandlePart     # Short path, version >= 0.8.1

# This method is NOT a part of the library.
quotes = get_historical_quotes("SPY")

# Calculate 20-period WMA
results = indicators.get_wma(quotes, 20, CandlePart.CLOSE)

About {{ page.title }}

Weighted Moving Average is the linear weighted average of close price over N lookback periods. This also called Linear Weighted Moving Average (LWMA). [Discuss] 💬

image

Sources