}L i".vddlZddlmZmZddlZddlmZddlm Z m Z ddl m Z ddl mZe dZGdd Zy) N)DictOptional)utils) _BASE_URL_ _SENTINEL_)YfData)YFDataExceptionz/v10/finance/quoteSummary/ceZdZdZefdedefdZdefdZe defdZ e de ee effdZ e dejfd Ze de eeffd Ze dejfd Ze dejfd Ze dejfd Ze de eeffdZe de eeffdZdZddZeddZddZddZdZy) FundsDataz ETF and Mutual Funds Data Queried Modules: quoteType, summaryProfile, fundProfile, topHoldings Notes: - fundPerformance module is not implemented as better data is queryable using history datasymbolc*||_||_|tur7tjdt d|jj |d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_y)z Args: data (YfData): The YfData object for fetching data. symbol (str): The symbol of the fund. z=Set proxy via new config function: yf.set_config(proxy=proxy)) stacklevelN)_data_symbolrwarningswarnDeprecationWarning _set_proxy _quote_type _description_fund_overview_fund_operations_asset_classes _top_holdings_equity_holdings_bond_holdings _bond_ratings_sector_weightings)selfr r proxys ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/yfinance/scrapers/funds.py__init__zFundsData.__init__s    " MMY[mz{ | JJ ! !% ( !# $#! $"!"&returncR|j|j|jS)zh Returns the quote type of the fund. Returns: str: The quote type. )r_fetch_and_parser!s r# quote_typezFundsData.quote_type2s(    #  ! ! #r%cR|j|j|jS)zj Returns the description of the fund. Returns: str: The description. )rr(r)s r# descriptionzFundsData.description=s(    $  ! ! #   r%cR|j|j|jS)zw Returns the fund overview. Returns: Dict[str, Optional[str]]: The fund overview. )rr(r)s r# fund_overviewzFundsData.fund_overviewI(    &  ! ! #"""r%cR|j|j|jS)zo Returns the fund operations. Returns: pd.DataFrame: The fund operations. )rr(r)s r#fund_operationszFundsData.fund_operationsU(  (  ! ! #$$$r%cR|j|j|jS)z{ Returns the asset classes of the fund. Returns: Dict[str, float]: The asset classes. )rr(r)s r# asset_classeszFundsData.asset_classesar/r%cR|j|j|jS)zu Returns the top holdings of the fund. Returns: pd.DataFrame: The top holdings. )rr(r)s r# top_holdingszFundsData.top_holdingsm(    %  ! ! #!!!r%cR|j|j|jS)z{ Returns the equity holdings of the fund. Returns: pd.DataFrame: The equity holdings. )rr(r)s r#equity_holdingszFundsData.equity_holdingsyr2r%cR|j|j|jS)zw Returns the bond holdings of the fund. Returns: pd.DataFrame: The bond holdings. )rr(r)s r# bond_holdingszFundsData.bond_holdingsr/r%cR|j|j|jS)zy Returns the bond ratings of the fund. Returns: Dict[str, float]: The bond ratings. )rr(r)s r# bond_ratingszFundsData.bond_ratingsr7r%cR|j|j|jS)z Returns the sector weightings of the fund. Returns: Dict[str, float]: The sector weightings. )r r(r)s r#sector_weightingszFundsData.sector_weightingss(  " " *  ! ! #&&&r%cdjgd}|d|jdd}|jjt|jz|}|S)zp Fetches the raw JSON data from the API. Returns: dict: The raw JSON data. ,) quoteTypesummaryProfile topHoldings fundProfilezfinance.yahoo.comfalse)modules corsDomainr formatted)params)joinrr get_raw_json_QUOTE_SUMMARY_URL_)r!rG params_dictresults r#_fetchzFundsData._fetchsS((XY")9LX\XdXdsz{ (()}|j|d |j|d |j|d @t j |||d j d|_|jdi}t j dgd|j|j|jdtj|j|jdtj|j|jdtj|j|jdtj|j|jdtj|j|jdtjgd|j|jdtj|j|jdtj|j|jdtj|j|jdtj|j|jdtj|j|jdtjgij d|_ |jdi}t j dgd |j|j|jd!tj|j|jd"tj|j|jd#tjgd|j|jd$tj|j|jd%tj|j|jd&tjgij d|_ td'|jd(gD|_ td)|jd*gD|_y)+zl Parses the top holdings from the data. Args: data: The data to parse. cashPositionN stockPosition bondPositionpreferredPositionconvertiblePosition otherPosition)rirjrkrlrmrnholdingsr holdingNameholdingPercent)SymbolNamezHolding PercentrrequityHoldingsAverage)zPrice/Earningsz Price/Bookz Price/SaleszPrice/CashflowzMedian Market Capz3 Year Earnings GrowthpriceToEarnings priceToBook priceToSalespriceToCashflowmedianMarketCapthreeYearEarningsGrowthCategory AveragepriceToEarningsCatpriceToBookCatpriceToSalesCatpriceToCashflowCatmedianMarketCapCatthreeYearEarningsGrowthCat bondHoldings)DurationMaturityzCredit Qualitydurationmaturity creditQuality durationCat maturityCatcreditQualityCatc38K|]}|D] }|||f ywN.0dkeys r# z0FundsData._parse_top_holdings...s&!bA`a!bY\3#-!b-!b bondRatingsc38K|]}|D] }|||f ywrrrs r#rz0FundsData._parse_top_holdings..1s&&ljk&lcfQsV}&l}&lrsectorWeightings)rdrbrappendpd DataFrame set_indexrrNArrrarr ) r!r _holdingsr_name_holding_percentitemrrs r#rUzFundsData._parse_top_holdingss~!22488ND3QR!33DHH_d4ST 22488ND3QR!%!7!7ATVZ8[!\#'#9#9$((CXZ^:_#`!33DHH_d4ST  HHZ, +-r2( * LLm, -  # #D)9$: ; <  \\/+   9X   88$4b9 " H LL&&'7';';^&l"lr%c`|jdd|jdd|jddd|_|jdi}|jdi}tjdgd |j|j |jd tj |j |jd tj |j |jd tj gd |j |jd tj |j |jd tj |j |jd tj gijd|_y)zl Parses the fund profile from the data. Args: data: The data to parse. categoryNameNfamily legalType)rrrfeesExpensesInvestmentfeesExpensesInvestmentCat Attributes)zAnnual Report Expense RatiozAnnual Holdings TurnoverzTotal Net AssetsannualReportExpenseRatioannualHoldingsTurnovertotalNetAssetsr|) rbrrrrrdrrr)r!r r_fund_operations_cats r#rVzFundsData._parse_fund_profile3st!HH^T: HHXt4 HH[$7   88$rs4!1 /# $>?C#C#r%