diff --git a/openbb_terminal/decorators.py b/openbb_terminal/decorators.py index 6ecfd7cb38c..d9ff190bb5d 100644 --- a/openbb_terminal/decorators.py +++ b/openbb_terminal/decorators.py @@ -37,11 +37,15 @@ def log_start_end(func=None, log=None): repr(a) for a in args if isinstance(a, (pd.DataFrame, pd.Series)) or a ] - if len(args) == 2 and ( - "__main__.TerminalController" in args_passed_in_function[0] - or ( - "openbb_terminal." in args_passed_in_function[0] - and "_controller" in args_passed_in_function[0] + if ( + len(args) == 2 + and args_passed_in_function + and ( + "__main__.TerminalController" in args_passed_in_function[0] + or ( + "openbb_terminal." in args_passed_in_function[0] + and "_controller" in args_passed_in_function[0] + ) ) ): logging_name = args_passed_in_function[0].split()[0][1:] diff --git a/openbb_terminal/stocks/sector_industry_analysis/financedatabase_model.py b/openbb_terminal/stocks/sector_industry_analysis/financedatabase_model.py index 29fdd480e00..6b38867491b 100644 --- a/openbb_terminal/stocks/sector_industry_analysis/financedatabase_model.py +++ b/openbb_terminal/stocks/sector_industry_analysis/financedatabase_model.py @@ -34,7 +34,8 @@ def get_countries(industry: str = "", sector: str = ""): return fd.show_options("equities", industry=True)[industry]["Countries"] if sector: return fd.show_options("equities", sector=sector)["Countries"] - return fd.show_options("equities", "countries") + + return [count for count in fd.show_options("equities", "countries") if count] @log_start_end(log=logger) @@ -59,7 +60,7 @@ def get_sectors(industry: str = "", country: str = ""): if country: return fd.show_options("equities", country=country)["Sectors"] - return fd.show_options("equities", "sectors") + return [sect for sect in fd.show_options("equities", "sectors") if sect] @log_start_end(log=logger) @@ -87,7 +88,7 @@ def get_industries(country: str = "", sector: str = ""): if sector: return fd.show_options("equities", sector=sector)["Industries"] - return fd.show_options("equities", "industries") + return [ind for ind in fd.show_options("equities", "industries") if ind] @log_start_end(log=logger) diff --git a/openbb_terminal/stocks/sector_industry_analysis/sia_controller.py b/openbb_terminal/stocks/sector_industry_analysis/sia_controller.py index 7177c83fbd0..5f6c518bf41 100644 --- a/openbb_terminal/stocks/sector_industry_analysis/sia_controller.py +++ b/openbb_terminal/stocks/sector_industry_analysis/sia_controller.py @@ -169,10 +169,10 @@ class SectorIndustryAnalysisController(BaseController): """Constructor""" super().__init__(queue) - self.country = "United States" - self.sector = "Financial Services" - self.industry = "Financial Data & Stock Exchanges" - self.mktcap = "Large" + self.country = "" + self.sector = "" + self.industry = "" + self.mktcap = "" self.exclude_exchanges = True self.period = "Annual" @@ -243,6 +243,8 @@ class SectorIndustryAnalysisController(BaseController): self.choices = choices self.completer = NestedCompleter.from_nested_dict(choices) + self.update_runtime_choices() + def update_runtime_choices(self): """Update runtime choices""" if session and obbff.USE_PROMPT_TOOLKIT: @@ -304,7 +306,6 @@ class SectorIndustryAnalysisController(BaseController): mt.add_raw("\n") mt.add_param("_returned_tickers", ", ".join(self.tickers)) mt.add_menu("ca", self.tickers) - mt.add_raw("\n") console.print(text=mt.menu_text, menu="Stocks - Sector and Industry Analysis") def custom_reset(self): @@ -796,22 +797,36 @@ class SectorIndustryAnalysisController(BaseController): parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES ) if ns_parser: - ( - self.stocks_data, - self.tickers, - ) = financedatabase_view.display_bars_financials( - self.metric_yf_keys[ns_parser.metric][0], - self.metric_yf_keys[ns_parser.metric][1], - self.country, - self.sector, - self.industry, - self.mktcap, - self.exclude_exchanges, - ns_parser.limit, - ns_parser.export, - ns_parser.raw, - self.stocks_data, - ) + if not self.country and not self.sector and not self.industry: + console.print( + "[red]Select at least one filter from sector, country or industry.[/red]\n" + ) + else: + try: + console.print( + "[param]If it takes too long, you can use 'Ctrl + C' to cancel.\n[/param]" + ) + ( + self.stocks_data, + self.tickers, + ) = financedatabase_view.display_bars_financials( + self.metric_yf_keys[ns_parser.metric][0], + self.metric_yf_keys[ns_parser.metric][1], + self.country, + self.sector, + self.industry, + self.mktcap, + self.exclude_exchanges, + ns_parser.limit, + ns_parser.export, + ns_parser.raw, + self.stocks_data, + ) + except KeyboardInterrupt: + console.print( + "[param]For a faster search, ensure that you select at least one filter " + "from sector, country or industry.\n[/param]" + ) @log_start_end(log=logger) def call_satma(self, other_args: List[str]): @@ -877,7 +892,6 @@ class SectorIndustryAnalysisController(BaseController): help="Metric to visualize", choices=self.vis_choices, ) - parser.add_argument( "-p", "--period", @@ -886,44 +900,56 @@ class SectorIndustryAnalysisController(BaseController): help="Limit number of periods to display", type=check_positive, ) - parser.add_argument( - "-cc", - "--convert_currency", + "-c", + "--currency", dest="currency", help="Convert the currency of the chosen country to a specified currency. By default, this is set " "to USD (US Dollars).", default="USD", ) - if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-m") ns_parser = self.parse_known_args_and_warn( parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, limit=10, raw=True ) if ns_parser: - if ns_parser.currency != self.currency: - self.stocks_data = {} - ( - self.stocks_data, - self.tickers, - ) = stockanalysis_view.display_plots_financials( - finance_key=ns_parser.metric, - country=self.country, - sector=self.sector, - industry=self.industry, - period=self.period, - period_length=ns_parser.period, - marketcap=self.mktcap, - currency=ns_parser.currency, - exclude_exchanges=self.exclude_exchanges, - limit=ns_parser.limit, - export=ns_parser.export, - raw=ns_parser.raw, - already_loaded_stocks_data=self.stocks_data, - ) + if not self.country and not self.sector and not self.industry: + console.print( + "[red]Select at least one filter from sector, country or industry.[/red]\n" + ) + else: + try: + console.print( + "[param]If it takes too long, you can use 'Ctrl + C' to cancel.\n[/param]" + ) + if ns_parser.currency != self.currency: + self.stocks_data = {} + ( + self.stocks_data, + self.tickers, + ) = stockanalysis_view.display_plots_financials( + finance_key=ns_parser.metric, + country=self.country, + sector=self.sector, + industry=self.industry, + period=self.period, + period_length=ns_parser.period, + marketcap=self.mktcap, + currency=ns_parser.currency, + exclude_exchanges=self.exclude_exchanges, + limit=ns_parser.limit, + export=ns_parser.export, + raw=ns_parser.raw, + already_loaded_stocks_data=self.stocks_data, + ) - self.currency = ns_parser.currency + self.currency = ns_parser.currency + except KeyboardInterrupt: + console.print( + "[param]For a faster search, ensure that you select at least one filter" + "from sector, country or industry.\n[/param]" + ) @log_start_end(log=logger) def call_cps(self, other_args: List[str]): diff --git a/tests/openbb_terminal/stocks/sector_industry_analysis/cassettes/test_sia_controller/test_menu_without_queue_completion.yaml b/tests/openbb_terminal/stocks/sector_industry_analysis/cassettes/test_sia_controller/test_menu_without_queue_completion.yaml new file mode 100644 index 00000000000..75ebb4387aa --- /dev/null +++ b/tests/openbb_terminal/stocks/sector_industry_analysis/cassettes/test_sia_controller/test_menu_without_queue_completion.yaml @@ -0,0 +1,252 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/Database/Categories/equities_industries.json + response: + body: + string: !!binary | + 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 + hRqhvJx0vu23P//49/97iI42IRwAAA== + headers: + Accept-Ranges: + - bytes + Access-Control-Allow-Origin: + - '*' + Cache-Control: + - max-age=300 + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Length: + - '2017' + Content-Security-Policy: + - default-src 'none'; style-src 'unsafe-inline'; sandbox + Content-Type: + - text/plain; charset=utf-8 + Date: + - Tue, 16 Aug 2022 07:29:39 GMT + ETag: + - W/"bec06f34decad0baec39ad6c71d6246490e25b7c2b763e54e88d22c78bcd2b05" + Expires: + - Tue, 16 Aug 2022 07:34:39 GMT + Source-Age: + - '10' + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization,Accept-Encoding,Origin + Via: + - 1.1 varnish + X-Cache: + - HIT + X-Cache-Hits: + - '1' + X-Content-Type-Options: + - nosniff + X-Fastly-Request-ID: + - 14e2c81643c483d207054c322c433c52704536cc + X-Frame-Options: + - deny + X-GitHub-Request-Id: + - C5BA:E164:59BCAE:60A1FA:62FB2871 + X-Served-By: + - cache-cdg20769-CDG + X-Timer: + - S1660634980.910673,VS0,VE1 + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/Database/Categories/equities_sectors.json + response: + body: + string: !!binary | + H4sIAAAAAAAAA2WPuw7CMAxF90r9h6gzX0Epj4GFx4QYLNe0llJHStJK/XuChJJAMjnn+vraj7pS + 4TXN5ltswTGqM3iyDNpF3pppmoURPBtRV7ILI+WyDNpMZIPxh7o5QNWuqINXl8qOXiSOFyqlgzF9 + mtUJ2WGN3z0LCHI2MpJyuyOB9iOCTSkn6WfnPzf+5SQhsUvwq875cFxkRciNcBSjTbbk3bNmz6Gp + rp5vNAjipmsBAAA= + headers: + Accept-Ranges: + - bytes + Access-Control-Allow-Origin: + - '*' + Cache-Control: + - max-age=300 + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Length: + - '182' + Content-Security-Policy: + - default-src 'none'; style-src 'unsafe-inline'; sandbox + Content-Type: + - text/plain; charset=utf-8 + Date: + - Tue, 16 Aug 2022 07:29:39 GMT + ETag: + - W/"263950799e0dc59b79009e2f6d9b7b42ba7de8ea2c367a0947e8ef59f28686c6" + Expires: + - Tue, 16 Aug 2022 07:34:39 GMT + Source-Age: + - '11' + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization,Accept-Encoding,Origin + Via: + - 1.1 varnish + X-Cache: + - HIT + X-Cache-Hits: + - '1' + X-Content-Type-Options: + - nosniff + X-Fastly-Request-ID: + - 86f9a1ad8e0a7ddc1e7c6a099d50b91bf2c2ee6e + X-Frame-Options: + - deny + X-GitHub-Request-Id: + - B07E:F863:586F92:5F436E:62FB2871 + X-Served-By: + - cache-cdg20744-CDG + X-Timer: + - S1660634980.990352,VS0,VE1 + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: https://raw.githubusercontent.com/JerBouma/FinanceDatabase/master/Database/Categories/equities_countries.json + response: + body: + string: !!binary | + H4sIAAAAAAAAA21UTVPbMBC9M8N/0HDunwgppCEkk8bAgU4PG3uRt5EldyUR7F9fGdpoFeqDZ97T + fmn3rX5cXqj0Xc1edAuWfAB79eUfZ3UkYyATrNEGsoKJPjAYOmMkHpH3QL9E3GtooQMvsNUGGvSt + oJJT44QNGk2xk5hGFJC72OSs1y74I4hCrxlGMgJSIN+qJ2JNVi29AdvkbHPo9q4Rt5inWI2EQwf/ + cWvJoESigLkzrtvLkC41W+2oFtTQcxThRqxbtcM+7g3VJ/or2g74kLHryKYw9rPpjR76kJEPzooK + bsEcpgt8usct2YnImMHWKCDaVNgikuzwAvYuz3iBLnVWnKYBgR0ybgtf2icVBeDMMKJIOcGypkVE + th5zxG/OarVKv8xEq4GzxbLGIsTSyhEn5Cx6yfCZvTeo3ItaCy0vPQNmXS0DGJHw1fGg5g58HsId + 9ML9Dlne4c5xI05XMMKhLXZyNbAexoK6h/Aqqr6npJqA1gckYUShjSCnfx/fMKk8cm7YGmqIEmFT + CGYNBgZfEkGiOK2VUPAa36h2GToLJdROvh2JSIWjZmnDri58xrSb9DtmbawHmBbihDfQkVy0DYYW + uVS44NQsPWnGoDw8qmeEYvYb0iiftY3jI+TBbZOaOxCwj6CmOGlJLIoD5NzgbXouqO+TQc69dUXa + reMQNWSBfQe5JTuMlsTW7VxXzHgXvRxXBbEhNWOQ7ammjosMFaWt6R3nBlfGvcJBuiQCZZ7KxdCq + 2QvL1+yDXKVIgutBiLJKekl9E5mO2KA4P1IYP8Z04h6AjkL8D2DH4soPLVDpEPkgVuzxwKmEnPLR + UsDmvSnqpiOGIKbx93CVWtK47pyuQmnMUUehiSfCkG53ws/w/v5fXvz8A5FdW1d1BwAA + headers: + Accept-Ranges: + - bytes + Access-Control-Allow-Origin: + - '*' + Cache-Control: + - max-age=300 + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Length: + - '678' + Content-Security-Policy: + - default-src 'none'; style-src 'unsafe-inline'; sandbox + Content-Type: + - text/plain; charset=utf-8 + Date: + - Tue, 16 Aug 2022 07:29:40 GMT + ETag: + - W/"3e9fcbc95bfd7c6294e48a7aa396eb8aa56a8809e3c5ab96a4782aa16b34e7f7" + Expires: + - Tue, 16 Aug 2022 07:34:40 GMT + Source-Age: + - '11' + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization,Accept-Encoding,Origin + Via: + - 1.1 varnish + X-Cache: + - HIT + X-Cache-Hits: + - '1' + X-Content-Type-Options: + - nosniff + X-Fastly-Request-ID: + - bf64e01b6a8da093db057b3ce4e57f3c378843f6 + X-Frame-Options: + - deny + X-GitHub-Request-Id: + - 845E:D47E:53F0D0:59C146:62FADD04 + X-Served-By: + - cache-cdg20737-CDG + X-Timer: + - S1660634980.070336,VS0,VE1 + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_industries[-].json b/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_industries[-].json index 5f1589e0bed..5b4f08626c5 100644 --- a/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_industries[-].json +++ b/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_industries[-].json @@ -1 +1 @@ -["", "Advertising Agencies", "Aerospace & Defense", "Aerospace Defense - Major Diversified", "Aerospace Defense Products & Services", "Agricultural Chemicals", "Agricultural Inputs", "Air Delivery & Freight Services", "Airlines", "Airports & Air Services", "Aluminum", "Apparel Manufacturing", "Apparel Retail", "Apparel Stores", "Asset Management", "Auto & Truck Dealerships", "Auto Dealerships", "Auto Manufacturers", "Auto Manufacturers - Major", "Auto Parts", "Banks - Diversified", "Banks - Regional", "Beverages - Brewers", "Beverages - Non-Alcoholic", "Beverages - Soft Drinks", "Beverages - Wineries & Distilleries", "Beverages - Wineries & Distillers", "Biotechnology", "Broadcasting", "Broadcasting - TV", "Building Materials", "Building Products & Equipment", "Business Equipment", "Business Equipment & Supplies", "Business Services", "Business Software & Services", "Capital Markets", "Chemicals", "Chemicals - Major Diversified", "Cigarettes", "Closed-End Fund - Equity", "Coking Coal", "Communication Equipment", "Computer Based Systems", "Computer Hardware", "Confectioners", "Conglomerates", "Consulting Services", "Consumer Electronics", "Copper", "Credit Services", "Department Stores", "Diagnostics & Research", "Discount Stores", "Discount, Variety Stores", "Diversified Computer Systems", "Diversified Electronics", "Diversified Investments", "Diversified Machinery", "Diversified Utilities", "Drug Manufacturers - General", "Drug Manufacturers - Major", "Drug Manufacturers - Other", "Drug Manufacturers - Specialty & Generic", "Drugs - Generic", "Education & Training Services", "Electric Utilities", "Electrical Equipment & Parts", "Electronic Components", "Electronic Equipment", "Electronic Gaming & Multimedia", "Electronics & Computer Distribution", "Electronics Wholesale", "Engineering & Construction", "Entertainment", "Entertainment - Diversified", "Farm & Construction Machinery", "Farm & Heavy Construction Machinery", "Farm Products", "Financial Conglomerates", "Financial Data & Stock Exchanges", "Food - Major Diversified", "Food Distribution", "Food Wholesale", "Footwear & Accessories", "Furnishings, Fixtures & Appliances", "Gambling", "Gaming Activities", "General Building Materials", "General Contractors", "Gold", "Grocery Stores", "Health Care Plans", "Health Information Services", "Healthcare Information Services", "Healthcare Plans", "Heavy Construction", "Home Furnishings & Fixtures", "Home Improvement Retail", "Hospitals", "Household & Personal Products", "Independent Oil & Gas", "Industrial Distribution", "Industrial Equipment Wholesale", "Industrial Metals & Minerals", "Information Technology Services", "Infrastructure Operations", "Insurance - Diversified", "Insurance - Life", "Insurance - Property & Casualty", "Insurance - Reinsurance", "Insurance - Specialty", "Insurance Brokers", "Integrated Freight & Logistics", "Internet Content & Information", "Internet Information Providers", "Internet Retail", "Internet Service Providers", "Internet Software & Services", "Investment Brokerage - National", "Jewelry Stores", "Leisure", "Life Insurance", "Lodging", "Long Distance Carriers", "Lumber & Wood Production", "Lumber, Wood Production", "Luxury Goods", "Machine Tools & Accessories", "Major Airlines", "Major Integrated Oil & Gas", "Marine Shipping", "Marketing Services", "Medical Appliances & Equipment", "Medical Care Facilities", "Medical Devices", "Medical Distribution", "Medical Instruments & Supplies", "Medical Laboratories & Research", "Metal Fabrication", "Money Center Banks", "Mortgage Finance", "Mortgage Investment", "Multimedia & Graphics Software", "Networking & Communication Devices", "Nonmetallic Mineral Mining", "Oil & Gas Drilling", "Oil & Gas Drilling & Exploration", "Oil & Gas E&P", "Oil & Gas Equipment & Services", "Oil & Gas Integrated", "Oil & Gas Midstream", "Oil & Gas Pipelines", "Oil & Gas Refining & Marketing", "Other Industrial Metals & Mining", "Other Precious Metals & Mining", "Packaged Foods", "Packaging & Containers", "Paper & Paper Products", "Personal Products", "Personal Services", "Pharmaceutical Retailers", "Pollution & Treatment Controls", "Printed Circuit Boards", "Processed & Packaged Goods", "Property & Casualty Insurance", "Property Management", "Publishing", "Publishing - Newspapers", "REIT - Diversified", "REIT - Healthcare Facilities", "REIT - Hotel & Motel", "REIT - Industrial", "REIT - Mortgage", "REIT - Office", "REIT - Residential", "REIT - Retail", "REIT - Specialty", "Railroads", "Real Estate - Development", "Real Estate - Diversified", "Real Estate Development", "Real Estate Services", "Recreational Goods, Other", "Recreational Vehicles", "Regional - Mid-Atlantic Banks", "Rental & Leasing Services", "Research Services", "Residential Construction", "Resorts & Casinos", "Restaurants", "Rubber & Plastics", "Scientific & Technical Instruments", "Security & Protection Services", "Security Software & Services", "Semiconductor - Broad Line", "Semiconductor Equipment & Materials", "Semiconductor- Memory Chips", "Semiconductors", "Shell Companies", "Shipping", "Silver", "Software - Application", "Software - Infrastructure", "Solar", "Specialized Health Services", "Specialty Business Services", "Specialty Chemicals", "Specialty Industrial Machinery", "Specialty Retail", "Specialty Retail, Other", "Staffing & Employment Services", "Staffing & Outsourcing Services", "Steel", "Steel & Iron", "Technical & System Software", "Telecom Services", "Textile - Apparel Clothing", "Textile - Apparel Footwear & Accessories", "Textile Industrial", "Textile Manufacturing", "Thermal Coal", "Tobacco", "Tobacco Products, Other", "Tools & Accessories", "Travel Services", "Trucking", "Trucks & Other Vehicles", "Uranium", "Utilities - Diversified", "Utilities - Independent Power Producers", "Utilities - Regulated Electric", "Utilities - Regulated Gas", "Utilities - Regulated Water", "Utilities - Renewable", "Waste Management", "Water Utilities", "Wireless Communications"] \ No newline at end of file +["Advertising Agencies", "Aerospace & Defense", "Aerospace Defense - Major Diversified", "Aerospace Defense Products & Services", "Agricultural Chemicals", "Agricultural Inputs", "Air Delivery & Freight Services", "Airlines", "Airports & Air Services", "Aluminum", "Apparel Manufacturing", "Apparel Retail", "Apparel Stores", "Asset Management", "Auto & Truck Dealerships", "Auto Dealerships", "Auto Manufacturers", "Auto Manufacturers - Major", "Auto Parts", "Banks - Diversified", "Banks - Regional", "Beverages - Brewers", "Beverages - Non-Alcoholic", "Beverages - Soft Drinks", "Beverages - Wineries & Distilleries", "Beverages - Wineries & Distillers", "Biotechnology", "Broadcasting", "Broadcasting - TV", "Building Materials", "Building Products & Equipment", "Business Equipment", "Business Equipment & Supplies", "Business Services", "Business Software & Services", "Capital Markets", "Chemicals", "Chemicals - Major Diversified", "Cigarettes", "Closed-End Fund - Equity", "Coking Coal", "Communication Equipment", "Computer Based Systems", "Computer Hardware", "Confectioners", "Conglomerates", "Consulting Services", "Consumer Electronics", "Copper", "Credit Services", "Department Stores", "Diagnostics & Research", "Discount Stores", "Discount, Variety Stores", "Diversified Computer Systems", "Diversified Electronics", "Diversified Investments", "Diversified Machinery", "Diversified Utilities", "Drug Manufacturers - General", "Drug Manufacturers - Major", "Drug Manufacturers - Other", "Drug Manufacturers - Specialty & Generic", "Drugs - Generic", "Education & Training Services", "Electric Utilities", "Electrical Equipment & Parts", "Electronic Components", "Electronic Equipment", "Electronic Gaming & Multimedia", "Electronics & Computer Distribution", "Electronics Wholesale", "Engineering & Construction", "Entertainment", "Entertainment - Diversified", "Farm & Construction Machinery", "Farm & Heavy Construction Machinery", "Farm Products", "Financial Conglomerates", "Financial Data & Stock Exchanges", "Food - Major Diversified", "Food Distribution", "Food Wholesale", "Footwear & Accessories", "Furnishings, Fixtures & Appliances", "Gambling", "Gaming Activities", "General Building Materials", "General Contractors", "Gold", "Grocery Stores", "Health Care Plans", "Health Information Services", "Healthcare Information Services", "Healthcare Plans", "Heavy Construction", "Home Furnishings & Fixtures", "Home Improvement Retail", "Hospitals", "Household & Personal Products", "Independent Oil & Gas", "Industrial Distribution", "Industrial Equipment Wholesale", "Industrial Metals & Minerals", "Information Technology Services", "Infrastructure Operations", "Insurance - Diversified", "Insurance - Life", "Insurance - Property & Casualty", "Insurance - Reinsurance", "Insurance - Specialty", "Insurance Brokers", "Integrated Freight & Logistics", "Internet Content & Information", "Internet Information Providers", "Internet Retail", "Internet Service Providers", "Internet Software & Services", "Investment Brokerage - National", "Jewelry Stores", "Leisure", "Life Insurance", "Lodging", "Long Distance Carriers", "Lumber & Wood Production", "Lumber, Wood Production", "Luxury Goods", "Machine Tools & Accessories", "Major Airlines", "Major Integrated Oil & Gas", "Marine Shipping", "Marketing Services", "Medical Appliances & Equipment", "Medical Care Facilities", "Medical Devices", "Medical Distribution", "Medical Instruments & Supplies", "Medical Laboratories & Research", "Metal Fabrication", "Money Center Banks", "Mortgage Finance", "Mortgage Investment", "Multimedia & Graphics Software", "Networking & Communication Devices", "Nonmetallic Mineral Mining", "Oil & Gas Drilling", "Oil & Gas Drilling & Exploration", "Oil & Gas E&P", "Oil & Gas Equipment & Services", "Oil & Gas Integrated", "Oil & Gas Midstream", "Oil & Gas Pipelines", "Oil & Gas Refining & Marketing", "Other Industrial Metals & Mining", "Other Precious Metals & Mining", "Packaged Foods", "Packaging & Containers", "Paper & Paper Products", "Personal Products", "Personal Services", "Pharmaceutical Retailers", "Pollution & Treatment Controls", "Printed Circuit Boards", "Processed & Packaged Goods", "Property & Casualty Insurance", "Property Management", "Publishing", "Publishing - Newspapers", "REIT - Diversified", "REIT - Healthcare Facilities", "REIT - Hotel & Motel", "REIT - Industrial", "REIT - Mortgage", "REIT - Office", "REIT - Residential", "REIT - Retail", "REIT - Specialty", "Railroads", "Real Estate - Development", "Real Estate - Diversified", "Real Estate Development", "Real Estate Services", "Recreational Goods, Other", "Recreational Vehicles", "Regional - Mid-Atlantic Banks", "Rental & Leasing Services", "Research Services", "Residential Construction", "Resorts & Casinos", "Restaurants", "Rubber & Plastics", "Scientific & Technical Instruments", "Security & Protection Services", "Security Software & Services", "Semiconductor - Broad Line", "Semiconductor Equipment & Materials", "Semiconductor- Memory Chips", "Semiconductors", "Shell Companies", "Shipping", "Silver", "Software - Application", "Software - Infrastructure", "Solar", "Specialized Health Services", "Specialty Business Services", "Specialty Chemicals", "Specialty Industrial Machinery", "Specialty Retail", "Specialty Retail, Other", "Staffing & Employment Services", "Staffing & Outsourcing Services", "Steel", "Steel & Iron", "Technical & System Software", "Telecom Services", "Textile - Apparel Clothing", "Textile - Apparel Footwear & Accessories", "Textile Industrial", "Textile Manufacturing", "Thermal Coal", "Tobacco", "Tobacco Products, Other", "Tools & Accessories", "Travel Services", "Trucking", "Trucks & Other Vehicles", "Uranium", "Utilities - Diversified", "Utilities - Independent Power Producers", "Utilities - Regulated Electric", "Utilities - Regulated Gas", "Utilities - Regulated Water", "Utilities - Renewable", "Waste Management", "Water Utilities", "Wireless Communications"] \ No newline at end of file diff --git a/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_sectors[-].json b/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_sectors[-].json index 2ee7ea70769..486c9e6feb0 100644 --- a/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_sectors[-].json +++ b/tests/openbb_terminal/stocks/sector_industry_analysis/json/test_financedatabase_model/test_get_sectors[-].json @@ -1 +1 @@ -["", "Basic Materials", "Communication Services", "Conglomerates", "Consumer Cyclical", "Consumer Defensive", "Consumer Goods", "Energy", "Financial", "Financial Services", "Healthcare", "Industrial Goods", "Industrials", "Real Estate", "Services", "Technology", "Utilities"] \ No newline at end of file +["Basic Materials", "Communication Services", "Conglomerates", "Consumer Cyclical", "Consumer Defensive", "Consumer Goods", "Energy", "Financial", "Financial Services", "Healthcare", "Industrial Goods", "Industrials", "Real Estate", "Services", "Technology", "Utilities"] \ No newline at end of file diff --git a/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py b/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py index 0b949901892..06306fb97bb 100644 --- a/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py +++ b/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py @@ -76,7 +76,7 @@ def test_menu_with_queue(expected, mocker, queue): assert result_menu == expected -@pytest.mark.vcr(record_mode="none") +@pytest.mark.vcr def test_menu_without_queue_completion(mocker): path_controller = "openbb_terminal.stocks.sector_industry_analysis.sia_controller" @@ -333,8 +333,8 @@ def test_call_func_expect_queue(expected_queue, func, queue): ], "financedatabase_view.display_companies_per_sector_in_country", [ - "United States", - "Large", + "MOCK_COUNTRY", + "", True, "csv", True, @@ -353,8 +353,8 @@ def test_call_func_expect_queue(expected_queue, func, queue): ], "financedatabase_view.display_companies_per_industry_in_country", [ - "United States", - "Large", + "MOCK_COUNTRY", + "", True, "csv", True, @@ -373,8 +373,8 @@ def test_call_func_expect_queue(expected_queue, func, queue): ], "financedatabase_view.display_companies_per_industry_in_sector", [ - "Financial Services", - "Large", + "MOCK_SECTOR", + "", True, "csv", True, @@ -393,8 +393,8 @@ def test_call_func_expect_queue(expected_queue, func, queue): ], "financedatabase_view.display_companies_per_country_in_sector", [ - "Financial Services", - "Large", + "MOCK_SECTOR", + "", True, "csv", True, @@ -413,8 +413,8 @@ def test_call_func_expect_queue(expected_queue, func, queue): ], "financedatabase_view.display_companies_per_country_in_industry", [ - "Financial Data & Stock Exchanges", - "Large", + "MOCK_INDUSTRY", + "", True, "csv", True, @@ -450,8 +450,12 @@ def test_call_func( ) controller = sia_controller.SectorIndustryAnalysisController( - ticker=None, queue=None + ticker=None, + queue=None, ) + controller.country = "MOCK_COUNTRY" + controller.sector = "MOCK_SECTOR" + controller.industry = "MOCK_INDUSTRY" getattr(controller, tested_func)(other_args) if called_args or called_kwargs: @@ -460,8 +464,12 @@ def test_call_func( mock.assert_called_once() else: controller = sia_controller.SectorIndustryAnalysisController( - ticker=None, queue=None + ticker=None, + queue=None, ) + controller.country = "MOCK_COUNTRY" + controller.sector = "MOCK_SECTOR" + controller.industry = "MOCK_INDUSTRY" getattr(controller, tested_func)(other_args) diff --git a/tests/openbb_terminal/stocks/sector_industry_analysis/txt/test_sia_controller/test_print_help.txt b/tests/openbb_terminal/stocks/sector_industry_analysis/txt/test_sia_controller/test_print_help.txt index e62349613e9..7f3a3df420c 100644 --- a/tests/openbb_terminal/stocks/sector_industry_analysis/txt/test_sia_controller/test_print_help.txt +++ b/tests/openbb_terminal/stocks/sector_industry_analysis/txt/test_sia_controller/test_print_help.txt @@ -1,34 +1,33 @@ - load load a specific ticker and all it's corresponding parameters - - clear clear all or one of industry, sector, country and market cap parameters - industry see existing industries, or set industry if arg specified - sector see existing sectors, or set sector if arg specified - country see existing countries, or set country if arg specified - mktcap set mktcap between nano, micro, small, mid, large or mega - exchange revert exclude international exchanges flag - period set period between annual, quarterly or trailing [StockAnalysis] - -Industry : Financial Data & Stock Exchanges -Sector : Financial Services -Country : United States -Market Cap : Large -Exclude Exchanges : True -Period : Annual - -Statistics: - cps companies per Sector based on Country (and Market Cap) - cpic companies per Industry based on Country (and Market Cap) - cpis companies per Industry based on Sector (and Market Cap) - cpcs companies per Country based on Sector (and Market Cap) - cpci companies per Country based on Industry (and Market Cap) - -Financials - loaded data (fast mode): - sama see all metrics available [Yahoo Finance] - metric visualize financial metric across filters selected [Yahoo Finance] - satma see all metrics available over time [StockAnalysis] - vis visualize financial metric across filters selected [StockAnalysis] - -Returned tickers: -[unvl]> ca take these to comparison analysis menu[/unvl] - - + load load a specific ticker and all it's corresponding parameters + + clear clear all or one of industry, sector, country and market cap parameters + industry see existing industries, or set industry if arg specified + sector see existing sectors, or set sector if arg specified + country see existing countries, or set country if arg specified + mktcap set mktcap between nano, micro, small, mid, large or mega + exchange revert exclude international exchanges flag + period set period between annual, quarterly or trailing [StockAnalysis] + +Industry : +Sector : +Country : +Market Cap : +Exclude Exchanges : True +Period : Annual + +Statistics: +[unvl] cps companies per Sector based on Country (and Market Cap)[/unvl] +[unvl] cpic companies per Industry based on Country (and Market Cap)[/unvl] +[unvl] cpis companies per Industry based on Sector (and Market Cap)[/unvl] +[unvl] cpcs companies per Country based on Sector (and Market Cap)[/unvl] +[unvl] cpci companies per Country based on Industry (and Market Cap)[/unvl] + +Financials - loaded data (fast mode): + sama see all metrics available [Yahoo Finance] + metric visualize financial metric across filters selected [Yahoo Finance] + satma see all metrics available over time [StockAnalysis] + vis visualize financial metric across filters selected [StockAnalysis] + +Returned tickers: +[unvl]> ca take these to comparison analysis menu[/unvl] +