Skip to content

Commit

Permalink
hotfix/ Options Historical + Crypto candles (#5064)
Browse files Browse the repository at this point in the history
* fix options/crypto candles

* fix streamlit indicators

* Update Indicators.py
  • Loading branch information
tehcoderer authored May 24, 2023
1 parent 77b2da0 commit e07a5a3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ website/terminaltest
openbb_terminal/core/plots/assets/plotly*.js
.dccache
*rome.json

**/node_modules/*
# pyinstaller artifacts
*.pyo
dist/*
Expand Down
1 change: 1 addition & 0 deletions openbb_terminal/core/plots/plotly_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 12 additions & 5 deletions openbb_terminal/dashboards/stream/pages/Indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
)
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions openbb_terminal/stocks/options/chartexchange_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ def plot_chart(
OpenBBFigure
Plotly figure object
"""
titles_list = ["Historical", symbol, price, option_type.title()]

fig = OpenBBFigure.create_subplots(
rows=1,
cols=1,
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,
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions openbb_terminal/stocks/options/intrinio_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/stocks/options/tradier_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e07a5a3

Please sign in to comment.