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

[BugFix] Fix Intraday Check in Charting ta_class #6119

Merged
merged 5 commits into from
Feb 28, 2024
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
2 changes: 1 addition & 1 deletion openbb_platform/core/integration/test_obbject.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_to_chart(obb):
"""Test obbject to chart."""

res = obb.equity.price.historical("AAPL", provider="fmp")
res.charting.to_chart()
res.charting.to_chart(render=False)
assert isinstance(res.chart.fig, OpenBBFigure)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def to_chart(
index = (
data.index.name
if has_data and isinstance(data, (pd.DataFrame, pd.Series))
else ""
hjoaquim marked this conversation as resolved.
Show resolved Hide resolved
else None
)
data_as_df: pd.DataFrame = (
basemodel_to_df(convert_to_basemodel(data), index=index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ def __plot__(
if not isinstance(indicators, ChartIndicators):
indicators = ChartIndicators.from_dict(indicators or dict(dict()))

# Apply to_datetime to the index in a way that handles daylight savings.
hjoaquim marked this conversation as resolved.
Show resolved Hide resolved
df_stock.loc[:, "date"] = df_stock.index # type: ignore
df_stock["date"] = df_stock["date"].apply(pd.to_datetime)
df_stock.index = df_stock["date"] # type: ignore
df_stock.drop(columns=["date"], inplace=True)

self.indicators = indicators
self.intraday = df_stock.index[-2].time() != df_stock.index[-1].time()
self.df_stock = df_stock.sort_index(ascending=True)
Expand Down
Loading