From 386c5b4a994ae69b946a01141234d9a14ad6a4c4 Mon Sep 17 00:00:00 2001 From: elyanah Date: Tue, 28 Mar 2023 22:46:26 +0800 Subject: [PATCH 1/5] Add icebofa csv filtering by title --- openbb_terminal/fixedincome/fred_view.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbb_terminal/fixedincome/fred_view.py b/openbb_terminal/fixedincome/fred_view.py index 5581ab529f60..f4f1c29a5d75 100644 --- a/openbb_terminal/fixedincome/fred_view.py +++ b/openbb_terminal/fixedincome/fred_view.py @@ -1252,9 +1252,9 @@ def plot_icebofa( ) if description: - for title, description_text in series[["Title", "Description"]].values: - console.print(f"\n[bold]{title}[/bold]") - console.print(description_text) + description_text = series[series["Title"] == title]["Description"].values + console.print(f"\n[bold]{title}[/bold]") + console.print(description_text) export_data( export, From d3e9d05a4d7842b7ae8a52cf2ec9f36756ef9256 Mon Sep 17 00:00:00 2001 From: elyanah Date: Wed, 29 Mar 2023 07:11:52 +0800 Subject: [PATCH 2/5] Fix description display, rewrite code to avoid raising index error --- openbb_terminal/fixedincome/fred_view.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/openbb_terminal/fixedincome/fred_view.py b/openbb_terminal/fixedincome/fred_view.py index f4f1c29a5d75..32f191009bf6 100644 --- a/openbb_terminal/fixedincome/fred_view.py +++ b/openbb_terminal/fixedincome/fred_view.py @@ -1229,8 +1229,11 @@ 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] - + if df.empty: + title = "" + else: + title = "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) @@ -1251,8 +1254,8 @@ def plot_icebofa( limit=limit, ) - if description: - description_text = series[series["Title"] == title]["Description"].values + if description and title: + description_text = series[series["Title"] == title]["Description"].values[0] console.print(f"\n[bold]{title}[/bold]") console.print(description_text) From ac8f4062660b44cacfb0742ac5081fe36ab0b8ba Mon Sep 17 00:00:00 2001 From: elyanah Date: Wed, 29 Mar 2023 07:25:11 +0800 Subject: [PATCH 3/5] Reformat with black --- openbb_terminal/fixedincome/fred_view.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openbb_terminal/fixedincome/fred_view.py b/openbb_terminal/fixedincome/fred_view.py index 32f191009bf6..e3c441e2a9d4 100644 --- a/openbb_terminal/fixedincome/fred_view.py +++ b/openbb_terminal/fixedincome/fred_view.py @@ -1232,8 +1232,10 @@ def plot_icebofa( if df.empty: title = "" else: - title = "ICE BofA Bond Benchmark Indices" if len(df.columns) > 1 else df.columns[0] - + title = ( + "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) From 217e6f4eb32c14bf2e751ce3dde0e4c66612ca38 Mon Sep 17 00:00:00 2001 From: elyanah Date: Wed, 29 Mar 2023 07:30:08 +0800 Subject: [PATCH 4/5] Replace if-else with ternary operator --- openbb_terminal/fixedincome/fred_view.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openbb_terminal/fixedincome/fred_view.py b/openbb_terminal/fixedincome/fred_view.py index e3c441e2a9d4..989db6a13776 100644 --- a/openbb_terminal/fixedincome/fred_view.py +++ b/openbb_terminal/fixedincome/fred_view.py @@ -1229,12 +1229,13 @@ def plot_icebofa( start_date=start_date, end_date=end_date, ) - if df.empty: - title = "" - else: - 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) From 654af28d27a6b954e5f0b7fd828998c2819056da Mon Sep 17 00:00:00 2001 From: elyanah Date: Thu, 30 Mar 2023 07:03:23 +0800 Subject: [PATCH 5/5] Fix issue when multiple indices are selected --- openbb_terminal/fixedincome/fred_view.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openbb_terminal/fixedincome/fred_view.py b/openbb_terminal/fixedincome/fred_view.py index 989db6a13776..fe17a323cc15 100644 --- a/openbb_terminal/fixedincome/fred_view.py +++ b/openbb_terminal/fixedincome/fred_view.py @@ -1258,9 +1258,12 @@ def plot_icebofa( ) if description and title: - description_text = series[series["Title"] == title]["Description"].values[0] - console.print(f"\n[bold]{title}[/bold]") - console.print(description_text) + 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) export_data( export,