Skip to content

Time Series Forecast

TSF predicts future values based on linear regression.

Method

tm.ta.tsf(source, timeperiod)

Inputs

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

Outputs

OutputType
tsfnp.ndarray

Example usage

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