Files
OpenBB/website/content/platform/reference/quantitative/stats/quantile.md

1.8 KiB
Vendored

title, description, keywords
title description keywords
quantile Calculate the quantile of a target column at a specified quantile percentage
quantitative
stats
quantile

import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Calculate the quantile of a target column at a specified quantile percentage.

Quantiles are points dividing the range of a probability distribution into intervals with equal probabilities, or dividing the sample in the same way.

Examples

from openbb import obb
# Get Quantile.
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.quantile(data=returns, target="close", quantile_pct=0.75)
obb.quantitative.stats.quantile(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 the quantile. False
quantile_pct NonNegativeFloat, optional The quantile percentage to calculate (e.g., 0.5 for median), default is 0.5. False

Returns

OBBject
    results : List[Data]
        An object containing the rolling quantile values with the median.