sma
Calculate the Simple Moving Average (SMA) for a given symbol.
Syntax
Fields
Description
symbol(str)
Symbol to perform calculation on. Defaults to the first symbol in watchlist
period(int)
Period of SMA. Defaults to 14
interval(str)
Interval to perform the calculation. Defaults to interval of algorithm
ref(str)
'close', 'open', 'high', or 'low'. Defaults to 'close'
prices(list)
When specified, this function will use the values provided in the list to perform calculations and ignore other parameters. Defaults to None
def sma(
self,
symbol: str = None,
period: int = 14,
interval: Interval = None,
ref: str = "close",
prices=None,
) -> np.array:
Returns
Returns a NumPy array containing the SMA values.
Raises
- An
Exception
is raised if the calculation fails due to incorrect parameters or data issues.