
    h\                     X    d dl Zd dlZddlmZ ddlmZmZ ddlm	Z	  G d d          Z
dS )    N   )utils)
_BASE_URL_
_SENTINEL_)YfDatac                       e Zd ZddddddddddeddfdZddZedd
            Zedd            Zedd            Z	edd            Z
edd            Zedd            Zedd            ZdS )Search   TFN   c                 (   || _         t          | j                   | _        |t          ur6t	          j        dt          d           | j                            |           || _        || _	        |	| _
        || _        || _        || _        || _        || _        || _        || _        || _        |
| _        t)          j                    | _        i | _        i | _        g | _        g | _        g | _        g | _        g | _        |                                  dS )a6  
        Fetches and organizes search results from Yahoo Finance, including stock quotes and news articles.

        Args:
            query: The search query (ticker symbol or company name).
            max_results: Maximum number of stock quotes to return (default 8).
            news_count: Number of news articles to include (default 8).
            lists_count: Number of lists to include (default 8).
            include_cb: Include the company breakdown (default True).
            include_nav_links: Include the navigation links (default False).
            include_research: Include the research reports (default False).
            include_cultural_assets: Include the cultural assets (default False).
            enable_fuzzy_query: Enable fuzzy search for typos (default False).
            recommended: Recommended number of results to return (default 8).
            session: Custom HTTP session for requests (default None).
            timeout: Request timeout in seconds (default 30).
            raise_errors: Raise exceptions on error (default True).
        )sessionz=Set proxy via new config function: yf.set_config(proxy=proxy)   )
stacklevelN)r   r   _datar   warningswarnDeprecationWarning
_set_proxyquerymax_resultsenable_fuzzy_query
news_counttimeoutraise_errorslists_count
include_cb	nav_linksenable_researchenable_cultural_assetsrecommendedr   get_yf_logger_logger	_response_all_quotes_news_lists	_research_navsearch)selfr   r   r   r   r   include_nav_linksinclude_researchinclude_cultural_assetsr   r    r   proxyr   r   s                  M/var/www/html/marketdash/venv/lib/python3.11/site-packages/yfinance/search.py__init__zSearch.__init__   s   * DL111

""MY[mz{||||J!!%(((
&"4$(&$*/&=#&*,,	
	    returnc                    t            d}| j        | j        | j        | j        dd| j        | j        | j        | j        | j	        | j
        d}| j                            | j         dt          t          |                                | j                            ||| j                  }|	d|j        v rt'          d	          	 |                                }n9# t*          j        $ r' | j                            | j         d
           i }Y nw xY w|| _        d |                    dg           D             | _        |                    dg           | _        |                    dg           | _        |                    dg           | _        |                    dg           | _        | j        | j        | j        | j        | j        d| _        | S )z=Search using the query parameters defined in the constructor.z/v1/finance/searchtss_match_phrase_querynews_cie_vespa)qquotesCountenableFuzzyQuery	newsCountquotesQueryIdnewsQueryId
listsCountenableCbenableNavLinksenableResearchReportsenableCulturalAssetsrecommendedCountz: Yahoo GET parameters: )urlparamsr   NzWill be right backz~*** YAHOO! FINANCE IS CURRENTLY DOWN! ***
Our engineers are working quickly to resolve the issue. Thank you for your patience.zI: Failed to retrieve search results and received faulty response instead.c                     g | ]}d |v |	S )symbol ).0quotes     r0   
<listcomp>z!Search.search.<locals>.<listcomp>v   s#    WWW%XQVEVEVEVEVEVr2   quotesnewslistsresearchReportsnav)rK   rL   rM   researchrO   ) r   r   r   r   r   r   r   r   r   r   r    r"   debugstrdictr   	cache_getr   textRuntimeErrorjson_jsonJSONDecodeErrorerrorr#   getr%   r&   r'   r(   r)   r$   )r+   rC   rD   datas       r0   r*   zSearch.searchU   s   ///+ $ 75+*"n%)%9$($? $ 0
 
 	djUU#d6llBSBSUUVVVz##FDL#QQ</49<<  I J J J	99;;DD$ 	 	 	L$*wwwxxxDDD	 WW488Hb+A+AWWWXXfb))
hhw++"3R88HHUB''	#|TZ$+cgcq I' '	 s   C 3DDlistc                     | j         S )z'Get the quotes from the search results.)r%   r+   s    r0   rK   zSearch.quotes   s     |r2   c                     | j         S )z%Get the news from the search results.)r&   r_   s    r0   rL   zSearch.news   s     zr2   c                     | j         S )z&Get the lists from the search results.)r'   r_   s    r0   rM   zSearch.lists   s     {r2   c                     | j         S )z1Get the research reports from the search results.)r(   r_   s    r0   rP   zSearch.research        ~r2   c                     | j         S )z1Get the navigation links from the search results.)r)   r_   s    r0   rO   z
Search.nav        yr2   dict[str,list]c                     | j         S )zOGet all the results from the search results: filtered down version of response.)r$   r_   s    r0   allz
Search.all   re   r2   rS   c                     | j         S )z-Get the raw response from the search results.)r#   r_   s    r0   responsezSearch.response   rc   r2   )r3   r	   )r3   r]   )r3   rf   )r3   rS   )__name__
__module____qualname__r   r1   r*   propertyrK   rL   rM   rP   rO   rh   rj   rG   r2   r0   r	   r	      s?       *+qUYmr"'[`noZ$4 4 4 4l* * * *X    X    X    X    X    X    X    X  r2   r	   )rW   rX   r    r   constr   r   r\   r   r	   rG   r2   r0   <module>rq      s   ,            ) ) ) ) ) ) ) )      D D D D D D D D D Dr2   