From e07a5a382619cdbfec3a4f5188aa9dea958cbdf9 Mon Sep 17 00:00:00 2001 From: teh_coderer Date: Wed, 24 May 2023 15:46:40 -0500 Subject: [PATCH] hotfix/ Options Historical + Crypto candles (#5064) * fix options/crypto candles * fix streamlit indicators * Update Indicators.py --- .gitignore | 2 +- openbb_terminal/core/plots/plotly_helper.py | 1 + .../cryptocurrency/cryptocurrency_helpers.py | 4 ++-- .../dashboards/stream/pages/Indicators.py | 17 ++++++++++++----- .../stocks/options/chartexchange_view.py | 5 +++-- openbb_terminal/stocks/options/intrinio_view.py | 6 +++--- openbb_terminal/stocks/options/tradier_view.py | 2 +- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index e3616f955db9..2067d0436151 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,7 @@ website/terminaltest openbb_terminal/core/plots/assets/plotly*.js .dccache *rome.json - +**/node_modules/* # pyinstaller artifacts *.pyo dist/* diff --git a/openbb_terminal/core/plots/plotly_helper.py b/openbb_terminal/core/plots/plotly_helper.py index 25589b2228bf..0ede57301e63 100644 --- a/openbb_terminal/core/plots/plotly_helper.py +++ b/openbb_terminal/core/plots/plotly_helper.py @@ -1592,6 +1592,7 @@ def _set_watermark(self) -> None: xref="paper", x=1, y=0, + showarrow=False, text="OpenBB Terminal", font_size=17, font_color="gray", diff --git a/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py b/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py index c6e4fd7d6274..9f88d23a739f 100644 --- a/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py +++ b/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py @@ -915,12 +915,12 @@ def plot_candles( # pylint: disable=too-many-arguments name=f"{symbol} OHLC", row=1, col=1, - secondary_y=volume, + secondary_y=False, ) if volume: fig.add_inchart_volume(data) - fig.set_yaxis_title("Price", row=1, col=1, secondary_y=volume, type=yscale) + fig.set_yaxis_title("Price", row=1, col=1, secondary_y=False, type=yscale) fig.update_layout(showlegend=False) return fig.show(external=external_axes) diff --git a/openbb_terminal/dashboards/stream/pages/Indicators.py b/openbb_terminal/dashboards/stream/pages/Indicators.py index 74a8a5c3a0b9..9be698a5aae4 100644 --- a/openbb_terminal/dashboards/stream/pages/Indicators.py +++ b/openbb_terminal/dashboards/stream/pages/Indicators.py @@ -102,7 +102,7 @@ async def plot_indicators( main_ticker, candles=not tickers, volume=not tickers, - volume_ticks_x=5, + volume_ticks_x=7, ) fig.update_traces(showlegend=False) @@ -149,8 +149,8 @@ async def plot_indicators( showline=False, zeroline=False, title_text="% Change", - ticksuffix=f"{'':>20}", side="left", + title_standoff=5, tickformat=".2%", overlaying="y", ) @@ -167,13 +167,20 @@ async def plot_indicators( y_min -= y_range * 0.05 y_max += y_range * 0.05 - yaxis = "yaxis" if tickers else "yaxis2" - fig.update_layout( - {yaxis: dict(range=[y_min, y_max], autorange=False)}, + yaxis=dict(range=[y_min, y_max], autorange=False), title=dict(x=0.5, xanchor="center", yanchor="top", y=0.99, text=title), showlegend=True, height=550 + (20 * rows), + legend=dict( + bgcolor="rgba(0,0,0,0.5)", + bordercolor="#F5EFF3", + borderwidth=1, + x=0.01, + y=0.01, + xanchor="left", + yanchor="bottom", + ), ) return fig diff --git a/openbb_terminal/stocks/options/chartexchange_view.py b/openbb_terminal/stocks/options/chartexchange_view.py index 6b71d9c08a6d..7741a7b5c88a 100644 --- a/openbb_terminal/stocks/options/chartexchange_view.py +++ b/openbb_terminal/stocks/options/chartexchange_view.py @@ -38,6 +38,7 @@ def plot_chart( OpenBBFigure Plotly figure object """ + titles_list = ["Historical", symbol, price, option_type.title()] fig = OpenBBFigure.create_subplots( rows=1, @@ -45,7 +46,7 @@ def plot_chart( vertical_spacing=0.06, specs=[[{"secondary_y": True}]], ) - fig.set_title(f"Historical {symbol} {price} {option_type.title()}") + fig.set_title(" ".join(str(x) for x in titles_list if x)) fig.add_candlestick( open=df.Open, @@ -56,7 +57,7 @@ def plot_chart( name=f"{price} {option_type.title()} OHLC", row=1, col=1, - secondary_y=True, + secondary_y=False, ) fig.add_inchart_volume(df) fig.hide_holidays() diff --git a/openbb_terminal/stocks/options/intrinio_view.py b/openbb_terminal/stocks/options/intrinio_view.py index e5ec49fa4763..4a6c262d06f9 100644 --- a/openbb_terminal/stocks/options/intrinio_view.py +++ b/openbb_terminal/stocks/options/intrinio_view.py @@ -71,13 +71,13 @@ def display_historical( df_hist.columns = [x.title() for x in df_hist.columns] + titles_list = [symbol, strike, op_type] fig = OpenBBFigure.create_subplots( rows=1, cols=1, specs=[[{"secondary_y": True}]], vertical_spacing=0.03, - subplot_titles=[f"{symbol} {strike} {op_type}"], - ) + ).set_title(" ".join([str(x) for x in titles_list if x])) fig.add_candlestick( open=df_hist["Open"], @@ -88,7 +88,7 @@ def display_historical( name=f"{symbol} OHLC", row=1, col=1, - secondary_y=True, + secondary_y=False, ) fig.add_inchart_volume(df_hist) fig.hide_holidays() diff --git a/openbb_terminal/stocks/options/tradier_view.py b/openbb_terminal/stocks/options/tradier_view.py index 45b992f2fbd3..5e1e384f5617 100644 --- a/openbb_terminal/stocks/options/tradier_view.py +++ b/openbb_terminal/stocks/options/tradier_view.py @@ -88,7 +88,7 @@ def display_historical( name=f"{symbol} OHLC", row=1, col=1, - secondary_y=True, + secondary_y=False, ) fig.add_inchart_volume(df_hist) fig.hide_holidays()