From 9cee9cc76aa3505a4637e4203bcf9b5027a4bfe6 Mon Sep 17 00:00:00 2001 From: James Maslek Date: Fri, 29 Jul 2022 07:18:47 -0400 Subject: [PATCH] Small danglewood bugs (#2197) * add user agent to yahoo request * initialize pandas series with float * Add a billions to economy SCALE * add color to rtps * make values required for certain settings * spell required correctly, dont block -h in settngs * quick lint * added couple guess games lines lol --- guess_game.json | 5 ++++- openbb_terminal/economy/alphavantage_view.py | 3 ++- openbb_terminal/economy/econdb_model.py | 7 ++++--- openbb_terminal/settings_controller.py | 5 ++++- .../stocks/dark_pool_shorts/yahoofinance_model.py | 5 ++++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/guess_game.json b/guess_game.json index 8e95c3c22b0..d006b0833bd 100644 --- a/guess_game.json +++ b/guess_game.json @@ -4,5 +4,8 @@ "get management team from AAPL": "stocks/load AAPL/fa/mgmt", "check future IPOs": "stocks/disc/fipo", "search tickers with word 'Technology' from India": "stocks/search Technology -c India", - "get consumer price index for Portugal": "economy/macro -p CPI -c Portugal" + "get consumer price index for Portugal": "economy/macro -p CPI -c Portugal", + "load in SPY etf and get top holdings": "etf/load SPY/holdings", + "get forward rates for Euro to USD": "forex/load EURUSD/fwd", + "load AAPL and compare the balance sheet with microsofts" : "stocks/load AAPL/ca/add MSFT/balance" } diff --git a/openbb_terminal/economy/alphavantage_view.py b/openbb_terminal/economy/alphavantage_view.py index 8c9f7214140..c2dae006e13 100644 --- a/openbb_terminal/economy/alphavantage_view.py +++ b/openbb_terminal/economy/alphavantage_view.py @@ -61,7 +61,8 @@ def realtime_performance_sector( ) else: - ax = df_rtp.plot(kind="barh") + colors = [theme.up_color if x > 0 else theme.down_color for x in df_rtp.values] + ax = df_rtp.plot(kind="barh", color=colors) theme.style_primary_axis(ax) ax.set_title("Real Time Performance (%) per Sector") ax.tick_params(axis="x", labelrotation=90) diff --git a/openbb_terminal/economy/econdb_model.py b/openbb_terminal/economy/econdb_model.py index 4e35b42f2fd..c60d46cc293 100644 --- a/openbb_terminal/economy/econdb_model.py +++ b/openbb_terminal/economy/econdb_model.py @@ -411,6 +411,7 @@ SCALES = { "Thousands": 1_000, "Millions": 1_000_000, "Hundreds of millions": 100_000_000, + "Billions": 1_000_000_000, "Units": 1, } @@ -503,10 +504,10 @@ def get_macro_data( if country not in COUNTRY_CODES: console.print(f"No data available for the country {country}.") - return pd.Series(), "" + return pd.Series(dtype=float), "" if parameter not in PARAMETERS: console.print(f"The parameter {parameter} is not an option for {country}.") - return pd.Series(), "" + return pd.Series(dtype=float), "" country_code = COUNTRY_CODES[country] country_currency = COUNTRY_CURRENCIES[country] @@ -533,7 +534,7 @@ def get_macro_data( f"No data available for {parameter} ({PARAMETERS[parameter]['name']}) " f"of country {country.replace('_', ' ')}" ) - return pd.Series(), "" + return pd.Series(dtype=float), "" if start_date or end_date: df = df.loc[start_date:end_date] diff --git a/openbb_terminal/settings_controller.py b/openbb_terminal/settings_controller.py index 7664078211f..b96ad8ad74d 100644 --- a/openbb_terminal/settings_controller.py +++ b/openbb_terminal/settings_controller.py @@ -207,11 +207,12 @@ class SettingsController(BaseController): type=int, dest="value", help="value", + required="-h" not in other_args, ) if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-v") ns_parser = parse_simple_args(parser, other_args) - if ns_parser: + if ns_parser and ns_parser.value: set_key(obbff.ENV_FILE, "OPENBB_PLOT_DPI", str(ns_parser.value)) cfg_plot.PLOT_DPI = ns_parser.value console.print("") @@ -231,6 +232,7 @@ class SettingsController(BaseController): type=int, dest="value", help="value", + required="-h" not in other_args, ) if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-v") @@ -255,6 +257,7 @@ class SettingsController(BaseController): type=int, dest="value", help="value", + required="-h" not in other_args, ) if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-v") diff --git a/openbb_terminal/stocks/dark_pool_shorts/yahoofinance_model.py b/openbb_terminal/stocks/dark_pool_shorts/yahoofinance_model.py index cae3dc70ee5..50c5052fa7d 100644 --- a/openbb_terminal/stocks/dark_pool_shorts/yahoofinance_model.py +++ b/openbb_terminal/stocks/dark_pool_shorts/yahoofinance_model.py @@ -7,6 +7,7 @@ import pandas as pd import requests from openbb_terminal.decorators import log_start_end +from openbb_terminal.helper_funcs import get_user_agent logger = logging.getLogger(__name__) @@ -22,6 +23,8 @@ def get_most_shorted() -> pd.DataFrame: """ url = "https://finance.yahoo.com/screener/predefined/most_shorted_stocks" - data = pd.read_html(requests.get(url).text)[0] + data = pd.read_html( + requests.get(url, headers={"User-Agent": get_user_agent()}).text + )[0] data = data.iloc[:, :-1] return data