Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stocks/ta/fib datetime plotting #4875

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def plot_fib(self, fig: OpenBBFigure, df_ta: pd.DataFrame):
"<b>0.65</b>",
"<b>1</b>",
]
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(
Expand Down