diff --git a/openbb_terminal/stocks/stocks_controller.py b/openbb_terminal/stocks/stocks_controller.py index fe0bc20eb169..e33009823629 100644 --- a/openbb_terminal/stocks/stocks_controller.py +++ b/openbb_terminal/stocks/stocks_controller.py @@ -242,10 +242,6 @@ def call_search(self, other_args: List[str]): exchange_country=exchange, all_exchanges=ns_parser.all_exchanges, limit=ns_parser.limit, - export=ns_parser.export, - sheet_name=" ".join(ns_parser.sheet_name) - if ns_parser.sheet_name - else None, ) @log_start_end(log=logger) diff --git a/openbb_terminal/stocks/stocks_helper.py b/openbb_terminal/stocks/stocks_helper.py index e55b7c9e55a1..34856e9a5272 100644 --- a/openbb_terminal/stocks/stocks_helper.py +++ b/openbb_terminal/stocks/stocks_helper.py @@ -27,7 +27,6 @@ from openbb_terminal import config_terminal as cfg from openbb_terminal.helper_funcs import ( - export_data, lambda_long_number_format_y_axis, plot_autoscale, print_rich_table, @@ -106,9 +105,7 @@ def search( exchange_country: str = "", all_exchanges: bool = False, limit: int = 0, - export: str = "", - sheet_name: Optional[str] = "", -) -> None: +) -> pd.DataFrame: """Search selected query for tickers. Parameters @@ -127,8 +124,12 @@ def search( Whether to search all exchanges, without this option only the United States market is searched limit : int The limit of companies shown. - export : str - Export data + + Returns + ------- + df: pd.DataFrame + Dataframe of search results. + Empty Dataframe if none are found. Examples -------- @@ -157,10 +158,10 @@ def search( console.print( "[red]No companies were found that match the given criteria.[/red]\n" ) - return + return pd.DataFrame() if not data: console.print("No companies found.\n") - return + return pd.DataFrame() if query: d = fd.search_products( @@ -180,23 +181,18 @@ def search( if not d: console.print("No companies found.\n") - return + return pd.DataFrame() df = pd.DataFrame.from_dict(d).T[ ["long_name", "short_name", "country", "sector", "industry", "exchange"] ] - if exchange_country: - if exchange_country in market_coverage_suffix: - suffix_tickers = [ - ticker.split(".")[1] if "." in ticker else "" - for ticker in list(df.index) - ] - df = df[ - [ - val in market_coverage_suffix[exchange_country] - for val in suffix_tickers - ] - ] + if exchange_country and exchange_country in market_coverage_suffix: + suffix_tickers = [ + ticker.split(".")[1] if "." in ticker else "" for ticker in list(df.index) + ] + df = df[ + [val in market_coverage_suffix[exchange_country] for val in suffix_tickers] + ] exchange_suffix = {} for k, v in market_coverage_suffix.items(): @@ -230,13 +226,7 @@ def search( title=title, ) - export_data( - export, - os.path.dirname(os.path.abspath(__file__)), - "search", - df, - sheet_name, - ) + return df def load( diff --git a/tests/openbb_terminal/stocks/test_stocks_controller.py b/tests/openbb_terminal/stocks/test_stocks_controller.py index 3316100ca583..c21086406fc6 100644 --- a/tests/openbb_terminal/stocks/test_stocks_controller.py +++ b/tests/openbb_terminal/stocks/test_stocks_controller.py @@ -263,8 +263,6 @@ def test_call_func_expect_queue(expected_queue, func, queue): industry="", all_exchanges=False, exchange_country="", - export="csv", - sheet_name=None, ), ), ( diff --git a/tests/openbb_terminal/stocks/test_stocks_helper.py b/tests/openbb_terminal/stocks/test_stocks_helper.py index 7c53cee644d7..811d4073b5e6 100644 --- a/tests/openbb_terminal/stocks/test_stocks_helper.py +++ b/tests/openbb_terminal/stocks/test_stocks_helper.py @@ -50,7 +50,6 @@ def test_search(mocker, use_tab): exchange_country="", all_exchanges=False, limit=5, - export="", ) diff --git a/website/content/sdk/reference/stocks/search.md b/website/content/sdk/reference/stocks/search.md index c98fc22cbc63..085839cac16d 100644 --- a/website/content/sdk/reference/stocks/search.md +++ b/website/content/sdk/reference/stocks/search.md @@ -10,29 +10,30 @@ Search selected query for tickers. Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/stocks/stocks_helper.py#L98)] ```python -openbb.stocks.search(query: str = "", country: str = "", sector: str = "", industry: str = "", exchange_country: str = "", limit: int = 0, export: str = "") +openbb.stocks.search(query: str = "", country: str = "", sector: str = "", industry: str = "", exchange_country: str = "", limit: int = 0) ``` --- ## Parameters -| Name | Type | Description | Default | Optional | -| ---- | ---- | ----------- | ------- | -------- | -| query | str | The search term used to find company tickers | | True | -| country | str | Search by country to find stocks matching the criteria | | True | -| sector | str | Search by sector to find stocks matching the criteria | | True | -| industry | str | Search by industry to find stocks matching the criteria | | True | -| exchange_country | str | Search by exchange country to find stock matching | | True | -| limit | int | The limit of companies shown. | 0 | True | -| export | str | Export data | | True | - +| Name | Type | Description | Default | Optional | +|------------------|------|---------------------------------------------------------|---------|----------| +| query | str | The search term used to find company tickers | | True | +| country | str | Search by country to find stocks matching the criteria | | True | +| sector | str | Search by sector to find stocks matching the criteria | | True | +| industry | str | Search by industry to find stocks matching the criteria | | True | +| exchange_country | str | Search by exchange country to find stock matching | | True | +| limit | int | The limit of companies shown. | 0 | True | --- ## Returns -This function does not return anything +| Type | Description | +|--------------|----------------| +| pd.DataFrame | Search results | + ---