Skip to main content

variance

Calculate the variance of a target column.

Variance measures the dispersion of a set of data points around their mean. It is a key metric for assessing the volatility and stability of financial returns or other time series data.

Example​

from openbb import obb

stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()
returns = stock_data["close"].pct_change().dropna()
obb.quantitative.stats.variance(data=returns, target="close")

Parameters​

NameTypeDescriptionDefaultOptional
dataList[Data]The time series data as a list of data points.False
targetstrThe name of the column for which to calculate variance.False

Returns​

OBBject
results : List[Data]
An object containing the rolling variance values.