(feat) add returns histogram chart

This commit is contained in:
drupman
2023-09-19 20:50:15 -03:00
parent b973f33eb3
commit b91073a0d5

View File

@@ -228,6 +228,33 @@ def intraday_performance(df: pd.DataFrame):
return fig
def returns_histogram(df: pd.DataFrame):
colors = [BULLISH_COLOR if val > 0 else BEARISH_COLOR for val in df["realized_pnl"]]
fig = go.Figure()
fig.add_trace(go.Histogram(name="Losses",
x=df.loc[df["realized_pnl"] < 0, "realized_pnl"],
marker_color=BEARISH_COLOR))
fig.add_trace(go.Histogram(name="Profits",
x=df.loc[df["realized_pnl"] > 0, "realized_pnl"],
marker_color=BULLISH_COLOR))
fig.update_layout(title=dict(
text='Returns Histogram',
x=0.5,
# y=0.93,
xanchor="center",
# yanchor="bottom"
),
legend=dict(
orientation="h",
# entrywidth=70,
yanchor="bottom",
y=1.02,
xanchor="center",
x=.48
))
return fig
style_metric_cards()
st.subheader("🔫 Data source")
with st.expander("⬆️ Upload"):