Skip to content

Search

Search any available asset at Investing.com.

Parameters:

Name Type Description Default
query str

Query to search for.

required
limit int

Maximum number of results to retrieve. Defaults to 10.

10
type Union[Literal['Stock', 'ETF', 'Commodity', 'Index', 'Future', 'Yield', 'FX'], None]

Type of asset to search for. Defaults to None.

None
exchange Union[str, None]

Exchange to search for. Defaults to None.

None

Returns:

Type Description
List[Dict[str, Any]]

A list of dictionaries with the search results from Investing.com.

Source code in investiny/search.py
def search_assets(
    query: str,
    limit: int = 10,
    type: Union[
        Literal[
            "Stock",
            "ETF",
            "Commodity",
            "Index",
            "Future",
            "Yield",
            "FX",
        ],
        None,
    ] = None,
    exchange: Union[str, None] = None,
) -> List[Dict[str, Any]]:
    """Search any available asset at Investing.com.

    Args:
        query: Query to search for.
        limit: Maximum number of results to retrieve. Defaults to 10.
        type: Type of asset to search for. Defaults to None.
        exchange: Exchange to search for. Defaults to None.

    Returns:
        A list of dictionaries with the search results from Investing.com.
    """
    params = {
        "query": query,
        "limit": limit,
        "type": type if type else "",
        "exchange": exchange if exchange else "",
    }
    return request_to_investing(endpoint="search", params=params)  # type: ignore

Last update: 2022-10-18
Created: 2022-10-18