From 6e01e453bf10b82c2dddbde5d5f439e7837081ac Mon Sep 17 00:00:00 2001 From: James Maslek Date: Tue, 13 Jun 2023 09:02:22 -0400 Subject: [PATCH] test --- .../reports/templates/economy.ipynb | 1542 +++++++++-------- .../reports/templates/equity.ipynb | 120 +- .../reports/templates/forecast.ipynb | 20 +- .../reports/templates/portfolio.ipynb | 40 +- .../cryptocurrency/defi/test_llama_view.py | 1 + 5 files changed, 865 insertions(+), 858 deletions(-) diff --git a/openbb_terminal/reports/templates/economy.ipynb b/openbb_terminal/reports/templates/economy.ipynb index 5e52d0f0a0c3..035bfdf04334 100644 --- a/openbb_terminal/reports/templates/economy.ipynb +++ b/openbb_terminal/reports/templates/economy.ipynb @@ -1,771 +1,777 @@ { - "cells": [ - { - "attachments": {}, - "cell_type": "markdown", - "id": "70ba2c8a", - "metadata": {}, - "source": [ - "## Notebook setup\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "driven-billion", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import io\n", - "import warnings\n", - "import datetime\n", - "import numpy as np\n", - "import pandas as pd\n", - "import base64\n", - "import pytz\n", - "\n", - "from IPython.display import HTML\n", - "\n", - "import openbb_terminal.config_terminal as cfg\n", - "from openbb_terminal.helper_funcs import get_user_timezone\n", - "from openbb_terminal import OpenBBFigure, theme\n", - "from openbb_terminal.helper_classes import TerminalStyle\n", - "\n", - "\n", - "warnings.filterwarnings(\"ignore\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4494cd3e", - "metadata": {}, - "outputs": [], - "source": [ - "# Suppressing sdk logs\n", - "from openbb_terminal.core.session.current_system import set_system_variable\n", - "\n", - "set_system_variable(\"LOGGING_SUPPRESS\", True)\n", - "\n", - "# Import the OpenBB SDK\n", - "from openbb_terminal.sdk import openbb, widgets\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f9feebc8", - "metadata": {}, - "outputs": [], - "source": [ - "from openbb_terminal.core.session.current_user import get_current_user\n", - "\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", - ")\n", - "theme.apply_style(\"light\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e6e39973", - "metadata": {}, - "outputs": [], - "source": [ - "stylesheet = widgets.html_report_stylesheet()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "daef64ec", - "metadata": { - "tags": [ - "parameters" - ] - }, - "outputs": [], - "source": [ - "# Parameters that will be replaced when calling this notebook\n", - "# Do not leave parameters blank as notebook will not run otherwise\n", - "report_name = \"economy_report\"\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1be26dae-cafe-4a22-80aa-eff296fc1a9b", - "metadata": {}, - "outputs": [], - "source": [ - "author = \"OpenBB\"\n", - "report_title = f\"Economy report\"\n", - "user_time_zone = pytz.timezone(get_user_timezone())\n", - "report_date = pd.Timestamp.now(tz=user_time_zone).strftime(\"%d %B, %Y\")\n", - "report_time = pd.Timestamp.now(tz=user_time_zone).strftime(\"%H:%M\")\n", - "report_timezone = pd.Timestamp.now(tz=user_time_zone).tzinfo\n", - "report_title, report_date, report_time, report_timezone\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "id": "9363f19a", - "metadata": {}, - "source": [ - "## Data\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "id": "0b9ec3f9", - "metadata": {}, - "source": [ - "Summary\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e3b15d6f-dc9e-4f97-aa07-37d949a4e4bb", - "metadata": {}, - "outputs": [], - "source": [ - "overview = openbb.economy.overview()\n", - "overview.set_index(list(overview.columns[0]), inplace=True)\n", - "overview = OpenBBFigure.to_table(overview, print_index=True, width=600)\n", - "\n", - "futures = openbb.economy.futures()\n", - "futures.set_index(list(futures.columns[0]), inplace=True)\n", - "futures[\"%Chg\"] = futures[\"%Chg\"].apply(lambda x: float(f\"{x:.2f}\"))\n", - "futures_fig = OpenBBFigure.to_table(futures, print_index=True)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "351d0451", - "metadata": {}, - "outputs": [], - "source": [ - "try:\n", - " news = openbb.news(\"economy\")\n", - " news.columns = news.columns.str.title()\n", - " news = news.rename(\n", - " columns={\"Date\": \"Published\", \"Description\": \"Title\", \"Url\": \"Link\"}\n", - " )\n", - " news[\"Title\"] = news.apply(\n", - " lambda x: f'{x[\"Title\"]}', axis=1\n", - " )\n", - " news = news[[\"Title\", \"Published\"]]\n", - " news[\"Published\"] = pd.to_datetime(news[\"Published\"]).dt.strftime(\"%Y-%m-%d %H:%M\")\n", - " news = news.set_index(\"Published\")\n", - "except:\n", - " news = pd.DataFrame()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "64729474", - "metadata": {}, - "outputs": [], - "source": [ - "rtps_data = openbb.economy.rtps()\n", - "subplots = OpenBBFigure.create_subplots(1, 2, horizontal_spacing=0.15)\n", - "openbb.economy.rtps_chart(external_axes=True).to_subplot(subplots, 1, 1)\n", - "\n", - "chg = futures[\"%Chg\"]\n", - "colors = [theme.up_color if x > 0 else theme.down_color for x in list(chg.values)]\n", - "subplots.add_bar(\n", - " y=chg.index,\n", - " x=chg.values,\n", - " orientation=\"h\",\n", - " marker_color=colors,\n", - " showlegend=False,\n", - " row=1,\n", - " col=2,\n", - ")\n", - "subplots.update_xaxes(title_text=\"Performance (%)\", row=1, col=1)\n", - "subplots.update_xaxes(title_text=\"Change %\", row=1, col=2)\n", - "subplots.update_layout(margin=dict(l=0, r=0, t=0, b=0), yaxis=dict(side=\"left\", nticks=15), yaxis2=dict(nticks=15))\n", - "chart_0 = subplots.to_html()\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "id": "7315ac99", - "metadata": {}, - "source": [ - "Events\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a02c6166", - "metadata": {}, - "outputs": [], - "source": [ - "events_1 = openbb.economy.events(\n", - " countries=\"United States\",\n", - " start_date=datetime.datetime.now().strftime(\"%Y-%m-%d\"),\n", - ")\n", - "if not events_1.empty:\n", - " events_1 = OpenBBFigure.to_table(\n", - " events_1.set_index(\"Date\"), print_index=True, height=200\n", - " )\n", - "\n", - "events_2 = openbb.economy.events(\n", - " countries=[\n", - " \"Germany\",\n", - " \"Spain\",\n", - " \"Italy\",\n", - " \"United Kingdom\",\n", - " \"France\",\n", - " \"Portugal\",\n", - " \"Greece\",\n", - " ],\n", - " start_date=datetime.datetime.now().strftime(\"%Y-%m-%d\"),\n", - ")\n", - "if not events_2.empty:\n", - " events_2 = OpenBBFigure.to_table(events_2.set_index(\"Date\"), print_index=True)\n", - "\n", - "events_3 = openbb.economy.events(\n", - " countries=\"China\",\n", - " start_date=datetime.datetime.now().strftime(\"%Y-%m-%d\"),\n", - ")\n", - "if not events_3.empty:\n", - " events_3 = OpenBBFigure.to_table(events_3.set_index(\"Date\"), print_index=True)\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "id": "f1863bd0", - "metadata": {}, - "source": [ - "Yields\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8e332ca6", - "metadata": {}, - "outputs": [], - "source": [ - "ycrv = openbb.fixedincome.ycrv(return_date=True)\n", - "\n", - "if (isinstance(ycrv, pd.DataFrame) and not ycrv.empty) or (\n", - " not isinstance(ycrv, pd.DataFrame) and ycrv\n", - "):\n", - " ycrv_data_1, _ = ycrv\n", - " ycrv_country_1 = \"United states\"\n", - "\n", - " ycrv_chart_1 = openbb.fixedincome.ycrv_chart(external_axes=True)\n", - "\n", - " if ycrv_chart_1:\n", - " ycrv_chart_1 = ycrv_chart_1.to_html()\n", - "\n", - " if not ycrv_data_1.empty:\n", - " ycrv_data_1.drop([\"Maturity\"], axis=1, inplace=True)\n", - " ycrv_data_1.index = [\n", - " \"1M\",\n", - " \"3M\",\n", - " \"6M\",\n", - " \"1Y\",\n", - " \"2Y\",\n", - " \"3Y\",\n", - " \"5Y\",\n", - " \"7Y\",\n", - " \"10Y\",\n", - " \"20Y\",\n", - " \"30Y\",\n", - " ]\n", - "else:\n", - " ycrv = None\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "31fb0f86", - "metadata": {}, - "outputs": [], - "source": [ - "openbb.economy.treasury_maturities()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c4f987af", - "metadata": {}, - "outputs": [], - "source": [ - "subplots = OpenBBFigure.create_subplots(\n", - " 2,\n", - " 2,\n", - " vertical_spacing=0.15,\n", - " row_heights=[0.5, 0.5],\n", - " subplot_titles=(\"UST 2y-10y\", \"UST 10y-30y\", \"Nominal vs TIPS\"),\n", - " specs=[[{\"type\": \"xy\"}, {\"type\": \"xy\"}], [{\"colspan\": 2}, None]],\n", - ")\n", - "openbb.economy.treasury_chart(\n", - " instruments=[\"nominal\"],\n", - " maturities=[\"2y\", \"10y\"],\n", - " frequency=\"daily\",\n", - " start_date=\"2020-01-01\",\n", - " external_axes=True,\n", - ").to_subplot(subplots, 1, 1)\n", - "\n", - "openbb.economy.treasury_chart(\n", - " instruments=[\"nominal\"],\n", - " maturities=[\"10y\", \"30y\"],\n", - " frequency=\"daily\",\n", - " start_date=\"2020-01-01\",\n", - " external_axes=True,\n", - ").to_subplot(subplots, 1, 2)\n", - "\n", - "openbb.economy.treasury_chart(\n", - " instruments=[\"nominal\", \"inflation\"],\n", - " maturities=[\"10y\"],\n", - " frequency=\"daily\",\n", - " start_date=\"2020-01-01\",\n", - " external_axes=True,\n", - ").to_subplot(subplots, 2, 1)\n", - "\n", - "subplots.update_traces(legend=\"legend\", row=1, col=1)\n", - "subplots.update_traces(legend=\"legend2\", row=1, col=2)\n", - "subplots.update_traces(legend=\"legend3\", row=2, col=1)\n", - "defaults = dict(\n", - " xanchor=\"left\",\n", - " yanchor=\"top\",\n", - " xref=\"paper\",\n", - " yref=\"paper\",\n", - " bgcolor=\"rgba(0, 0, 0, 0)\",\n", - ")\n", - "subplots.update_layout(\n", - " legend=dict(x=0.01, y=0.99, **defaults),\n", - " legend2=dict(x=0.562, y=0.99, **defaults),\n", - " legend3=dict(x=0.01, y=0.41, **defaults),\n", - ")\n", - "\n", - "\n", - "ust = subplots.to_html()\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "id": "7a3c421f", - "metadata": {}, - "source": [ - "Equity Market\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "12c98e06", - "metadata": {}, - "outputs": [], - "source": [ - "valuation = OpenBBFigure.to_table(openbb.economy.valuation(), print_index=False)\n", - "performance = OpenBBFigure.to_table(openbb.economy.performance(), print_index=False)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "42f5570d", - "metadata": {}, - "outputs": [], - "source": [ - "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", - "data = openbb.economy.index(\n", - " indices=[\"sp500\", \"dow_djus\", \"nasdaq100\", \"russell3000\", \"cboe_vix\"],\n", - " start_date=\"2000-03-09\",\n", - ")\n", - "\n", - "data = data.pct_change().dropna()\n", - "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", - "for col in data.columns:\n", - " fig.add_scatter(\n", - " x=data.index,\n", - " y=data[col] * 100,\n", - " name=col,\n", - " )\n", - "\n", - "eqty_0 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "286a82d7", - "metadata": {}, - "outputs": [], - "source": [ - "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", - "data = openbb.economy.index(\n", - " indices=[\"ftse100\", \"de_dax40\", \"fr_cac40\", \"it_mib40\", \"es_ibex35\"],\n", - " start_date=\"2000-01-01\",\n", - ")\n", - "\n", - "data = data.pct_change().dropna()\n", - "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", - "for col in data.columns:\n", - " fig.add_scatter(\n", - " x=data.index,\n", - " y=data[col] * 100,\n", - " name=col,\n", - " )\n", - "\n", - "eqty_1 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e825e8ed", - "metadata": {}, - "outputs": [], - "source": [ - "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", - "data = openbb.economy.index(\n", - " indices=[\"jp_n225\", \"cn_csi300\", \"hk_china\", \"au_asx50\"], start_date=\"2014-01-01\"\n", - ")\n", - "\n", - "data = data.pct_change().dropna()\n", - "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", - "for col in data.columns:\n", - " fig.add_scatter(\n", - " x=data.index,\n", - " y=data[col] * 100,\n", - " name=col,\n", - " )\n", - "\n", - "eqty_2 = fig.update_layout(margin=dict(l=0, r=60), legend=dict(x=1.1)).to_html()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8eb1327b", - "metadata": {}, - "outputs": [], - "source": [ - "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", - "data = openbb.economy.index(\n", - " indices=[\"in_nse50\", \"br_bvsp\", \"za_jo\", \"mx_ipc\", \"ru_moex\"],\n", - " start_date=\"2013-01-01\",\n", - ")\n", - "\n", - "data = data.pct_change().dropna()\n", - "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", - "for col in data.columns:\n", - " fig.add_scatter(\n", - " x=data.index,\n", - " y=data[col] * 100,\n", - " name=col,\n", - " )\n", - "\n", - "eqty_3 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "02630bd6", - "metadata": {}, - "outputs": [], - "source": [ - "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", - "data = openbb.economy.index(indices=[\"arca_xoi\", \"arca_pse\"], start_date=\"2000-01-01\")\n", - "\n", - "data = data.pct_change().dropna()\n", - "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", - "for col in data.columns:\n", - " fig.add_scatter(\n", - " x=data.index,\n", - " y=data[col] * 100,\n", - " name=col,\n", - " )\n", - "\n", - "eqty_4 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5a4c8963", - "metadata": {}, - "outputs": [], - "source": [ - "bigmac_res = openbb.economy.bigmac()\n", - "\n", - "if (isinstance(bigmac_res, pd.DataFrame) and not bigmac_res.empty) or (\n", - " not isinstance(bigmac_res, pd.DataFrame) and bigmac_res\n", - "):\n", - " bigmac = openbb.economy.bigmac_chart(\n", - " country_codes=[\n", - " \"USA\",\n", - " \"CAN\",\n", - " \"ARG\",\n", - " \"PRT\",\n", - " \"NLD\",\n", - " \"FRA\",\n", - " \"UAE\",\n", - " \"LKA\",\n", - " \"VNM\",\n", - " \"RUS\",\n", - " \"SWE\",\n", - " \"GBR\",\n", - " ],\n", - " external_axes=True,\n", - " )\n", - " if bigmac:\n", - " bigmac.set_title(\"\")\n", - " bigmac = bigmac.update_layout(margin=dict(l=0, r=60), legend=dict(x=1.1)).to_html()\n", - "\n", - "else:\n", - " bigmac_res = pd.DataFrame()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1947a06c", - "metadata": {}, - "outputs": [], - "source": [ - "subplots = OpenBBFigure.create_subplots(1, 1, specs=[[{\"secondary_y\": True}]])\n", - "\n", - "openbb.economy.macro_chart(\n", - " parameters=[\"CONF\", \"IP\"], start_date=\"2010-01-01\", external_axes=True\n", - ").to_subplot(subplots, 1, 1, secondary_y=False)\n", - "subplots.update_yaxes(title_text=\"Confidence and IP\", secondary_y=False)\n", - "\n", - "\n", - "df, df_dict, _ = openbb.economy.macro(parameters=[\"CPI\"], start_date=\"2010-01-01\")\n", - "cpi_chg = df.pct_change(1) * 100\n", - "subplots.add_scatter(\n", - " x=cpi_chg.index,\n", - " y=cpi_chg.T.values[0],\n", - " name=\"CPI (% change)\",\n", - " mode=\"lines\",\n", - " line=dict(color=\"red\", dash=\"dash\"),\n", - " secondary_y=True,\n", - " yaxis=\"y2\",\n", - ")\n", - "subplots.update_yaxes(\n", - " title_text=\"CPI (% change)\",\n", - " secondary_y=True,\n", - " range=[-2, 2],\n", - " side=\"left\",\n", - " overlaying=\"y\",\n", - ")\n", - "subplots.horizontal_legend()\n", - "\n", - "macro_0 = subplots.to_html()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "971e4c51", - "metadata": {}, - "outputs": [], - "source": [ - "fred = openbb.economy.fred(series_ids=[\"T10Y3M\"], start_date=\"1980-01-01\")\n", - "\n", - "if (isinstance(fred, pd.DataFrame) and not fred.empty) or (\n", - " not isinstance(fred, pd.DataFrame) and fred\n", - "):\n", - " df, df_dict = fred\n", - "\n", - " fig = OpenBBFigure.create_subplots(1, 1, specs=[[{\"secondary_y\": True}]])\n", - " fig.add_scatter(\n", - " x=df.index,\n", - " y=df[\"T10Y3M\"],\n", - " name=df_dict[\"T10Y3M\"][\"title\"],\n", - " line=dict(color=\"red\", dash=\"dash\"),\n", - " secondary_y=False,\n", - " )\n", - " openbb.economy.fred_chart(\n", - " series_ids=[\"A191RP1A027NBEA\"],\n", - " start_date=\"1980-01-01\",\n", - " external_axes=True,\n", - " ).to_subplot(fig, 1, 1, secondary_y=True)\n", - " fig.update_yaxes(secondary_y=True, side=\"left\", overlaying=\"y\")\n", - " fig.set_title(\"\")\n", - " fig.horizontal_legend()\n", - "\n", - " fred_0 = fig.to_html()\n", - "else:\n", - " fred = None\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "id": "ac501a32-124d-4d21-aae1-a8d147bb1071", - "metadata": {}, - "source": [ - "## Render the report template to a file\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "abfe37e4-ea38-42c3-8fb5-7cceb233fb12", - "metadata": {}, - "outputs": [], - "source": [ - "body = \"\"\n", - "\n", - "\n", - "body += widgets.header(\n", - " author,\n", - " report_date,\n", - " report_time,\n", - " report_timezone,\n", - " f\"ECONOMY REPORT: Leverage multiple sources to create custom reports.\",\n", - " plotly_js=True,\n", - ")\n", - "\n", - "body += widgets.tablinks(\n", - " [\n", - " \"SUMMARY\",\n", - " \"Events\",\n", - " \"Yields\",\n", - " \"Equity Market\",\n", - " \"Macro Data\",\n", - " ]\n", - ")\n", - "\n", - "# Summary\n", - "htmlcode = widgets.row(\n", - " [widgets.h(3, \"Global markets (source: WSJ)\") + overview.to_html()]\n", - ")\n", - "\n", - "htmlcode += widgets.row(\n", - " [widgets.h(3, \"Commodities (source: WSJ)\") + futures_fig.to_html()]\n", - " + [\n", - " widgets.h(3, \"Real-time sector performance (source: Alphavantage)\")\n", - " + rtps_data.to_html().replace(\"table\", 'table style=\"display:inline\"')\n", - " ]\n", - ")\n", - "htmlcode += widgets.row([chart_0])\n", - "\n", - "if not news.empty:\n", - " htmlcode += widgets.row(\n", - " [\n", - " widgets.h(3, \"Top news on 'economy' keyword (source: Feedparser)\")\n", - " + news.to_html(escape=False)\n", - " ]\n", - " )\n", - "\n", - "body += widgets.add_tab(\"SUMMARY\", htmlcode)\n", - "\n", - "# Events\n", - "htmlcode = widgets.row([widgets.h(3, \"Economic calendars (source: investing.com)\")])\n", - "htmlcode += widgets.row([widgets.h(3, \"United States\") + events_1.to_html()])\n", - "htmlcode += widgets.row(\n", - " [widgets.h(3, \"Select European Countries\") + events_2.to_html()]\n", - ")\n", - "htmlcode += widgets.row([widgets.h(3, \"China\") + events_3.to_html()])\n", - "body += widgets.add_tab(\"Events\", htmlcode)\n", - "\n", - "# Yields\n", - "htmlcode = widgets.row([widgets.h(3, \"US treasuries (source: EconDB)\") + ust])\n", - "\n", - "if ycrv:\n", - " htmlcode += widgets.row(\n", - " [\n", - " widgets.h(3, f\"{ycrv_country_1} yield curve (source: FRED)\")\n", - " + (ycrv_chart_1 or \"\")\n", - " ]\n", - " )\n", - " htmlcode += widgets.row([widgets.h(3, \"\") + ycrv_data_1.to_html()])\n", - "\n", - "body += widgets.add_tab(\"Yields\", htmlcode)\n", - "\n", - "# Equity market\n", - "htmlcode = widgets.row(\n", - " [widgets.h(3, \"Valuation (source: Finviz)\") + valuation.to_html()]\n", - ")\n", - "htmlcode += widgets.row(\n", - " [widgets.h(3, \"Performance (source: Finviz)\") + valuation.to_html()]\n", - ")\n", - "htmlcode += widgets.row([widgets.h(3, \"US markets (source: YahooFinance)\") + eqty_0])\n", - "htmlcode += widgets.row(\n", - " [widgets.h(3, \"European markets (source: YahooFinance)\") + eqty_1]\n", - ")\n", - "htmlcode += widgets.row([widgets.h(3, \"APAC markets (source: YahooFinance)\") + eqty_2])\n", - "htmlcode += widgets.row(\n", - " [widgets.h(3, \"Emerging markets (source: YahooFinance)\") + eqty_3]\n", - ")\n", - "htmlcode += widgets.row([widgets.h(3, \"ARCA (source: YahooFinance)\") + eqty_4])\n", - "body += widgets.add_tab(\"Equity Market\", htmlcode)\n", - "\n", - "# Macro\n", - "htmlcode = \"\"\n", - "if not bigmac_res.empty:\n", - " htmlcode += widgets.row(\n", - " [widgets.h(3, \"Bigmac index (source: Nasdaq)\") + (bigmac or \"\")]\n", - " )\n", - "htmlcode += widgets.row([widgets.h(3, \"Leading indicators (source: EconDB)\") + macro_0])\n", - "if fred:\n", - " htmlcode += widgets.row(\n", - " [widgets.h(3, \"Recession indicator (source: FRED)\") + fred_0]\n", - " )\n", - "body += widgets.add_tab(\"Macro Data\", htmlcode)\n", - "\n", - "body += widgets.tab_clickable_and_save_evt()\n", - "report = widgets.html_report(title=report_name, stylesheet=stylesheet, body=body)\n", - "\n", - "# to save the results\n", - "with open(report_name + \".html\", \"w\", encoding=\"utf-8\") as fh:\n", - " fh.write(report)\n" - ] - } - ], - "metadata": { - "celltoolbar": "Tags", - "kernelspec": { - "display_name": "venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" - }, - "vscode": { - "interpreter": { - "hash": "381a209f752e9104bff95ec5e80679ea2e476866b80e4326f1ee6b7658af6049" - } - } + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "id": "70ba2c8a", + "metadata": {}, + "source": [ + "## Notebook setup\n" + ] }, - "nbformat": 4, - "nbformat_minor": 5 + { + "cell_type": "code", + "execution_count": null, + "id": "driven-billion", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import io\n", + "import warnings\n", + "import datetime\n", + "import numpy as np\n", + "import pandas as pd\n", + "import base64\n", + "import pytz\n", + "\n", + "from IPython.display import HTML\n", + "\n", + "import openbb_terminal.config_terminal as cfg\n", + "from openbb_terminal.helper_funcs import get_user_timezone\n", + "from openbb_terminal import OpenBBFigure, theme\n", + "from openbb_terminal.helper_classes import TerminalStyle\n", + "\n", + "\n", + "warnings.filterwarnings(\"ignore\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4494cd3e", + "metadata": {}, + "outputs": [], + "source": [ + "# Suppressing sdk logs\n", + "from openbb_terminal.core.session.current_system import set_system_variable\n", + "\n", + "set_system_variable(\"LOGGING_SUPPRESS\", True)\n", + "\n", + "# Import the OpenBB SDK\n", + "from openbb_terminal.sdk import openbb, widgets" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f9feebc8", + "metadata": {}, + "outputs": [], + "source": [ + "from openbb_terminal.core.session.current_user import get_current_user\n", + "\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", + ")\n", + "theme.apply_style(\"light\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e6e39973", + "metadata": {}, + "outputs": [], + "source": [ + "stylesheet = widgets.html_report_stylesheet()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "daef64ec", + "metadata": { + "tags": [ + "parameters" + ] + }, + "outputs": [], + "source": [ + "# Parameters that will be replaced when calling this notebook\n", + "# Do not leave parameters blank as notebook will not run otherwise\n", + "report_name = \"economy_report\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1be26dae-cafe-4a22-80aa-eff296fc1a9b", + "metadata": {}, + "outputs": [], + "source": [ + "author = \"OpenBB\"\n", + "report_title = f\"Economy report\"\n", + "user_time_zone = pytz.timezone(get_user_timezone())\n", + "report_date = pd.Timestamp.now(tz=user_time_zone).strftime(\"%d %B, %Y\")\n", + "report_time = pd.Timestamp.now(tz=user_time_zone).strftime(\"%H:%M\")\n", + "report_timezone = pd.Timestamp.now(tz=user_time_zone).tzinfo\n", + "report_title, report_date, report_time, report_timezone" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "id": "9363f19a", + "metadata": {}, + "source": [ + "## Data\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "id": "0b9ec3f9", + "metadata": {}, + "source": [ + "Summary\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e3b15d6f-dc9e-4f97-aa07-37d949a4e4bb", + "metadata": {}, + "outputs": [], + "source": [ + "overview = openbb.economy.overview()\n", + "overview.set_index(list(overview.columns[0]), inplace=True)\n", + "overview = OpenBBFigure.to_table(overview, print_index=True, width=600)\n", + "\n", + "futures = openbb.economy.futures()\n", + "futures.set_index(list(futures.columns[0]), inplace=True)\n", + "futures[\"%Chg\"] = futures[\"%Chg\"].apply(lambda x: float(f\"{x:.2f}\"))\n", + "futures_fig = OpenBBFigure.to_table(futures, print_index=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "351d0451", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " news = openbb.news(\"economy\")\n", + " news.columns = news.columns.str.title()\n", + " news = news.rename(\n", + " columns={\"Date\": \"Published\", \"Description\": \"Title\", \"Url\": \"Link\"}\n", + " )\n", + " news[\"Title\"] = news.apply(\n", + " lambda x: f'{x[\"Title\"]}', axis=1\n", + " )\n", + " news = news[[\"Title\", \"Published\"]]\n", + " news[\"Published\"] = pd.to_datetime(news[\"Published\"]).dt.strftime(\"%Y-%m-%d %H:%M\")\n", + " news = news.set_index(\"Published\")\n", + "except:\n", + " news = pd.DataFrame()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64729474", + "metadata": {}, + "outputs": [], + "source": [ + "rtps_data = openbb.economy.rtps()\n", + "subplots = OpenBBFigure.create_subplots(1, 2, horizontal_spacing=0.15)\n", + "openbb.economy.rtps_chart(external_axes=True).to_subplot(subplots, 1, 1)\n", + "\n", + "chg = futures[\"%Chg\"]\n", + "colors = [theme.up_color if x > 0 else theme.down_color for x in list(chg.values)]\n", + "subplots.add_bar(\n", + " y=chg.index,\n", + " x=chg.values,\n", + " orientation=\"h\",\n", + " marker_color=colors,\n", + " showlegend=False,\n", + " row=1,\n", + " col=2,\n", + ")\n", + "subplots.update_xaxes(title_text=\"Performance (%)\", row=1, col=1)\n", + "subplots.update_xaxes(title_text=\"Change %\", row=1, col=2)\n", + "subplots.update_layout(\n", + " margin=dict(l=0, r=0, t=0, b=0),\n", + " yaxis=dict(side=\"left\", nticks=15),\n", + " yaxis2=dict(nticks=15),\n", + ")\n", + "chart_0 = subplots.to_html()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "id": "7315ac99", + "metadata": {}, + "source": [ + "Events\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a02c6166", + "metadata": {}, + "outputs": [], + "source": [ + "events_1 = openbb.economy.events(\n", + " countries=\"United States\",\n", + " start_date=datetime.datetime.now().strftime(\"%Y-%m-%d\"),\n", + ")\n", + "if not events_1.empty:\n", + " events_1 = OpenBBFigure.to_table(\n", + " events_1.set_index(\"Date\"), print_index=True, height=200\n", + " )\n", + "\n", + "events_2 = openbb.economy.events(\n", + " countries=[\n", + " \"Germany\",\n", + " \"Spain\",\n", + " \"Italy\",\n", + " \"United Kingdom\",\n", + " \"France\",\n", + " \"Portugal\",\n", + " \"Greece\",\n", + " ],\n", + " start_date=datetime.datetime.now().strftime(\"%Y-%m-%d\"),\n", + ")\n", + "if not events_2.empty:\n", + " events_2 = OpenBBFigure.to_table(events_2.set_index(\"Date\"), print_index=True)\n", + "\n", + "events_3 = openbb.economy.events(\n", + " countries=\"China\",\n", + " start_date=datetime.datetime.now().strftime(\"%Y-%m-%d\"),\n", + ")\n", + "if not events_3.empty:\n", + " events_3 = OpenBBFigure.to_table(events_3.set_index(\"Date\"), print_index=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "id": "f1863bd0", + "metadata": {}, + "source": [ + "Yields\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8e332ca6", + "metadata": {}, + "outputs": [], + "source": [ + "ycrv = openbb.fixedincome.ycrv(return_date=True)\n", + "\n", + "if (isinstance(ycrv, pd.DataFrame) and not ycrv.empty) or (\n", + " not isinstance(ycrv, pd.DataFrame) and ycrv\n", + "):\n", + " ycrv_data_1, _ = ycrv\n", + " ycrv_country_1 = \"United states\"\n", + "\n", + " ycrv_chart_1 = openbb.fixedincome.ycrv_chart(external_axes=True)\n", + "\n", + " if ycrv_chart_1:\n", + " ycrv_chart_1 = ycrv_chart_1.to_html()\n", + "\n", + " if not ycrv_data_1.empty:\n", + " ycrv_data_1.drop([\"Maturity\"], axis=1, inplace=True)\n", + " ycrv_data_1.index = [\n", + " \"1M\",\n", + " \"3M\",\n", + " \"6M\",\n", + " \"1Y\",\n", + " \"2Y\",\n", + " \"3Y\",\n", + " \"5Y\",\n", + " \"7Y\",\n", + " \"10Y\",\n", + " \"20Y\",\n", + " \"30Y\",\n", + " ]\n", + "else:\n", + " ycrv = None" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "31fb0f86", + "metadata": {}, + "outputs": [], + "source": [ + "openbb.economy.treasury_maturities()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c4f987af", + "metadata": {}, + "outputs": [], + "source": [ + "subplots = OpenBBFigure.create_subplots(\n", + " 2,\n", + " 2,\n", + " vertical_spacing=0.15,\n", + " row_heights=[0.5, 0.5],\n", + " subplot_titles=(\"UST 2y-10y\", \"UST 10y-30y\", \"Nominal vs TIPS\"),\n", + " specs=[[{\"type\": \"xy\"}, {\"type\": \"xy\"}], [{\"colspan\": 2}, None]],\n", + ")\n", + "openbb.economy.treasury_chart(\n", + " instruments=[\"nominal\"],\n", + " maturities=[\"2y\", \"10y\"],\n", + " frequency=\"daily\",\n", + " start_date=\"2020-01-01\",\n", + " external_axes=True,\n", + ").to_subplot(subplots, 1, 1)\n", + "\n", + "openbb.economy.treasury_chart(\n", + " instruments=[\"nominal\"],\n", + " maturities=[\"10y\", \"30y\"],\n", + " frequency=\"daily\",\n", + " start_date=\"2020-01-01\",\n", + " external_axes=True,\n", + ").to_subplot(subplots, 1, 2)\n", + "\n", + "openbb.economy.treasury_chart(\n", + " instruments=[\"nominal\", \"inflation\"],\n", + " maturities=[\"10y\"],\n", + " frequency=\"daily\",\n", + " start_date=\"2020-01-01\",\n", + " external_axes=True,\n", + ").to_subplot(subplots, 2, 1)\n", + "\n", + "subplots.update_traces(legend=\"legend\", row=1, col=1)\n", + "subplots.update_traces(legend=\"legend2\", row=1, col=2)\n", + "subplots.update_traces(legend=\"legend3\", row=2, col=1)\n", + "defaults = dict(\n", + " xanchor=\"left\",\n", + " yanchor=\"top\",\n", + " xref=\"paper\",\n", + " yref=\"paper\",\n", + " bgcolor=\"rgba(0, 0, 0, 0)\",\n", + ")\n", + "subplots.update_layout(\n", + " legend=dict(x=0.01, y=0.99, **defaults),\n", + " legend2=dict(x=0.562, y=0.99, **defaults),\n", + " legend3=dict(x=0.01, y=0.41, **defaults),\n", + ")\n", + "\n", + "\n", + "ust = subplots.to_html()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "id": "7a3c421f", + "metadata": {}, + "source": [ + "Equity Market\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "12c98e06", + "metadata": {}, + "outputs": [], + "source": [ + "valuation = OpenBBFigure.to_table(openbb.economy.valuation(), print_index=False)\n", + "performance = OpenBBFigure.to_table(openbb.economy.performance(), print_index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "42f5570d", + "metadata": {}, + "outputs": [], + "source": [ + "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", + "data = openbb.economy.index(\n", + " indices=[\"sp500\", \"dow_djus\", \"nasdaq100\", \"russell3000\", \"cboe_vix\"],\n", + " start_date=\"2000-03-09\",\n", + ")\n", + "\n", + "data = data.pct_change().dropna()\n", + "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", + "for col in data.columns:\n", + " fig.add_scatter(\n", + " x=data.index,\n", + " y=data[col] * 100,\n", + " name=col,\n", + " )\n", + "\n", + "eqty_0 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "286a82d7", + "metadata": {}, + "outputs": [], + "source": [ + "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", + "data = openbb.economy.index(\n", + " indices=[\"ftse100\", \"de_dax40\", \"fr_cac40\", \"it_mib40\", \"es_ibex35\"],\n", + " start_date=\"2000-01-01\",\n", + ")\n", + "\n", + "data = data.pct_change().dropna()\n", + "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", + "for col in data.columns:\n", + " fig.add_scatter(\n", + " x=data.index,\n", + " y=data[col] * 100,\n", + " name=col,\n", + " )\n", + "\n", + "eqty_1 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e825e8ed", + "metadata": {}, + "outputs": [], + "source": [ + "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", + "data = openbb.economy.index(\n", + " indices=[\"jp_n225\", \"cn_csi300\", \"hk_china\", \"au_asx50\"], start_date=\"2014-01-01\"\n", + ")\n", + "\n", + "data = data.pct_change().dropna()\n", + "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", + "for col in data.columns:\n", + " fig.add_scatter(\n", + " x=data.index,\n", + " y=data[col] * 100,\n", + " name=col,\n", + " )\n", + "\n", + "eqty_2 = fig.update_layout(margin=dict(l=0, r=60), legend=dict(x=1.1)).to_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8eb1327b", + "metadata": {}, + "outputs": [], + "source": [ + "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", + "data = openbb.economy.index(\n", + " indices=[\"in_nse50\", \"br_bvsp\", \"za_jo\", \"mx_ipc\", \"ru_moex\"],\n", + " start_date=\"2013-01-01\",\n", + ")\n", + "\n", + "data = data.pct_change().dropna()\n", + "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", + "for col in data.columns:\n", + " fig.add_scatter(\n", + " x=data.index,\n", + " y=data[col] * 100,\n", + " name=col,\n", + " )\n", + "\n", + "eqty_3 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "02630bd6", + "metadata": {}, + "outputs": [], + "source": [ + "fig = OpenBBFigure(yaxis_title=\"Cumulative returns (%)\")\n", + "data = openbb.economy.index(indices=[\"arca_xoi\", \"arca_pse\"], start_date=\"2000-01-01\")\n", + "\n", + "data = data.pct_change().dropna()\n", + "data = (1 + data.shift(periods=1, fill_value=0)).cumprod() - 1\n", + "for col in data.columns:\n", + " fig.add_scatter(\n", + " x=data.index,\n", + " y=data[col] * 100,\n", + " name=col,\n", + " )\n", + "\n", + "eqty_4 = fig.update_layout(margin=dict(l=20, r=60), legend=dict(x=1.1)).to_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a4c8963", + "metadata": {}, + "outputs": [], + "source": [ + "bigmac_res = openbb.economy.bigmac()\n", + "\n", + "if (isinstance(bigmac_res, pd.DataFrame) and not bigmac_res.empty) or (\n", + " not isinstance(bigmac_res, pd.DataFrame) and bigmac_res\n", + "):\n", + " bigmac = openbb.economy.bigmac_chart(\n", + " country_codes=[\n", + " \"USA\",\n", + " \"CAN\",\n", + " \"ARG\",\n", + " \"PRT\",\n", + " \"NLD\",\n", + " \"FRA\",\n", + " \"UAE\",\n", + " \"LKA\",\n", + " \"VNM\",\n", + " \"RUS\",\n", + " \"SWE\",\n", + " \"GBR\",\n", + " ],\n", + " external_axes=True,\n", + " )\n", + " if bigmac:\n", + " bigmac.set_title(\"\")\n", + " bigmac = bigmac.update_layout(\n", + " margin=dict(l=0, r=60), legend=dict(x=1.1)\n", + " ).to_html()\n", + "\n", + "else:\n", + " bigmac_res = pd.DataFrame()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1947a06c", + "metadata": {}, + "outputs": [], + "source": [ + "subplots = OpenBBFigure.create_subplots(1, 1, specs=[[{\"secondary_y\": True}]])\n", + "\n", + "openbb.economy.macro_chart(\n", + " parameters=[\"CONF\", \"IP\"], start_date=\"2010-01-01\", external_axes=True\n", + ").to_subplot(subplots, 1, 1, secondary_y=False)\n", + "subplots.update_yaxes(title_text=\"Confidence and IP\", secondary_y=False)\n", + "\n", + "\n", + "df, df_dict, _ = openbb.economy.macro(parameters=[\"CPI\"], start_date=\"2010-01-01\")\n", + "cpi_chg = df.pct_change(1) * 100\n", + "subplots.add_scatter(\n", + " x=cpi_chg.index,\n", + " y=cpi_chg.T.values[0],\n", + " name=\"CPI (% change)\",\n", + " mode=\"lines\",\n", + " line=dict(color=\"red\", dash=\"dash\"),\n", + " secondary_y=True,\n", + " yaxis=\"y2\",\n", + ")\n", + "subplots.update_yaxes(\n", + " title_text=\"CPI (% change)\",\n", + " secondary_y=True,\n", + " range=[-2, 2],\n", + " side=\"left\",\n", + " overlaying=\"y\",\n", + ")\n", + "subplots.horizontal_legend()\n", + "\n", + "macro_0 = subplots.to_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "971e4c51", + "metadata": {}, + "outputs": [], + "source": [ + "fred = openbb.economy.fred(series_ids=[\"T10Y3M\"], start_date=\"1980-01-01\")\n", + "\n", + "if (isinstance(fred, pd.DataFrame) and not fred.empty) or (\n", + " not isinstance(fred, pd.DataFrame) and fred\n", + "):\n", + " df, df_dict = fred\n", + "\n", + " fig = OpenBBFigure.create_subplots(1, 1, specs=[[{\"secondary_y\": True}]])\n", + " fig.add_scatter(\n", + " x=df.index,\n", + " y=df[\"T10Y3M\"],\n", + " name=df_dict[\"T10Y3M\"][\"title\"],\n", + " line=dict(color=\"red\", dash=\"dash\"),\n", + " secondary_y=False,\n", + " )\n", + " openbb.economy.fred_chart(\n", + " series_ids=[\"A191RP1A027NBEA\"],\n", + " start_date=\"1980-01-01\",\n", + " external_axes=True,\n", + " ).to_subplot(fig, 1, 1, secondary_y=True)\n", + " fig.update_yaxes(secondary_y=True, side=\"left\", overlaying=\"y\")\n", + " fig.set_title(\"\")\n", + " fig.horizontal_legend()\n", + "\n", + " fred_0 = fig.to_html()\n", + "else:\n", + " fred = None" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "id": "ac501a32-124d-4d21-aae1-a8d147bb1071", + "metadata": {}, + "source": [ + "## Render the report template to a file\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "abfe37e4-ea38-42c3-8fb5-7cceb233fb12", + "metadata": {}, + "outputs": [], + "source": [ + "body = \"\"\n", + "\n", + "\n", + "body += widgets.header(\n", + " author,\n", + " report_date,\n", + " report_time,\n", + " report_timezone,\n", + " f\"ECONOMY REPORT: Leverage multiple sources to create custom reports.\",\n", + " plotly_js=True,\n", + ")\n", + "\n", + "body += widgets.tablinks(\n", + " [\n", + " \"SUMMARY\",\n", + " \"Events\",\n", + " \"Yields\",\n", + " \"Equity Market\",\n", + " \"Macro Data\",\n", + " ]\n", + ")\n", + "\n", + "# Summary\n", + "htmlcode = widgets.row(\n", + " [widgets.h(3, \"Global markets (source: WSJ)\") + overview.to_html()]\n", + ")\n", + "\n", + "htmlcode += widgets.row(\n", + " [widgets.h(3, \"Commodities (source: WSJ)\") + futures_fig.to_html()]\n", + " + [\n", + " widgets.h(3, \"Real-time sector performance (source: Alphavantage)\")\n", + " + rtps_data.to_html().replace(\"table\", 'table style=\"display:inline\"')\n", + " ]\n", + ")\n", + "htmlcode += widgets.row([chart_0])\n", + "\n", + "if not news.empty:\n", + " htmlcode += widgets.row(\n", + " [\n", + " widgets.h(3, \"Top news on 'economy' keyword (source: Feedparser)\")\n", + " + news.to_html(escape=False)\n", + " ]\n", + " )\n", + "\n", + "body += widgets.add_tab(\"SUMMARY\", htmlcode)\n", + "\n", + "# Events\n", + "htmlcode = widgets.row([widgets.h(3, \"Economic calendars (source: investing.com)\")])\n", + "htmlcode += widgets.row([widgets.h(3, \"United States\") + events_1.to_html()])\n", + "htmlcode += widgets.row(\n", + " [widgets.h(3, \"Select European Countries\") + events_2.to_html()]\n", + ")\n", + "htmlcode += widgets.row([widgets.h(3, \"China\") + events_3.to_html()])\n", + "body += widgets.add_tab(\"Events\", htmlcode)\n", + "\n", + "# Yields\n", + "htmlcode = widgets.row([widgets.h(3, \"US treasuries (source: EconDB)\") + ust])\n", + "\n", + "if ycrv:\n", + " htmlcode += widgets.row(\n", + " [\n", + " widgets.h(3, f\"{ycrv_country_1} yield curve (source: FRED)\")\n", + " + (ycrv_chart_1 or \"\")\n", + " ]\n", + " )\n", + " htmlcode += widgets.row([widgets.h(3, \"\") + ycrv_data_1.to_html()])\n", + "\n", + "body += widgets.add_tab(\"Yields\", htmlcode)\n", + "\n", + "# Equity market\n", + "htmlcode = widgets.row(\n", + " [widgets.h(3, \"Valuation (source: Finviz)\") + valuation.to_html()]\n", + ")\n", + "htmlcode += widgets.row(\n", + " [widgets.h(3, \"Performance (source: Finviz)\") + valuation.to_html()]\n", + ")\n", + "htmlcode += widgets.row([widgets.h(3, \"US markets (source: YahooFinance)\") + eqty_0])\n", + "htmlcode += widgets.row(\n", + " [widgets.h(3, \"European markets (source: YahooFinance)\") + eqty_1]\n", + ")\n", + "htmlcode += widgets.row([widgets.h(3, \"APAC markets (source: YahooFinance)\") + eqty_2])\n", + "htmlcode += widgets.row(\n", + " [widgets.h(3, \"Emerging markets (source: YahooFinance)\") + eqty_3]\n", + ")\n", + "htmlcode += widgets.row([widgets.h(3, \"ARCA (source: YahooFinance)\") + eqty_4])\n", + "body += widgets.add_tab(\"Equity Market\", htmlcode)\n", + "\n", + "# Macro\n", + "htmlcode = \"\"\n", + "if not bigmac_res.empty:\n", + " htmlcode += widgets.row(\n", + " [widgets.h(3, \"Bigmac index (source: Nasdaq)\") + (bigmac or \"\")]\n", + " )\n", + "htmlcode += widgets.row([widgets.h(3, \"Leading indicators (source: EconDB)\") + macro_0])\n", + "if fred:\n", + " htmlcode += widgets.row(\n", + " [widgets.h(3, \"Recession indicator (source: FRED)\") + fred_0]\n", + " )\n", + "body += widgets.add_tab(\"Macro Data\", htmlcode)\n", + "\n", + "body += widgets.tab_clickable_and_save_evt()\n", + "report = widgets.html_report(title=report_name, stylesheet=stylesheet, body=body)\n", + "\n", + "# to save the results\n", + "with open(report_name + \".html\", \"w\", encoding=\"utf-8\") as fh:\n", + " fh.write(report)" + ] + } + ], + "metadata": { + "celltoolbar": "Tags", + "kernelspec": { + "display_name": "venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.11" + }, + "vscode": { + "interpreter": { + "hash": "381a209f752e9104bff95ec5e80679ea2e476866b80e4326f1ee6b7658af6049" + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 } diff --git a/openbb_terminal/reports/templates/equity.ipynb b/openbb_terminal/reports/templates/equity.ipynb index ff49cbaf6167..438ee8ebdc83 100644 --- a/openbb_terminal/reports/templates/equity.ipynb +++ b/openbb_terminal/reports/templates/equity.ipynb @@ -28,7 +28,7 @@ "from openbb_terminal import OpenBBFigure\n", "from openbb_terminal.core.plots.plotly_ta.ta_class import PlotlyTA\n", "\n", - "warnings.filterwarnings(\"ignore\")\n" + "warnings.filterwarnings(\"ignore\")" ] }, { @@ -44,7 +44,7 @@ "set_system_variable(\"LOGGING_SUPPRESS\", True)\n", "\n", "# Import the OpenBB SDK\n", - "from openbb_terminal.sdk import openbb, widgets\n" + "from openbb_terminal.sdk import openbb, widgets" ] }, { @@ -65,7 +65,7 @@ " user.preferences.PMF_STYLE,\n", " user.preferences.RICH_STYLE,\n", ")\n", - "theme.apply_style(\"light\")\n" + "theme.apply_style(\"light\")" ] }, { @@ -75,7 +75,7 @@ "metadata": {}, "outputs": [], "source": [ - "stylesheet = widgets.html_report_stylesheet()\n" + "stylesheet = widgets.html_report_stylesheet()" ] }, { @@ -101,7 +101,7 @@ "# Parameters that will be replaced when calling this notebook\n", "# Do not leave parameters blank as notebook will not run otherwise\n", "symbol = \"MSFT\"\n", - "report_name = f\"Equity report for {symbol}\"\n" + "report_name = f\"Equity report for {symbol}\"" ] }, { @@ -115,7 +115,7 @@ " import sys\n", "\n", " sys.exit(0)\n", - "symbol = symbol.upper()\n" + "symbol = symbol.upper()" ] }, { @@ -135,7 +135,7 @@ "report_date = datetime.datetime.now().strftime(\"%d %B, %Y\")\n", "report_time = datetime.datetime.now().strftime(\"%H:%M\")\n", "report_timezone = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo\n", - "report_title, report_date, report_time, report_timezone\n" + "report_title, report_date, report_time, report_timezone" ] }, { @@ -163,7 +163,7 @@ " company_industry = \"N/A\"\n", "\n", "\n", - "overview = [company_name, company_sector, company_industry]\n" + "overview = [company_name, company_sector, company_industry]" ] }, { @@ -187,7 +187,7 @@ " df_quarter_earnings,\n", " df_quarter_revenues,\n", ") = openbb.stocks.fa.est(symbol=symbol)\n", - "df_quarter_revenues.transpose()\n" + "df_quarter_revenues.transpose()" ] }, { @@ -198,7 +198,7 @@ "outputs": [], "source": [ "display_year = sorted(df_year_estimates.columns.tolist())[:3]\n", - "df_year_estimates = df_year_estimates[display_year].head(5)\n" + "df_year_estimates = df_year_estimates[display_year].head(5)" ] }, { @@ -214,7 +214,7 @@ " if not isinstance(table, pd.DataFrame):\n", " continue\n", "\n", - " table[0].loc[\"URL\"] = table[0].loc[\"URL\"].apply(lambda x: f'{x}')\n" + " table[0].loc[\"URL\"] = table[0].loc[\"URL\"].apply(lambda x: f'{x}')" ] }, { @@ -225,7 +225,7 @@ "outputs": [], "source": [ "quote_data = info[[\"Price\", \"Prev Close\", \"Change\", \"Volume\", \"52W Range\", \"Perf YTD\"]]\n", - "quote_data\n" + "quote_data" ] }, { @@ -237,7 +237,7 @@ "source": [ "df_institutional_shareholders = openbb.stocks.fa.shrs(symbol, holder=\"institutional\")\n", "df_institutional_shareholders.index += 1\n", - "df_institutional_shareholders\n" + "df_institutional_shareholders" ] }, { @@ -254,7 +254,7 @@ " ].head(5)\n", " df_sec_filings\n", "except:\n", - " df_sec_filings = \"Error with Nasdaq API\"\n" + " df_sec_filings = \"Error with Nasdaq API\"" ] }, { @@ -282,7 +282,7 @@ "# \"target\": \"Price Target\",\n", "# }\n", "# )\n", - "df_analyst.head(10)\n" + "df_analyst.head(10)" ] }, { @@ -293,7 +293,7 @@ "outputs": [], "source": [ "df_rating = openbb.stocks.fa.rating(symbol)\n", - "df_rating\n" + "df_rating" ] }, { @@ -306,7 +306,7 @@ "pcr_chart = openbb.stocks.options.pcr_chart(symbol, window=30, external_axes=True)\n", "\n", "if pcr_chart:\n", - " pcr_chart = pcr_chart.to_html()\n" + " pcr_chart = pcr_chart.to_html()" ] }, { @@ -321,7 +321,7 @@ "if expiry_dates:\n", " exp = expiry_dates[0]\n", " option_chain = openbb.stocks.options.chains(symbol, expiration=exp)\n", - " current_price = float(ticker_data[\"Adj Close\"][-1])\n" + " current_price = float(ticker_data[\"Adj Close\"][-1])" ] }, { @@ -344,7 +344,7 @@ " )\n", "\n", " if voi_chart:\n", - " voi_chart = voi_chart.to_html()\n" + " voi_chart = voi_chart.to_html()" ] }, { @@ -363,7 +363,7 @@ ")\n", "\n", "if net_short_position:\n", - " net_short_position = net_short_position.to_html()\n" + " net_short_position = net_short_position.to_html()" ] }, { @@ -376,7 +376,7 @@ "dark_pools = openbb.stocks.dps.dpotc_chart(symbol=symbol, external_axes=True)\n", "\n", "if dark_pools:\n", - " dark_pools = dark_pools.to_html()\n" + " dark_pools = dark_pools.to_html()" ] }, { @@ -393,7 +393,7 @@ ")\n", "\n", "if gtrades_chart:\n", - " gtrades_chart = gtrades_chart.to_html()\n" + " gtrades_chart = gtrades_chart.to_html()" ] }, { @@ -410,7 +410,7 @@ ")\n", "\n", "if gov_contracts_chart:\n", - " gov_contracts_chart = gov_contracts_chart.to_html()\n" + " gov_contracts_chart = gov_contracts_chart.to_html()" ] }, { @@ -426,7 +426,7 @@ ")\n", "\n", "if google_mentions_chart:\n", - " google_mentions_chart = google_mentions_chart.to_html()\n" + " google_mentions_chart = google_mentions_chart.to_html()" ] }, { @@ -443,7 +443,7 @@ ")\n", "\n", "if google_regions_chart:\n", - " google_regions_chart = google_regions_chart.to_html()\n" + " google_regions_chart = google_regions_chart.to_html()" ] }, { @@ -455,7 +455,7 @@ "source": [ "similar_companies = openbb.stocks.ca.similar(symbol, source=\"Finviz\")[0:5]\n", "if similar_companies:\n", - " similar_companies.append(symbol)\n" + " similar_companies.append(symbol)" ] }, { @@ -472,7 +472,7 @@ ")\n", "\n", "if historical_similar:\n", - " historical_similar = historical_similar.to_html()\n" + " historical_similar = historical_similar.to_html()" ] }, { @@ -488,7 +488,7 @@ ")\n", "\n", "if hcorr_similar:\n", - " hcorr_similar = hcorr_similar.to_html()\n" + " hcorr_similar = hcorr_similar.to_html()" ] }, { @@ -504,7 +504,7 @@ ")\n", "\n", "if vol_similar:\n", - " vol_similar = vol_similar.to_html()\n" + " vol_similar = vol_similar.to_html()" ] }, { @@ -520,7 +520,7 @@ ")\n", "\n", "if scorr_similar:\n", - " scorr_similar = scorr_similar.to_html()\n" + " scorr_similar = scorr_similar.to_html()" ] }, { @@ -531,7 +531,7 @@ "outputs": [], "source": [ "income_comparison = openbb.stocks.ca.income(similar_companies)\n", - "income_comparison\n" + "income_comparison" ] }, { @@ -546,7 +546,7 @@ " df_related_queries.index += 1\n", " df_related_queries.index\n", "except:\n", - " pass\n" + " pass" ] }, { @@ -561,7 +561,7 @@ " df_rising_queries.index += 1\n", " df_rising_queries\n", "except:\n", - " pass\n" + " pass" ] }, { @@ -577,7 +577,7 @@ ")\n", "\n", "if gov_histcont_chart:\n", - " gov_histcont_chart = gov_histcont_chart.to_html()\n" + " gov_histcont_chart = gov_histcont_chart.to_html()" ] }, { @@ -588,7 +588,7 @@ "outputs": [], "source": [ "df_lobbying = openbb.stocks.gov.lobbying(symbol, limit=5)\n", - "df_lobbying\n" + "df_lobbying" ] }, { @@ -603,7 +603,7 @@ ")\n", "\n", "if price_vs_short_interest:\n", - " price_vs_short_interest = price_vs_short_interest.to_html()\n" + " price_vs_short_interest = price_vs_short_interest.to_html()" ] }, { @@ -620,7 +620,7 @@ ")\n", "\n", "if price_chart:\n", - " price_chart = price_chart.to_html()\n" + " price_chart = price_chart.to_html()" ] }, { @@ -643,7 +643,7 @@ " if price_target_chart:\n", " price_target_chart = price_target_chart.to_html()\n", "except Exception:\n", - " price_target_chart = OpenBBFigure()\n" + " price_target_chart = OpenBBFigure()" ] }, { @@ -670,7 +670,7 @@ " else:\n", " avg_ratings = 0\n", "\n", - "last_price = round(ticker_data[\"Close\"][-1], 2)\n" + "last_price = round(ticker_data[\"Close\"][-1], 2)" ] }, { @@ -689,7 +689,7 @@ ")\n", "\n", "if ratings_over_time_chart:\n", - " ratings_over_time_chart = ratings_over_time_chart.to_html()\n" + " ratings_over_time_chart = ratings_over_time_chart.to_html()" ] }, { @@ -702,7 +702,7 @@ "ta_rsi = openbb.ta.rsi_chart(ticker_data[\"Close\"], external_axes=True)\n", "\n", "if ta_rsi:\n", - " ta_rsi = ta_rsi.to_html()\n" + " ta_rsi = ta_rsi.to_html()" ] }, { @@ -714,7 +714,7 @@ "source": [ "df = openbb.ta.rsi(ticker_data[\"Close\"])\n", "rsi_value = round(df.values[-1][0], 2)\n", - "rsi_value\n" + "rsi_value" ] }, { @@ -730,7 +730,7 @@ " np.array(range(len(ticker_data[\"Close\"][-30:].index))).reshape(-1, 1),\n", " ticker_data[\"Close\"][-30:].values,\n", ")\n", - "regression_slope = round(model.coef_[0], 2)\n" + "regression_slope = round(model.coef_[0], 2)" ] }, { @@ -751,7 +751,7 @@ " )\n", " last_10_insider_trading = round(sum(df_insider[\"Trade\"]) / 1_000_000, 2)\n", " df_insider = df_insider.drop(columns=[\"Val ($)\", \"Trade\"])\n", - " df_insider\n" + " df_insider" ] }, { @@ -764,7 +764,7 @@ "finbrain_sentiment = openbb.stocks.ba.headlines_chart(symbol=symbol, external_axes=True)\n", "\n", "if finbrain_sentiment:\n", - " finbrain_sentiment = finbrain_sentiment.to_html()\n" + " finbrain_sentiment = finbrain_sentiment.to_html()" ] }, { @@ -778,7 +778,7 @@ " df_sentiment_finbrain = openbb.stocks.ca.sentiment(symbols=[symbol])\n", " finbrain_sentiment_val = float(df_sentiment_finbrain.values[-1][0])\n", "except Exception as e:\n", - " finbrain_sentiment_val = \"N/A\"\n" + " finbrain_sentiment_val = \"N/A\"" ] }, { @@ -801,7 +801,7 @@ " stocktwits_sentiment += f\"Bearish {round(100*n_bear/n_cases, 2)}%\"\n", "else:\n", " stocktwits_sentiment += \"No messages found\"\n", - "stocktwits_sentiment\n" + "stocktwits_sentiment" ] }, { @@ -814,7 +814,7 @@ "snews = openbb.stocks.ba.snews_chart(symbol, external_axes=True)\n", "\n", "if snews:\n", - " snews = snews.to_html()\n" + " snews = snews.to_html()" ] }, { @@ -829,7 +829,7 @@ " 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()\n" + "ticker_data_all[\"Returns\"] = ticker_data_all[\"Adj Close\"].pct_change()" ] }, { @@ -848,7 +848,7 @@ ")\n", "\n", "if bw_month:\n", - " bw_month = bw_month.to_html()\n" + " bw_month = bw_month.to_html()" ] }, { @@ -867,7 +867,7 @@ ")\n", "\n", "if bw_year:\n", - " bw_year = bw_year.to_html()\n" + " bw_year = bw_year.to_html()" ] }, { @@ -894,7 +894,7 @@ " pass\n", "\n", "enterprise_df = openbb.stocks.fa.enterprise(symbol)\n", - "score = openbb.stocks.fa.score(symbol, years=10)\n" + "score = openbb.stocks.fa.score(symbol, years=10)" ] }, { @@ -914,7 +914,7 @@ "\n", "if ma_chart:\n", " ma_chart = ma_chart.show(external=True)\n", - " ma_chart = ma_chart.to_html()\n" + " ma_chart = ma_chart.to_html()" ] }, { @@ -929,7 +929,7 @@ ")\n", "\n", "if macd_chart:\n", - " macd_chart = macd_chart.to_html()\n" + " macd_chart = macd_chart.to_html()" ] }, { @@ -942,7 +942,7 @@ "cci_chart = openbb.ta.cci_chart(ticker_data, symbol=symbol, external_axes=True)\n", "\n", "if cci_chart:\n", - " cci_chart = cci_chart.to_html()\n" + " cci_chart = cci_chart.to_html()" ] }, { @@ -955,7 +955,7 @@ "stoch_chart = openbb.ta.stoch_chart(ticker_data, symbol=symbol, external_axes=True)\n", "\n", "if stoch_chart:\n", - " stoch_chart = stoch_chart.to_html()\n" + " stoch_chart = stoch_chart.to_html()" ] }, { @@ -968,7 +968,7 @@ "adx_chart = openbb.ta.adx_chart(ticker_data, symbol=symbol, external_axes=True)\n", "\n", "if adx_chart:\n", - " adx_chart = adx_chart.to_html()\n" + " adx_chart = adx_chart.to_html()" ] }, { @@ -981,7 +981,7 @@ "bbands_chart = openbb.ta.bbands_chart(ticker_data, symbol=symbol, external_axes=True)\n", "\n", "if bbands_chart:\n", - " bbands_chart = bbands_chart.to_html()\n" + " bbands_chart = bbands_chart.to_html()" ] }, { @@ -994,7 +994,7 @@ "ad_chart = openbb.ta.ad_chart(ticker_data, symbol=symbol, external_axes=True)\n", "\n", "if ad_chart:\n", - " ad_chart = ad_chart.to_html()\n" + " ad_chart = ad_chart.to_html()" ] }, { @@ -1354,7 +1354,7 @@ "\n", "# to save the results\n", "with open(report_name + \".html\", \"w\", encoding=\"utf-8\") as fh:\n", - " fh.write(report)\n" + " fh.write(report)" ] } ], diff --git a/openbb_terminal/reports/templates/forecast.ipynb b/openbb_terminal/reports/templates/forecast.ipynb index 3486a69a4434..ae7d5d6d7504 100644 --- a/openbb_terminal/reports/templates/forecast.ipynb +++ b/openbb_terminal/reports/templates/forecast.ipynb @@ -29,7 +29,7 @@ "from openbb_terminal.helper_classes import TerminalStyle\n", "from openbb_terminal import OpenBBFigure, theme\n", "\n", - "warnings.filterwarnings(\"ignore\")\n" + "warnings.filterwarnings(\"ignore\")" ] }, { @@ -45,7 +45,7 @@ "set_system_variable(\"LOGGING_SUPPRESS\", True)\n", "\n", "# Import the OpenBB SDK\n", - "from openbb_terminal.sdk import openbb, widgets\n" + "from openbb_terminal.sdk import openbb, widgets" ] }, { @@ -64,7 +64,7 @@ " user.preferences.PMF_STYLE,\n", " user.preferences.RICH_STYLE,\n", ")\n", - "theme.apply_style(\"light\")\n" + "theme.apply_style(\"light\")" ] }, { @@ -74,7 +74,7 @@ "metadata": {}, "outputs": [], "source": [ - "stylesheet = widgets.html_report_stylesheet()\n" + "stylesheet = widgets.html_report_stylesheet()" ] }, { @@ -129,7 +129,7 @@ "# Parameters that will be replaced when calling this notebook\n", "# Do not leave parameters blank as notebook will not run otherwise\n", "symbol = \"VTI\"\n", - "report_name = \"Forecast Report for VTI\"\n" + "report_name = \"Forecast Report for VTI\"" ] }, { @@ -139,7 +139,7 @@ "metadata": {}, "outputs": [], "source": [ - "ticker = symbol\n" + "ticker = symbol" ] }, { @@ -152,7 +152,7 @@ "if \".\" in ticker:\n", " import sys\n", "\n", - " sys.exit(0)\n" + " sys.exit(0)" ] }, { @@ -171,7 +171,7 @@ "report_date = datetime.datetime.now().strftime(\"%d %B, %Y\")\n", "report_time = datetime.datetime.now().strftime(\"%H:%M\")\n", "report_timezone = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo\n", - "report_title, report_date, report_time, report_timezone\n" + "report_title, report_date, report_time, report_timezone" ] }, { @@ -195,7 +195,7 @@ "\n", "# Prepare date for forecast\n", "ticker_data = ticker_data.reset_index()\n", - "ticker_data.columns = [x.lower() for x in ticker_data.columns]\n" + "ticker_data.columns = [x.lower() for x in ticker_data.columns]" ] }, { @@ -285,7 +285,7 @@ "\n", "# to save the results\n", "with open(report_name + \".html\", \"w\", encoding=\"utf-8\") as fh:\n", - " fh.write(report)\n" + " fh.write(report)" ] } ], diff --git a/openbb_terminal/reports/templates/portfolio.ipynb b/openbb_terminal/reports/templates/portfolio.ipynb index 833c1319c5d0..075534e3ea7d 100644 --- a/openbb_terminal/reports/templates/portfolio.ipynb +++ b/openbb_terminal/reports/templates/portfolio.ipynb @@ -32,7 +32,7 @@ "from openbb_terminal.core.config.paths import REPOSITORY_DIRECTORY\n", "from openbb_terminal import OpenBBFigure, theme\n", "\n", - "warnings.filterwarnings(\"ignore\")\n" + "warnings.filterwarnings(\"ignore\")" ] }, { @@ -48,7 +48,7 @@ "set_system_variable(\"LOGGING_SUPPRESS\", True)\n", "\n", "# Import the OpenBB SDK\n", - "from openbb_terminal.sdk import openbb, widgets, helper\n" + "from openbb_terminal.sdk import openbb, widgets, helper" ] }, { @@ -69,7 +69,7 @@ ")\n", "theme.apply_style(\"light\")\n", "\n", - "USER_PORTFOLIO_DATA_DIRECTORY = user.preferences.USER_PORTFOLIO_DATA_DIRECTORY\n" + "USER_PORTFOLIO_DATA_DIRECTORY = user.preferences.USER_PORTFOLIO_DATA_DIRECTORY" ] }, { @@ -79,7 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "stylesheet = widgets.html_report_stylesheet()\n" + "stylesheet = widgets.html_report_stylesheet()" ] }, { @@ -99,7 +99,7 @@ "outputs": [], "source": [ "stylesheet = widgets.html_report_stylesheet()\n", - "user_time_zone = pytz.timezone(helper.get_user_timezone())\n" + "user_time_zone = pytz.timezone(helper.get_user_timezone())" ] }, { @@ -116,7 +116,7 @@ "# Parameters that will be replaced when calling this notebook\n", "# Do not leave parameters blank as notebook will not run otherwise\n", "transactions = \"holdings_example.xlsx\"\n", - "report_name = \"Portfolio Report\"\n" + "report_name = \"Portfolio Report\"" ] }, { @@ -138,7 +138,7 @@ "elif os.path.isfile(file_1):\n", " transactions_path = file_1\n", "else:\n", - " raise FileNotFoundError(\"File not found: \" + transactions)\n" + " raise FileNotFoundError(\"File not found: \" + transactions)" ] }, { @@ -153,7 +153,7 @@ "report_date = pd.Timestamp.now(tz=user_time_zone).strftime(\"%d %B, %Y\")\n", "report_time = pd.Timestamp.now(tz=user_time_zone).strftime(\"%H:%M\")\n", "report_timezone = pd.Timestamp.now(tz=user_time_zone).tzinfo\n", - "report_title, report_date, report_time, report_timezone\n" + "report_title, report_date, report_time, report_timezone" ] }, { @@ -185,7 +185,7 @@ " P = openbb.portfolio.load(transactions_path)\n", " openbb.portfolio.show(P)\n", "except Exception as e:\n", - " raise Exception(\"Failed to load the transactions.\")\n" + " raise Exception(\"Failed to load the transactions.\")" ] }, { @@ -198,7 +198,7 @@ "beta_chart = openbb.portfolio.rbeta_chart(P, external_axes=True)\n", "\n", "if beta_chart:\n", - " beta_chart = beta_chart.to_html()\n" + " beta_chart = beta_chart.to_html()" ] }, { @@ -211,7 +211,7 @@ "sharpe_chart = openbb.portfolio.rsharpe_chart(P, external_axes=True)\n", "\n", "if sharpe_chart:\n", - " sharpe_chart = sharpe_chart.to_html()\n" + " sharpe_chart = sharpe_chart.to_html()" ] }, { @@ -224,7 +224,7 @@ "volatility_chart = openbb.portfolio.rvol_chart(P, external_axes=True)\n", "\n", "if volatility_chart:\n", - " volatility_chart = volatility_chart.to_html()\n" + " volatility_chart = volatility_chart.to_html()" ] }, { @@ -237,7 +237,7 @@ "sortino_chart = openbb.portfolio.rsort_chart(P, external_axes=True)\n", "\n", "if sortino_chart:\n", - " sortino_chart = sortino_chart.to_html()\n" + " sortino_chart = sortino_chart.to_html()" ] }, { @@ -250,7 +250,7 @@ "maxdd_chart = openbb.portfolio.maxdd_chart(P, external_axes=True)\n", "\n", "if maxdd_chart:\n", - " maxdd_chart = maxdd_chart.to_html()\n" + " maxdd_chart = maxdd_chart.to_html()" ] }, { @@ -272,7 +272,7 @@ " \"{:.3}pp\".format\n", ")\n", "\n", - "country_allocation\n" + "country_allocation" ] }, { @@ -294,7 +294,7 @@ " \"{:.3}pp\".format\n", ")\n", "\n", - "sector_allocation\n" + "sector_allocation" ] }, { @@ -307,7 +307,7 @@ "distr_chart = openbb.portfolio.distr_chart(P, external_axes=True)\n", "\n", "if distr_chart:\n", - " distr_chart = distr_chart.to_html()\n" + " distr_chart = distr_chart.to_html()" ] }, { @@ -320,7 +320,7 @@ "dret_chart = openbb.portfolio.dret_chart(P, external_axes=True)\n", "\n", "if dret_chart:\n", - " dret_chart = dret_chart.to_html()\n" + " dret_chart = dret_chart.to_html()" ] }, { @@ -333,7 +333,7 @@ "yret_chart = openbb.portfolio.yret_chart(P, external_axes=True)\n", "\n", "if yret_chart:\n", - " yret_chart = yret_chart.to_html()\n" + " yret_chart = yret_chart.to_html()" ] }, { @@ -477,7 +477,7 @@ "\n", "# to save the results\n", "with open(report_name + \".html\", \"w\", encoding=\"utf-8\") as fh:\n", - " fh.write(report)\n" + " fh.write(report)" ] } ], diff --git a/tests/openbb_terminal/cryptocurrency/defi/test_llama_view.py b/tests/openbb_terminal/cryptocurrency/defi/test_llama_view.py index 7f70328ae28a..ae9edd0af451 100644 --- a/tests/openbb_terminal/cryptocurrency/defi/test_llama_view.py +++ b/tests/openbb_terminal/cryptocurrency/defi/test_llama_view.py @@ -63,6 +63,7 @@ def gzip_data(response): return response +@pytest.mark.skip @pytest.mark.record_stdout def test_display_defi_protocols(): llama_view.display_defi_protocols(