mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-05 17:01:58 +00:00
1.7 KiB
Vendored
1.7 KiB
Vendored
title, description, keywords
| title | description | keywords | |||
|---|---|---|---|---|---|
| stdev | Calculate the rolling standard deviation of a target column |
|
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Calculate the rolling standard deviation of a target column.
Standard deviation is a measure of the amount of variation or dispersion of a set of values. It is widely used to assess the risk and volatility of financial returns or other time series data It is the square root of the variance.
Examples
from openbb import obb
# Get Standard Deviation.
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.stdev(data=returns, target="close")
obb.quantitative.stats.stdev(target='close', data=[{'date': '2023-01-02', 'close': 0.05}, {'date': '2023-01-03', 'close': 0.08}, {'date': '2023-01-04', 'close': 0.07}, {'date': '2023-01-05', 'close': 0.06}, {'date': '2023-01-06', 'close': 0.06}])
Parameters
| Name | Type | Description | Default | Optional |
|---|---|---|---|---|
| data | List[Data] | The time series data as a list of data points. | False | |
| target | str | The name of the column for which to calculate standard deviation. | False | |
Returns
OBBject
results : List[Data]
An object containing the rolling standard deviation values.