Skip to content

Commit

Permalink
Filter icebofa file by title (#4609)
Browse files Browse the repository at this point in the history
* Add icebofa csv filtering by title

* Fix description display, rewrite code to avoid raising index error

* Reformat with black

* Replace if-else with ternary operator

* Fix issue when multiple indices are selected

---------

Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
  • Loading branch information
3 people committed Apr 12, 2023
1 parent 48cef0e commit 6acc16f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions openbb_terminal/fixedincome/fred_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,13 @@ def plot_icebofa(
start_date=start_date,
end_date=end_date,
)
title = "ICE BofA Bond Benchmark Indices" if len(df.columns) > 1 else df.columns[0]
title = (
""
if df.empty
else "ICE BofA Bond Benchmark Indices"
if len(df.columns) > 1
else df.columns[0]
)

fig = OpenBBFigure(yaxis_title="Yield (%)" if units == "percent" else "Index")
fig.set_title(title)
Expand All @@ -1339,8 +1345,11 @@ def plot_icebofa(
limit=limit,
)

if description:
for title, description_text in series[["Title", "Description"]].values:
if description and title:
for index_title in df.columns:
description_text = series[series["Title"] == index_title][
"Description"
].values[0]
console.print(f"\n[bold]{title}[/bold]")
console.print(description_text)

Expand Down

0 comments on commit 6acc16f

Please sign in to comment.