From ecb36bf5616fe46ab2edc0738d32b5c104d6f8fb Mon Sep 17 00:00:00 2001 From: Raffaele Abate Date: Sun, 16 Oct 2022 00:47:10 +0200 Subject: [PATCH] Fix of #2833 (#2861) * Fix of #2833 * removed debug prints Co-authored-by: hjoaquim --- openbb_terminal/reports/equity.ipynb | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/openbb_terminal/reports/equity.ipynb b/openbb_terminal/reports/equity.ipynb index eaeb2c89c2e..c756fec7007 100644 --- a/openbb_terminal/reports/equity.ipynb +++ b/openbb_terminal/reports/equity.ipynb @@ -133,7 +133,6 @@ "outputs": [], "source": [ "info = openbb.stocks.fa.info(symbol=symbol).transpose()\n", - "\n", "if info[\"Long business summary\"][0] != \"NA\":\n", " overview = info[\"Long business summary\"][0]\n", "else:\n", @@ -182,6 +181,10 @@ "outputs": [], "source": [ "tables = openbb.etf.news(info[\"Short name\"][0], 5)\n", + "\n", + "# Add an empty iterator if it the returned type is None\n", + "# i.e.: in case of lack of a valid API\n", + "tables = tables if tables is not None else []\n", "for table in tables:\n", " table[0].loc[\"link\"] = (\n", " table[0].loc[\"link\"].apply(lambda x: f'{x}')\n", @@ -532,6 +535,10 @@ "outputs": [], "source": [ "similar_companies = openbb.stocks.ca.polygon_peers(symbol)\n", + "\n", + "# Add an empty list if it the returned list is empty\n", + "# i.e.: in case of lack of a valid API\n", + "similar_companies = similar_companies if similar_companies is not None else []\n", "similar_companies.append(symbol)" ] }, @@ -1375,9 +1382,13 @@ " )\n", "except:\n", " pass\n", - "htmlcode += widgets.row(\n", - " [widgets.h(3, f\"Enterprise data for {symbol}\") + enterprise_df.to_html()]\n", - ")\n", + "\n", + "try:\n", + " htmlcode += widgets.row(\n", + " [widgets.h(3, f\"Enterprise data for {symbol}\") + enterprise_df.to_html()]\n", + " )\n", + "except:\n", + " pass\n", "htmlcode += widgets.row(\n", " [widgets.h(3, f\"Income Statement for {symbol}\") + income_df.to_html()]\n", ")\n", @@ -1391,9 +1402,7 @@ " )\n", "except:\n", " pass\n", - "\n", "body += widgets.add_tab(\"Fundamental Analysis\", htmlcode)\n", - "\n", "htmlcode = widgets.row([widgets.h(3, \"Put to call ratio\") + pcr_chart])\n", "htmlcode += widgets.row(\n", " [widgets.h(3, \"Option Volume for closest expiry date\") + vol_chart]\n", @@ -1574,7 +1583,7 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "Python 3.9.13 ('obb')", + "display_name": "Python 3.10.4 ('obb')", "language": "python", "name": "python3" }, @@ -1588,11 +1597,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.4" }, "vscode": { "interpreter": { - "hash": "ab0e87f2bc73919b75956d1b3e303320699d53da895be1bb46287d7dc67c6497" + "hash": "1a8cc6b6e60740679b24fc1ea93bdeb94d949a22102a80c99b7fd3f0d572afd6" } } },