From 5fc61d72fd56cb421b060c76fb80a038ddb648e8 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Sun, 19 Feb 2023 21:34:51 -0800 Subject: [PATCH] ehances error handling - quantiles can be 0-1 or 0-100 --- .../technical_analysis/volatility_model.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/openbb_terminal/common/technical_analysis/volatility_model.py b/openbb_terminal/common/technical_analysis/volatility_model.py index 7905d57f4cf..df64e99739e 100644 --- a/openbb_terminal/common/technical_analysis/volatility_model.py +++ b/openbb_terminal/common/technical_analysis/volatility_model.py @@ -186,21 +186,25 @@ def rvol( Returns ------- - pd.DataFrame: rvol_cones + pd.DataFrame: rvol DataFrame of realized volatility quantiles. Examples -------- - df = get_rvol_cones(symbol = "AAPL") + df = rvol(symbol = "AAPL") - df = get_rvol_cones(symbol = "AAPL", lower_q = 0.10, upper_q = 0.90) + df = rvol(symbol = "AAPL", lower_q = 0.10, upper_q = 0.90) """ + if lower_q > 1: + lower_q = lower_q/100 + if upper_q > 1: + upper_q = upper_q/100 + lower_q_label = str((int(lower_q*100))) upper_q_label = str((int(upper_q*100))) - - rvol_cones: DataFrame = pd.DataFrame() + rvol_cones: pd.DataFrame = pd.DataFrame() quantiles = [lower_q, upper_q] - windows = [3,10,30,60,90,120,150,180,210,240] + windows = [3,10,30,60,90,120,150,180,210,240,300,360] data = data min_ = [] max_ = [] @@ -208,8 +212,7 @@ def rvol( top_q = [] bottom_q = [] realized = [] - data.index = data.index.date - data = pd.DataFrame(data).sort_index(ascending = False) + data = data.sort_index(ascending = False) def realized_vol(data, window=30): """Helper function for calculating realized volatility."""