summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrewkenreich <andrew.kenreich@gmail.com>2023-05-04 10:26:38 -0700
committerGitHub <noreply@github.com>2023-05-04 17:26:38 +0000
commitb9a4faa0d7b92d46813980e4325ff21855f82608 (patch)
tree816c6896ebd0b0a03c4656b62b21bdf22952d947
parent5a3b006b760ae5c62ec0e11b145784dfc6716156 (diff)
fixing equity report issue (#4922)
* fixing equity report issue * some fixes --------- Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
-rw-r--r--openbb_terminal/reports/templates/equity.ipynb123
1 files changed, 54 insertions, 69 deletions
diff --git a/openbb_terminal/reports/templates/equity.ipynb b/openbb_terminal/reports/templates/equity.ipynb
index b2992ffe43f..c7891f3b296 100644
--- a/openbb_terminal/reports/templates/equity.ipynb
+++ b/openbb_terminal/reports/templates/equity.ipynb
@@ -58,11 +58,13 @@
"\n",
"user = get_current_user()\n",
"\n",
- "cfg.theme = TerminalStyle(\n",
- " user.preferences.MPL_STYLE,\n",
- " user.preferences.PMF_STYLE,\n",
- " user.preferences.RICH_STYLE,\n",
- ")"
+ "from openbb_terminal import theme\n",
+ "\n",
+ "#cfg.theme = TerminalStyle(\n",
+ "# user.preferences.MPL_STYLE,\n",
+ "# user.preferences.PMF_STYLE,\n",
+ "# user.preferences.RICH_STYLE,\n",
+ "#)"
]
},
{
@@ -97,7 +99,7 @@
"source": [
"# Parameters that will be replaced when calling this notebook\n",
"# Do not leave parameters blank as notebook will not run otherwise\n",
- "symbol = \"IONQ\"\n",
+ "symbol = \"FRC\"\n",
"report_name = f\"Equity report for {symbol}\""
]
},
@@ -142,7 +144,7 @@
"metadata": {},
"outputs": [],
"source": [
- "info = openbb.stocks.fa.data(symbol=symbol).transpose()\n",
+ "info = openbb.stocks.fa.overview(symbol=symbol, source=\"Finviz\").transpose()\n",
"\n",
"info\n",
"try:\n",
@@ -183,7 +185,7 @@
" df_quarter_earnings,\n",
" df_quarter_revenues,\n",
") = openbb.stocks.fa.est(symbol=symbol)\n",
- "df_quarter_revenues"
+ "df_quarter_revenues.transpose()"
]
},
{
@@ -204,14 +206,14 @@
"metadata": {},
"outputs": [],
"source": [
- "tables = openbb.etf.news(info[\"Short name\"][0], 5) if \"Short name\" in info else symbol\n",
+ "tables = openbb.stocks.news(symbol)\n",
"\n",
"for table in tables:\n",
" if not isinstance(table, pd.DataFrame):\n",
" continue\n",
"\n",
- " table[0].loc[\"link\"] = (\n",
- " table[0].loc[\"link\"].apply(lambda x: f'<a href=\"{x}\">{x}</a>')\n",
+ " table[0].loc[\"URL\"] = (\n",
+ " table[0].loc[\"URL\"].apply(lambda x: f'<a href=\"{x}\">{x}</a>')\n",
" )"
]
},
@@ -222,7 +224,7 @@
"metadata": {},
"outputs": [],
"source": [
- "quote_data = openbb.stocks.quote([symbol])\n",
+ "quote_data = info[[\"Price\", \"Prev Close\", \"Change\", \"Volume\", \"52W Range\", \"Perf YTD\"]]\n",
"quote_data"
]
},
@@ -241,36 +243,18 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "e101e24e",
- "metadata": {},
- "outputs": [],
- "source": [
- "openbb.stocks.fa.shrs(symbol)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "51dfd9d2",
- "metadata": {},
- "outputs": [],
- "source": [
- "df_institutional_shareholders = openbb.stocks.fa.shrs(symbol)\n",
- "df_institutional_shareholders.index += 1\n",
- "df_institutional_shareholders"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
"id": "3022130e",
"metadata": {},
"outputs": [],
"source": [
- "df_sec_filings = openbb.stocks.fa.sec(symbol)[\n",
- " [\"Company Name\", \"Reporting Owner\", \"Form Type\", \"Period\"]\n",
- "].head(5)\n",
- "df_sec_filings"
+ "#this command works 1/2 the time - really need to fix this - but this will catch the errors and stop it from breaking the report\n",
+ "try:\n",
+ " df_sec_filings = openbb.stocks.fa.sec(symbol)[\n",
+ " [\"Company Name\", \"Reporting Owner\", \"Form Type\", \"Period\", \"View\"]\n",
+ " ].head(5)\n",
+ " df_sec_filings\n",
+ "except:\n",
+ " df_sec_filings = \"Error with Nasdaq API\""
]
},
{
@@ -280,25 +264,25 @@
"metadata": {},
"outputs": [],
"source": [
- "df_analyst = openbb.stocks.fa.analyst(symbol=symbol)\n",
- "print(df_analyst)\n",
- "if not df_analyst.empty:\n",
- " if \"target\" in df_analyst.columns:\n",
- " if \"target_to\" in df_analyst.columns:\n",
- " df_analyst[\"target\"] = df_analyst[\"target_to\"].combine_first(\n",
- " df_analyst[\"target\"]\n",
- " )\n",
- " else:\n",
- " df_analyst[\"target\"] = df_analyst[\"target\"]\n",
- " df_analyst = df_analyst[[\"category\", \"analyst\", \"rating\", \"target\"]].rename(\n",
- " columns={\n",
- " \"category\": \"Category\",\n",
- " \"analyst\": \"Analyst\",\n",
- " \"rating\": \"Rating\",\n",
- " \"target\": \"Price Target\",\n",
- " }\n",
- " )\n",
- "df_analyst"
+ "df_analyst = openbb.stocks.fa.pt(symbol=symbol).sort_index(ascending = False)\n",
+ "#print(df_analyst)\n",
+ "#if not df_analyst.empty:\n",
+ "# if \"target\" in df_analyst.columns:\n",
+ "# if \"target_to\" in df_analyst.columns:\n",
+ "# df_analyst[\"target\"] = df_analyst[\"target_to\"].combine_first(\n",
+ "# df_analyst[\"target\"]\n",
+ "# )\n",
+ "# else:\n",
+ "# df_analyst[\"target\"] = df_analyst[\"target\"]\n",
+ "# df_analyst = df_analyst[[\"category\", \"analyst\", \"rating\", \"target\"]].rename(\n",
+ "# columns={\n",
+ "# \"category\": \"Category\",\n",
+ "# \"analyst\": \"Analyst\",\n",
+ "# \"rating\": \"Rating\",\n",
+ "# \"target\": \"Price Target\",\n",
+ "# }\n",
+ "# )\n",
+ "df_analyst.head(10)"
]
},
{
@@ -469,7 +453,7 @@
"metadata": {},
"outputs": [],
"source": [
- "similar_companies = openbb.stocks.ca.similar(symbol, source=\"Polygon\")\n",
+ "similar_companies = openbb.stocks.ca.similar(symbol, source=\"Finviz\")[0:5]\n",
"if similar_companies:\n",
" similar_companies.append(symbol)"
]
@@ -666,7 +650,7 @@
"metadata": {},
"outputs": [],
"source": [
- "df = openbb.stocks.fa.pt(symbol=symbol)\n",
+ "df = df_analyst.copy()\n",
"avg_ratings_last_30_days = 0\n",
"days = 0\n",
"if not df.empty:\n",
@@ -840,6 +824,7 @@
"ticker_data_all = openbb.stocks.load(\n",
" symbol=symbol,\n",
" start_date=datetime.datetime.now() - datetime.timedelta(days=5 * 12 * 21),\n",
+ " verbose = False\n",
")\n",
"ticker_data_all[\"Returns\"] = ticker_data_all[\"Adj Close\"].pct_change()"
]
@@ -889,8 +874,8 @@
"metadata": {},
"outputs": [],
"source": [
- "income_df = openbb.stocks.fa.income(symbol, source=\"FinancialModelingPrep\")\n",
- "data_df = openbb.stocks.fa.data(symbol)\n",
+ "income_df = openbb.stocks.fa.income(symbol, source = 'FinancialModelingPrep')\n",
+ "data_df = openbb.stocks.fa.overview(symbol, source = 'FinancialModelingPrep')\n",
"mgmt_df = openbb.stocks.fa.mgmt(symbol)\n",
"try:\n",
" if not mgmt_df.empty:\n",
@@ -1029,7 +1014,7 @@
"<style>\n",
"@font-face {{\n",
" font-family: \"Fira Code\";\n",
- " src: url(\"{(OpenBBFigure.plotlyjs_path.parent.parent / \"web\"/\"css\").as_uri()}/fonts/FiraCode-Regular.ttf\") format(\"truetype\");\n",
+ " src: url(\"{(OpenBBFigure.plotlyjs_path.parent.parent / \"web\"/\"css\").as_uri()}/fonts/Consolas-Regular.ttf\") format(\"truetype\");\n",
" font-weight: 400 700;\n",
" font-stretch: 50%;\n",
"}}\n",
@@ -1162,12 +1147,12 @@
" htmlcode += widgets.row([widgets.h(3, \"Analyst Ratings\") + df_analyst.to_html()])\n",
"except:\n",
" pass\n",
- "try:\n",
- " htmlcode += widgets.row(\n",
- " [widgets.h(3, \"Analyst Recommendations\") + df_rating.to_html()]\n",
- " )\n",
- "except:\n",
- " pass\n",
+ "#try:\n",
+ "# htmlcode += widgets.row(\n",
+ "# [widgets.h(3, \"Analyst Recommendations\") + df_rating.to_html()]\n",
+ "# )\n",
+ "#except:\n",
+ "# pass\n",
"\n",
"body += widgets.add_tab(\"Analyst Opinions\", htmlcode)\n",
"\n",
@@ -1405,7 +1390,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.5"
+ "version": "3.10.8"
},
"vscode": {
"interpreter": {