diff --git a/openbb_terminal/jupyter/reports/equity.ipynb b/openbb_terminal/jupyter/reports/equity.ipynb index ff798cf3955..df6fdc86f45 100644 --- a/openbb_terminal/jupyter/reports/equity.ipynb +++ b/openbb_terminal/jupyter/reports/equity.ipynb @@ -434,8 +434,7 @@ "outputs": [], "source": [ "df_sentiment_finbrain = openbb.stocks.ba.models.finbrain.get_sentiment(ticker)\n", - "finbrain_sentiment_val = float(df_sentiment_finbrain.values[-1][0])\n", - "finbrain_sentiment_val = 10" + "finbrain_sentiment_val = float(df_sentiment_finbrain.values[-1][0])" ] }, { @@ -583,160 +582,64 @@ "outputs": [], "source": [ "body = \"\"\n", - "body += f'''\n", - "
Analyst: {author}
\n", - "Date : {report_date}
\n", - "Time : {report_time} {report_timezone}
\n", - "INVESTMENT RESEARCH REPORT: {ticker}
\n", - "❌ Last closing price ({last_price}) > Average price ratings last 30 days ({avg_ratings_last_30_days})
'\n", - "else:\n", - " body += f'✅ Average price ratings last 30 days ({avg_ratings_last_30_days}) > Last closing price ({last_price})
'\n", + "body += openbb.widgets.tablinks([\"SUMMARY\", \"Overview\", \"Analyst Opinions\", \"Fundamental Analysis\", \"Dark Pool and Shorts\", \"Technical Analysis\", \"Insider Trading\", \"Behavioural Analysis\", \"Quantitative Analysis\", \"Prediction Techniques\"])\n", "\n", - "if regression_slope > 0:\n", - " body += f'✅ Regression on the last 30 market days ({regression_slope} dollars/market day) is positive
'\n", - "else:\n", - " body += f'❌ Regression on the last 30 market days ({regression_slope} dollars/market day) is negative
'\n", - " \n", - "if rsi_value < 30:\n", - " body += f'✅ RSI level is OVERSOLD. {rsi_value} < 30
'\n", - "elif rsi_value > 70:\n", - " body += f'❌ RSI level is OVERBOUGHT. {rsi_value} > 70
'\n", - "else:\n", - " body += f'🟡 RSI level is NORMAL. 30 < {rsi_value} < 70
'\n", - " \n", - "if last_10_insider_trading > 0:\n", - " body += f'✅ Last 10 insider trading. {last_10_insider_trading} M was bought in value.
'\n", - "else:\n", - " body += f'❌ Last 10 insider trading. {last_10_insider_trading} M was sold in value
'\n", - " \n", - "if finbrain_sentiment_val > .1:\n", - " body += f'✅ Last FinBrain sentiment is BULLISH: {finbrain_sentiment_val}
'\n", - "elif finbrain_sentiment_val < -.1:\n", - " body += f'❌ Last FinBrain sentiment is BEARISH: {finbrain_sentiment_val}
'\n", - "else:\n", - " body += f'🟡 Last FinBrain sentiment is NEUTRAL: {finbrain_sentiment_val}
'\n", - " \n", - "if (regression_val - last_price) > 0:\n", - " body += f'✅ Regression for next 20th market price ({regression_val}) > Last closing price ({last_price})
'\n", - "else:\n", - " body += f'❌ Regression for next 20th market price ({regression_val}) < Last closing price ({last_price})
'\n", - " \n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([price_chart])\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"Description\") + openbb.widgets.p(overview)])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([price_target_chart])\n", - "body += openbb.widgets.row([ratings_over_time_chart])\n", - "body += openbb.widgets.row([df_analyst.to_html()])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"Estimates\") + df_year_estimates.head().to_html()])\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"Earnings\") + df_quarter_earnings.head().to_html()])\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"Revenues\") + df_quarter_revenues.head().to_html()])\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"SEC filings\") + df_sec_filings.head().to_html()])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([net_short_position])\n", - "body += openbb.widgets.row([price_vs_short_interest])\n", - "body += openbb.widgets.row([dark_pools])\n", - "body += openbb.widgets.row([volexch])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([ta_rsi])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"Last Activity\") + df_insider.head(10).to_html(col_space='75px')])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([finbrain_sentiment])\n", - "body += openbb.widgets.row([snews])\n", - "body += openbb.widgets.row([openbb.widgets.h(3, \"Stocktwits\") + stocktwits_sentiment])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([bw_month])\n", - "body += openbb.widgets.row([bw_year])\n", - "body += 'No comment.
'\n", - "body += openbb.widgets.row([regression])\n", - "body += openbb.widgets.row([mc])\n", - "body += '{text}
" def row(elements: List) -> str: + """HTML code elements to add in a single row + + Parameters + ---------- + elements : List + List of HTML code elements to add in a row + + Returns + ------- + str + HTML code as string + """ with open( os.path.join(os.path.dirname(os.path.abspath(__file__)), "widgets", "row.j2") ) as f: template = Template(f.read()) return template.render(elements=elements) + + +def kpi(thresholds: List[float], sentences: List[str], value: float) -> str: + """Add new key performance indicator to main page of report + + Parameters + ---------- + thresholds : List[float] + List of thresholds to take into account + sentences : List[str] + List of sentences to take into account. len(sentences) = len(thresholds)+1 + value : float + Current value for the KPI in question + + Returns + ------- + str + HTML code as string + """ + if len(thresholds) == 1 and len(sentences) == 2: + if value < thresholds[0]: + return f'❌ {sentences[0]}. {value} < {thresholds[0]}
' + return f'✅ {sentences[1]}. {value} > {thresholds[0]}
' + if len(thresholds) == 2 and len(sentences) == 3: + if value < thresholds[0]: + return f'❌ {sentences[0]}. {value} < {thresholds[0]}
' + if value > thresholds[1]: + return f'✅ {sentences[2]}. {value} > {thresholds[1]}
' + return f'🟡 {sentences[1]}. {thresholds[0]} < {value} < {thresholds[1]}
' + print("Error. KPI condition is not correctly set") + return "" + + +def add_tab(title: str, htmlcode: str) -> str: + """Add new tab section for the report. By default adds an opinion editable box at the start. + + Parameters + ---------- + title : str + Title associated with this tab / section + htmlcode : str + All HTML code contain within this section + + Returns + ------- + str + HTML code as string + """ + return f"""+ No comment. +
{htmlcode} +Analyst: {author}
+Date : {report_date}
+Time : {report_time} {report_tz}
+{title}
+