Skip to main content

wma

Calculate the Weighted Moving Average (WMA).

A Weighted Moving Average puts more weight on recent data and less on past data. This is done by multiplying each bar's price by a weighting factor. Because of its unique calculation, WMA will follow prices more closely than a corresponding Simple Moving Average.

Example​

from openbb import obb

stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')
wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)

Parameters​

NameTypeDescriptionDefaultOptional
dataList[Data]The data to use for the calculation.False
targetstrTarget column name.closeFalse
indexstrIndex column name to use with data, by default "date".dateFalse
lengthintThe length of the WMA, by default 50.50False
offsetintThe offset of the WMA, by default 0.0False

Returns​

OBBject
results : List[Data]
The WMA data.