Variance
VAR calculates the statistical variance of a set of values.
Method
tm.ta.var(source, timeperiod, nbdev)
Inputs
Parameter | Argument type | Description | Default Value |
---|---|---|---|
source | pd.Series | Input data series | - |
timeperiod | int | Number of periods for the indicator | 5 |
nbdev | float | Number of deviations for the indicator | 1 |
Outputs
Output | Type |
---|---|
var | np.ndarray |
Example usage
import tradomate as tm
@tm.strategy()def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Variance var = tm.ta.var(data.close, timeperiod=5, nbdev=1)
# Get the last value and print last_value = var.iloc[-1] tm.log(f"Last value of Variance is {last_value}")
# Plot the values of var tm.plot(var, title="Variance", overlay=False)