Skip to content

Standard Deviation

STDDEV measures the amount of variation or dispersion of a set of values.

Method

tm.ta.stddev(source, timeperiod, nbdev)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator5
nbdevfloatNumber of deviations for the indicator1

Outputs

OutputType
stddevnp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Standard Deviation
stddev = tm.ta.stddev(data.close, timeperiod=5, nbdev=1)
# Get the last value and print
last_value = stddev.iloc[-1]
tm.log(f"Last value of Standard Deviation is {last_value}")
# Plot the values of stddev
tm.plot(stddev, title="Standard Deviation", overlay=False)