mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-04 00:12:29 +00:00
hotfix/ Options Historical + Crypto candles (#5064)
* fix options/crypto candles * fix streamlit indicators * Update Indicators.py
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -43,7 +43,7 @@ website/terminaltest
|
||||
openbb_terminal/core/plots/assets/plotly*.js
|
||||
.dccache
|
||||
*rome.json
|
||||
|
||||
**/node_modules/*
|
||||
# pyinstaller artifacts
|
||||
*.pyo
|
||||
dist/*
|
||||
|
||||
@@ -1592,6 +1592,7 @@ class OpenBBFigure(go.Figure):
|
||||
xref="paper",
|
||||
x=1,
|
||||
y=0,
|
||||
showarrow=False,
|
||||
text="OpenBB Terminal",
|
||||
font_size=17,
|
||||
font_color="gray",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user