Skip to content

Commit

Permalink
Display daily returns as bar chart with color=red for negative return… (
Browse files Browse the repository at this point in the history
#3850)

* Display daily returns as bar chart with color=red for negative returns and color=green for positive return

* Display daily returns as bar chart with color=theme.down_color for negative returns and color=theme.up_color for positive return

* Black formatting

Co-authored-by: Lars Karbach <lars@karbach.org>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
  • Loading branch information
3 people authored Jan 3, 2023
1 parent 0d47953 commit ec41ab8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions openbb_terminal/portfolio/portfolio_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,19 @@ def display_daily_returns(
return
ax = external_axes

clrs_portfolio = [
theme.down_color if (x < 0) else theme.up_color for x in df["portfolio"]
]
clrs_benchmark = [
theme.down_color if (x < 0) else theme.up_color for x in df["benchmark"]
]

ax[0].set_title(f"Portfolio in period {window}")
ax[0].plot(df.index, df["portfolio"], label="Portfolio")
ax[0].bar(df.index, df["portfolio"], label="Portfolio", color=clrs_portfolio)
ax[0].set_ylabel("Returns [%]")
theme.style_primary_axis(ax[0])
ax[1].set_title(f"Benchmark in period {window}")
ax[1].plot(df.index, df["benchmark"], label="Benchmark")
ax[1].bar(df.index, df["benchmark"], label="Benchmark", color=clrs_benchmark)
ax[1].set_ylabel("Returns [%]")
theme.style_primary_axis(ax[1])

Expand Down

0 comments on commit ec41ab8

Please sign in to comment.