Fixed crypto, economy, forex commands inreports menu (#4717) (#4729)

* Fixed `crypto`, `economy`, `forex` commands  in`reports` menu

* Modified sdk.py to use Feedparser API to get news
* Made `basic_info` and `trading_pair_info` tables look prettier in `crypto` template
* Fixed news dataframe by modifying the columns in `economy` and `forex`

* Modified `trail_maps.csv` and generated `sdk.py`

* fixing forecast dashboard

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
Pratyush Shukla
2023-04-12 15:27:05 +05:30
committed by GitHub
parent 99854ef4d9
commit dd41b8461d
12 changed files with 54 additions and 29 deletions

View File

@@ -24,7 +24,7 @@ class StocksController(model.StocksRoot):
Attributes:
`candle`: Show candle plot of loaded ticker.\n
`load`: Load a symbol to perform analysis using the string above as a template.\n
`news`: Get news for a given term and source. [Source: Feedparser]\n
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
`process_candle`: Process DataFrame into candle style plot.\n
`quote`: Gets ticker quote from FMP\n
`search`: Search selected query for tickers.\n

View File

@@ -11,7 +11,7 @@ class StocksRoot(Category):
Attributes:
`candle`: Show candle plot of loaded ticker.\n
`load`: Load a symbol to perform analysis using the string above as a template.\n
`news`: Get news for a given term and source. [Source: Feedparser]\n
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
`process_candle`: Process DataFrame into candle style plot.\n
`quote`: Gets ticker quote from FMP\n
`search`: Search selected query for tickers.\n

View File

@@ -267,12 +267,12 @@ forex.oanda.positionbook,forex_oanda_model.positionbook_plot_data_request,forex_
forex.oanda.price,forex_oanda_model.fx_price_request,forex_oanda_view.get_fx_price
forex.oanda.summary,forex_oanda_model.account_summary_request,forex_oanda_view.get_account_summary
forex.quote,forex_sdk_helpers.quote,
funds.carbon,funds_mstarpy_model.load_carbon_metrics,
funds.exclusion,funds_mstarpy_model.load_exclusion_policy,
funds.historical,funds_mstarpy_model.get_historical,funds_mstarpy_view.display_historical
funds.holdings,funds_mstarpy_model.load_holdings,
funds.load,funds_mstarpy_model.load_funds,
funds.search,funds_mstarpy_model.search_funds,
funds.holdings,funds_mstarpy_model.load_holdings,
funds.exclusion,funds_mstarpy_model.load_exclusion_policy,
funds.carbon,funds_mstarpy_model.load_carbon_metrics,
funds.historical,funds_mstarpy_model.get_historical,funds_mstarpy_view.display_historical
funds.sector,funds_mstarpy_model.get_sector,funds_mstarpy_view.display_sector
futures.curve,futures_yfinance_model.get_curve_futures,futures_yfinance_view.display_curve
futures.historical,futures_sdk_model.get_historical,futures_yfinance_view.display_historical
@@ -314,7 +314,7 @@ keys.ultima,keys_model.set_ultima_key,
keys.walert,keys_model.set_walert_key,
login,sdk_session.login,
logout,sdk_session.logout,
news,common_ultima_newsmonitor_model.get_news,
news,common_feedparser_model.get_news,
portfolio.alloc.assets,portfolio_model.get_assets_allocation,
portfolio.alloc.countries,portfolio_model.get_countries_allocation,
portfolio.alloc.regions,portfolio_model.get_regions_allocation,
@@ -506,6 +506,7 @@ stocks.ins.lpsb,stocks_insider_sdk_helper.lpsb,
stocks.ins.print_insider_data,stocks_insider_openinsider_model.get_print_insider_data,stocks_insider_openinsider_view.print_insider_data
stocks.ins.stats,stocks_insider_sdk_helper.stats,
stocks.load,stocks_helper.load,
stocks.news,common_ultima_newsmonitor_model.get_news,
stocks.options.chains,stocks_options_sdk_helper.get_full_option_chain,
stocks.options.dte,stocks_options_yfinance_model.get_dte,
stocks.options.eodchain,stocks_options_intrinio_model.get_full_chain_eod,
@@ -525,7 +526,6 @@ stocks.options.unu,stocks_options_fdscanner_model.unusual_options,stocks_options
stocks.options.voi,stocks_options_view.plot_voi,
stocks.options.vol,stocks_options_view.plot_vol,
stocks.options.vsurf,stocks_options_yfinance_model.get_iv_surface,stocks_options_yfinance_view.display_vol_surface
stocks.news,common_ultima_newsmonitor_model.get_news,
stocks.process_candle,stocks_helper.process_candle,
stocks.qa.beta,stocks_qa_beta_model.beta_model,stocks_qa_beta_view.beta_view
stocks.qa.capm,stocks_qa_factors_model.capm_information,
1 trail model view
267 forex.oanda.price forex_oanda_model.fx_price_request forex_oanda_view.get_fx_price
268 forex.oanda.summary forex_oanda_model.account_summary_request forex_oanda_view.get_account_summary
269 forex.quote forex_sdk_helpers.quote
270 funds.carbon funds_mstarpy_model.load_carbon_metrics
271 funds.exclusion funds_mstarpy_model.load_exclusion_policy
272 funds.historical funds_mstarpy_model.get_historical funds_mstarpy_view.display_historical
273 funds.holdings funds_mstarpy_model.load_holdings
274 funds.load funds_mstarpy_model.load_funds
275 funds.search funds_mstarpy_model.search_funds
funds.holdings funds_mstarpy_model.load_holdings
funds.exclusion funds_mstarpy_model.load_exclusion_policy
funds.carbon funds_mstarpy_model.load_carbon_metrics
funds.historical funds_mstarpy_model.get_historical funds_mstarpy_view.display_historical
276 funds.sector funds_mstarpy_model.get_sector funds_mstarpy_view.display_sector
277 futures.curve futures_yfinance_model.get_curve_futures futures_yfinance_view.display_curve
278 futures.historical futures_sdk_model.get_historical futures_yfinance_view.display_historical
314 keys.walert keys_model.set_walert_key
315 login sdk_session.login
316 logout sdk_session.logout
317 news common_ultima_newsmonitor_model.get_news common_feedparser_model.get_news
318 portfolio.alloc.assets portfolio_model.get_assets_allocation
319 portfolio.alloc.countries portfolio_model.get_countries_allocation
320 portfolio.alloc.regions portfolio_model.get_regions_allocation
506 stocks.ins.print_insider_data stocks_insider_openinsider_model.get_print_insider_data stocks_insider_openinsider_view.print_insider_data
507 stocks.ins.stats stocks_insider_sdk_helper.stats
508 stocks.load stocks_helper.load
509 stocks.news common_ultima_newsmonitor_model.get_news
510 stocks.options.chains stocks_options_sdk_helper.get_full_option_chain
511 stocks.options.dte stocks_options_yfinance_model.get_dte
512 stocks.options.eodchain stocks_options_intrinio_model.get_full_chain_eod
526 stocks.options.voi stocks_options_view.plot_voi
527 stocks.options.vol stocks_options_view.plot_vol
528 stocks.options.vsurf stocks_options_yfinance_model.get_iv_surface stocks_options_yfinance_view.display_vol_surface
stocks.news common_ultima_newsmonitor_model.get_news
529 stocks.process_candle stocks_helper.process_candle
530 stocks.qa.beta stocks_qa_beta_model.beta_model stocks_qa_beta_view.beta_view
531 stocks.qa.capm stocks_qa_factors_model.capm_information

View File

@@ -17,7 +17,9 @@
"import pandas as pd\n",
"from IPython.display import display\n",
"\n",
"theme.apply_style()"
"from openbb_terminal import OpenBBFigure, theme\n",
"\n",
"theme.apply_style(\"light\")"
]
},
{
@@ -29,10 +31,11 @@
"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"
"from openbb_terminal.sdk import openbb"
]
},
{
@@ -356,7 +359,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
"version": "3.9.13"
},
"metadata": {
"interpreter": {

View File

@@ -46,6 +46,7 @@
"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",
@@ -141,6 +142,8 @@
"\n",
"basic_info = openbb.crypto.dd.basic(ticker)\n",
"if not basic_info.empty:\n",
" basic_info[\"Metric\"] = basic_info[\"Metric\"].str.title()\n",
" basic_info[\"Metric\"] = basic_info[\"Metric\"].str.replace(\"_\", \" \")\n",
" basic_info = basic_info.set_index(\"Metric\")\n",
" basic_info"
]
@@ -424,6 +427,8 @@
"if (isinstance(trading_pair_info, pd.DataFrame) and not trading_pair_info.empty) or (\n",
" not isinstance(trading_pair_info, pd.DataFrame) and trading_pair_info\n",
"):\n",
" trading_pair_info[\"Metric\"] = trading_pair_info[\"Metric\"].str.title()\n",
" trading_pair_info[\"Metric\"] = trading_pair_info[\"Metric\"].str.replace(\"_\", \" \")\n",
" trading_pair_info = trading_pair_info.set_index(\"Metric\")\n",
" trading_pair_info\n",
"else:\n",

View File

@@ -46,6 +46,7 @@
"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",
@@ -157,13 +158,15 @@
"try:\n",
" news = openbb.news(\"economy\")\n",
" news.columns = news.columns.str.title()\n",
" news[\"Title\"] = news.apply(lambda x: f'<a href=\"{x[\"Link\"]}\">{x[\"Title\"]}</a>', axis=1)\n",
" news = news.rename(\n",
" columns={\"Date\": \"Published\", \"Description\": \"Title\", \"Url\": \"Link\"}\n",
" )\n",
" news[\"Title\"] = news.apply(\n",
" lambda x: f'<a href=\"{x[\"Link\"]}\">{x[\"Title\"]}</a>', 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.set_index(\"Published\", inplace=True)\n",
"\n",
" news = OpenBBFigure.to_table(news, print_index=True, columnwidth=[1.3, 7], width=1100)\n",
" news.update_layout(clickmode=\"event+select\")\n",
" news = news.set_index(\"Published\")\n",
"except:\n",
" news = pd.DataFrame()"
]
@@ -667,9 +670,12 @@
"\n",
"if not news.empty:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, \"Top news on 'economy' keyword (source: Newsapi)\") + news.to_html()]\n",
" [\n",
" widgets.h(3, \"Top news on 'economy' keyword (source: Feedparser)\")\n",
" + news.to_html(escape=False)\n",
" ]\n",
" )\n",
" \n",
"\n",
"body += widgets.add_tab(\"SUMMARY\", htmlcode)\n",
"\n",
"# Events\n",
@@ -752,7 +758,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.10.9"
},
"vscode": {
"interpreter": {

View File

@@ -40,6 +40,7 @@
"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",

View File

@@ -38,6 +38,7 @@
"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",
@@ -209,7 +210,10 @@
"if \"Percentage\" in weights_df.columns:\n",
" weights_df.columns = [\"Percentage\"]\n",
"\n",
"if \"Percentage\" in weights_df.columns and len(weights_df[weights_df[\"Percentage\"] > 10].index) > 1:\n",
"if (\n",
" \"Percentage\" in weights_df.columns\n",
" and len(weights_df[weights_df[\"Percentage\"] > 10].index) > 1\n",
"):\n",
" colors = theme.get_colors()\n",
" fig = OpenBBFigure.create_subplots(\n",
" 1,\n",

View File

@@ -41,6 +41,7 @@
"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",

View File

@@ -42,6 +42,7 @@
"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",
@@ -470,15 +471,18 @@
"# latest news\n",
"try:\n",
" news = openbb.news(term=ticker).head(10)\n",
" news.columns = news.columns.str.title()\n",
"\n",
" news[\"published\"] = pd.to_datetime(news[\"published\"])\n",
" news[\"published\"] = pd.to_datetime(\n",
" news[\"published\"], format=\"%d/%m/%y %H:%M:%S\"\n",
" ).dt.strftime(\"%Y-%m-%d\")\n",
" news = news[[\"published\", \"title\", \"link\"]]\n",
" news = news.rename(\n",
" columns={\"Date\": \"Published\", \"Description\": \"Title\", \"Url\": \"Link\"}\n",
" )\n",
" news[\"Title\"] = news.apply(\n",
" lambda x: f'<a href=\"{x[\"Link\"]}\">{x[\"Title\"]}</a>', axis=1\n",
" )\n",
" news = news[[\"Title\", \"Published\"]]\n",
" news[\"Published\"] = pd.to_datetime(news[\"Published\"]).dt.strftime(\"%Y-%m-%d %H:%M\")\n",
"\n",
" news[\"link\"] = news[\"link\"].apply(lambda x: f'<a href=\"{x}\">{x}</a>')\n",
" news = news.set_index(\"published\")\n",
" news = news.set_index(\"Published\")\n",
" news.sort_index()\n",
"except:\n",
" news = pd.DataFrame()"

View File

@@ -43,6 +43,7 @@
"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",

View File

@@ -46,7 +46,7 @@ class OpenBBSDK:
SDKLogger()
self.login = lib.sdk_session.login
self.logout = lib.sdk_session.logout
self.news = lib.common_ultima_newsmonitor_model.get_news
self.news = lib.common_feedparser_model.get_news
self.whoami = lib.sdk_session.whoami
SDKLogger._try_to_login(self)
@@ -516,7 +516,7 @@ class OpenBBSDK:
Attributes:
`candle`: Show candle plot of loaded ticker.\n
`load`: Load a symbol to perform analysis using the string above as a template.\n
`news`: Get news for a given term and source. [Source: Feedparser]\n
`news`: Get news for a given term and source. [Source: Ultima Insights News Monitor]\n
`process_candle`: Process DataFrame into candle style plot.\n
`quote`: Gets ticker quote from FMP\n
`search`: Search selected query for tickers.\n