From e43c549c347d5fcf4b3394380bf67bd79dbfcadf Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Fri, 24 Feb 2023 12:29:08 +0000 Subject: [PATCH] Patch Equity Report --- .../reports/templates/equity.ipynb | 31 +++++++++++-------- .../stocks/options/nasdaq_model.py | 6 ++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/openbb_terminal/reports/templates/equity.ipynb b/openbb_terminal/reports/templates/equity.ipynb index a4e7d1cf8c0f..2757330bc7f7 100644 --- a/openbb_terminal/reports/templates/equity.ipynb +++ b/openbb_terminal/reports/templates/equity.ipynb @@ -134,10 +134,15 @@ "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", + "long_summary = \"Long business summary\"\n", + "long_name = \"Long name\"\n", + "\n", + "if long_summary in info and info[long_summary][0] != \"NA\":\n", + " overview = info[long_summary][0]\n", + "elif long_name in info:\n", + " overview = info[long_name][0]\n", "else:\n", - " overview = info[\"Long name\"][0]" + " overview = \"\"" ] }, { @@ -181,7 +186,7 @@ "metadata": {}, "outputs": [], "source": [ - "tables = openbb.etf.news(info[\"Short name\"][0], 5)\n", + "tables = openbb.etf.news(info[\"Short name\"][0], 5) if \"Short name\" in info else []\n", "for table in tables:\n", " table[0].loc[\"link\"] = (\n", " table[0].loc[\"link\"].apply(lambda x: f'{x}')\n", @@ -195,7 +200,7 @@ "metadata": {}, "outputs": [], "source": [ - "quote_data = openbb.stocks.quote_fmp(symbol)\n", + "quote_data = openbb.stocks.quote(symbol)\n", "quote_data" ] }, @@ -240,9 +245,7 @@ "metadata": {}, "outputs": [], "source": [ - "df_sec_filings = openbb.stocks.fa.sec(symbol=symbol)[[\"Type\", \"Category\", \"Link\"]].head(\n", - " 5\n", - ")\n", + "df_sec_filings = openbb.stocks.fa.sec(symbol)[[\"Type\", \"Category\", \"Link\"]].head(5)\n", "df_sec_filings[\"Link\"] = df_sec_filings[\"Link\"].apply(\n", " lambda x: f'{x}'\n", ")\n", @@ -1195,7 +1198,7 @@ " \"Buffet Score is neutral\",\n", " \"Buffet Score is favourable\",\n", " ],\n", - " float(score[\"Total Score\"], 2),\n", + " float(round(score[\"Total Score\"], 2)),\n", " )\n", "if predictions:\n", " htmlcode += widgets.kpi(\n", @@ -1208,7 +1211,9 @@ " )\n", "body += widgets.add_tab(\"SUMMARY\", htmlcode)\n", "\n", - "htmlcode = widgets.row([widgets.h(3, \"Description\") + widgets.p(overview)])\n", + "htmlcode=\"\"\n", + "if overview:\n", + " htmlcode += widgets.row([widgets.h(3, \"Description\") + widgets.p(overview)])\n", "htmlcode += widgets.row([widgets.h(3, \"Price Chart\") + price_chart])\n", "htmlcode += widgets.row([widgets.h(3, \"Quote\") + quote_data.to_html()])\n", "htmlcode += widgets.row([widgets.h(3, \"Latest News for \" + symbol)])\n", @@ -1466,7 +1471,7 @@ "metadata": { "celltoolbar": "Tags", "kernelspec": { - "display_name": "obb", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -1480,11 +1485,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.9.13" }, "vscode": { "interpreter": { - "hash": "100174a9203096c0c10fb537684ff280825ee9e252451beb8786068677204f06" + "hash": "af870c0f9615f5bb08692efcc9bf540319fe60e6793056508a4dab09c9fa8dda" } } }, diff --git a/openbb_terminal/stocks/options/nasdaq_model.py b/openbb_terminal/stocks/options/nasdaq_model.py index f703a8b3ee30..5c508308bd69 100644 --- a/openbb_terminal/stocks/options/nasdaq_model.py +++ b/openbb_terminal/stocks/options/nasdaq_model.py @@ -176,12 +176,12 @@ def option_expirations(symbol: str) -> List[str]: List of expiration dates """ df = get_full_option_chain(symbol) + if df.empty: return [] + # get everything that is not an empty string - exps = [exp for exp in list(df.expirygroup.unique()) if exp] - # Convert 'January 11, 1993' into '1993-01-11' - return [datetime.strptime(exp, "%B %d, %Y").strftime("%Y-%m-%d") for exp in exps] + return [exp for exp in list(df.expiration.unique()) if exp] @log_start_end(log=logger)