Skip to content

Beta

BETA measures the volatility of a security compared to a market index.

tm.ta.beta(source_high, source_low, timeperiod)
ParameterArgument typeDescriptionDefault Value
source_highpd.SeriesHigh prices series-
source_lowpd.SeriesLow prices series-
timeperiodintNumber of periods for the indicator5
OutputType
betanp.ndarray
strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Beta
beta = tm.ta.beta(data.high, data.low, timeperiod=5)
# Get the last value and print
last_value = beta.iloc[-1]
tm.log(f"Last value of Beta is {last_value}")
# Plot the values of beta
tm.plot(beta, title="Beta", overlay=False)