From fc66bd7ff8d94ec4264844da4610fe0bc09bdc9c Mon Sep 17 00:00:00 2001 From: clairericks <125876072+clairericks@users.noreply.github.com> Date: Mon, 24 Apr 2023 13:44:36 +0100 Subject: [PATCH] Fix stocks/ta/fib datetime plotting (#4875) --- .../common/technical_analysis/custom_indicators_model.py | 4 ++-- .../core/plots/plotly_ta/plugins/custom_indicators_plugin.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openbb_terminal/common/technical_analysis/custom_indicators_model.py b/openbb_terminal/common/technical_analysis/custom_indicators_model.py index b7fc5ace265..6846ba9159e 100644 --- a/openbb_terminal/common/technical_analysis/custom_indicators_model.py +++ b/openbb_terminal/common/technical_analysis/custom_indicators_model.py @@ -51,12 +51,12 @@ def calculate_fib_levels( return pd.DataFrame(), pd.Timestamp(), pd.Timestamp(), 0, 0, "" if start_date and end_date: if start_date not in data.index: - date0 = data.index[data.index.get_loc(start_date, method="nearest")] + date0 = data.index[data.index.get_indexer([end_date], method="nearest")[0]] console.print(f"Start date not in data. Using nearest: {date0}") else: date0 = start_date if end_date not in data.index: - date1 = data.index[data.index.get_loc(end_date, method="nearest")] + date1 = data.index[data.index.get_indexer([end_date], method="nearest")[0]] console.print(f"End date not in data. Using nearest: {date1}") else: date1 = end_date diff --git a/openbb_terminal/core/plots/plotly_ta/plugins/custom_indicators_plugin.py b/openbb_terminal/core/plots/plotly_ta/plugins/custom_indicators_plugin.py index 5b01ac0ecbf..79775c2dbf0 100644 --- a/openbb_terminal/core/plots/plotly_ta/plugins/custom_indicators_plugin.py +++ b/openbb_terminal/core/plots/plotly_ta/plugins/custom_indicators_plugin.py @@ -146,8 +146,8 @@ class Custom(PltTA): "0.65", "1", ] - min_date = min_date.to_pydatetime() - max_date = max_date.to_pydatetime() + min_date = pd.to_datetime(min_date).to_pydatetime() + max_date = pd.to_datetime(max_date).to_pydatetime() self.df_fib = df_fib fig.add_scatter(