mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 04:52:07 +00:00
fix intraday check in charting ta_class (#6119)
Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ class Charting:
|
||||
index = (
|
||||
data.index.name
|
||||
if has_data and isinstance(data, (pd.DataFrame, pd.Series))
|
||||
else ""
|
||||
else None
|
||||
)
|
||||
data_as_df: pd.DataFrame = (
|
||||
basemodel_to_df(convert_to_basemodel(data), index=index)
|
||||
|
||||
@@ -182,6 +182,12 @@ class PlotlyTA(PltTA):
|
||||
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.
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user