Skip to content

Summation

SUM calculates the sum of values over a specified period.

Method

tm.ta.sum(source, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
sourcepd.SeriesInput data series-
timeperiodintNumber of periods for the indicator30

Outputs

OutputType
sumnp.ndarray

Example usage

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