
    N j8*                        S SK JrJr  S SKrS SKJrJrJrJrJ	r	  S SK
JrJr  S SK
JrJr  S SK
JrJr  S SKJr  SS	KJrJr  \" S
\\\R.                  4   S9r\	S   r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)    )ABCabstractmethodN)ListUnionDictTypeVarLiteral)EQUITY_SCREENER_EQ_MAPEQUITY_SCREENER_FIELDS)FUND_SCREENER_EQ_MAPFUND_SCREENER_FIELDS)ETF_SCREENER_EQ_MAPETF_SCREENER_FIELDSYFNotImplementedError   )dynamic_docstring'generate_list_table_from_dict_universalT)bound)	eqzis-inbtwngtltgtelteandorc                      \ rS rSrS\S\\S    \\   \\R                     4   4S jr
\\S\4S j5       5       r\\S\4S j5       5       rS\S    SS4S	 jrS\\\\R                  4      SS4S
 jrS\\\\R                  4      SS4S jrS\\\\R                  4      SS4S jrS\S    SS4S jrS\4S jrSS\4S jjrS\4S jrSrg)	QueryBase   operatoroperandc                    UR                  5       n[        U[        5      (       d  [        S5      e[	        U5      S::  a  [        S5      eUS:X  a  U R                  U5        OkUS;   a  U R                  U5        OSUS:X  a  U R                  U5        O;US:X  a  U R                  U5        O#US;   a  U R                  U5        O[        S	5      eXl        X l        g )
NzInvalid operand typer   zInvalid field for EquityQueryIS-IN>   ORANDEQBTWN>   GTLTGTELTEzInvalid Operator Value)upper
isinstancelist	TypeErrorlen
ValueError_validate_isin_operand_validate_or_and_operand_validate_eq_operand_validate_btwn_operand_validate_gt_ltr"   operands)selfr"   r#   s      h/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/yfinance/screener/query.py__init__QueryBase.__init__   s    >>#'4((233w<1<==w''0%))'2%%g.''000  )566     returnc                     [        S5      e)Nz/valid_fields() needs to be implemented by childr   r:   s    r;   valid_fieldsQueryBase.valid_fields(        $$UVVr>   c                     [        S5      e)Nz/valid_values() needs to be implemented by childr   rA   s    r;   valid_valuesQueryBase.valid_values-   rD   r>   Nc                     [        U5      S::  a  [        S5      e[        S U 5       5      SL a  [        S[	        U 5       S35      eg )N   z$Operand must be length longer than 1c              3   B   #    U  H  n[        U[        5      v   M     g 7fNr/   r    ).0es     r;   	<genexpr>5QueryBase._validate_or_and_operand.<locals>.<genexpr>5   s     9Az!Y''   FzOperand must be type z for OR/AND)r2   r3   allr1   typer:   r#   s     r;   r5   "QueryBase._validate_or_and_operand2   sL    w<1CDD999UB3DJ<{KLL Cr>   c                   ^ [        T5      S:w  a  [        S5      e[        U4S jU R                  R	                  5        5       5      (       d  [        S[        U 5       STS    S35      eTS   U R                  ;   ax  U R                  TS      n[        U[        5      (       a5  [        5       R                  " UR	                  5        Vs/ s H  o3PM     sn6 nTS   U;  a  [        S	TS    S35      eg g s  snf )
Nr   zOperand must be length 2 for EQc              3   4   >#    U  H  nTS    U;   v   M     g7fr   N rM   fields_by_typer#   s     r;   rO   1QueryBase._validate_eq_operand.<locals>.<genexpr><        bGa^GAJ.0Ga   Invalid field for  "r   "rI   Invalid EQ value ")r2   r3   anyrB   valuesrS   rF   r/   dictsetunion)r:   r#   vvrN   s    `  r;   r6   QueryBase._validate_eq_operand8   s    w<1>??btGXGXG_G_Gabbb1$t*R
|1MNN1:***""71:.B"d## U[[biik":k1k":;qz# #5gaj\!CDD $ +
 #;s   C8c                 x  ^ [        T5      S:w  a  [        S5      e[        U4S jU R                  R	                  5        5       5      (       d  [        S[        U 5       35      e[        TS   [        R                  5      SL a  [        S5      e[        TS   [        R                  5      SL a  [        S5      eg )	N   z!Operand must be length 3 for BTWNc              3   4   >#    U  H  nTS    U;   v   M     g7frX   rY   rZ   s     r;   rO   3QueryBase._validate_btwn_operand.<locals>.<genexpr>J   r]   r^   r_   rI   Fz Invalid comparison type for BTWNr   
r2   r3   rc   rB   rd   rS   r/   numbersRealr1   rT   s    `r;   r7    QueryBase._validate_btwn_operandG   s    w<1@AAbtGXGXG_G_Gabbb1$t*>??gaj',,/58>??gaj',,/58>?? 9r>   c                 0  ^ [        T5      S:w  a  [        S5      e[        U4S jU R                  R	                  5        5       5      (       d  [        S[        U 5       STS    S35      e[        TS   [        R                  5      S	L a  [        S
5      eg )Nr   z"Operand must be length 2 for GT/LTc              3   4   >#    U  H  nTS    U;   v   M     g7frX   rY   rZ   s     r;   rO   ,QueryBase._validate_gt_lt.<locals>.<genexpr>T   r]   r^   r_   r`   r   ra   rI   Fz!Invalid comparison type for GT/LTrn   rT   s    `r;   r8   QueryBase._validate_gt_ltQ   s    w<1ABBbtGXGXG_G_Gabbb1$t*R
|1MNNgaj',,/58?@@ 9r>   c                 2  ^ [        T5      S:  a  [        S5      e[        U4S jU R                  R	                  5        5       5      (       d  [        S[        U 5       STS    S35      eTS   U R                  ;   a  U R                  TS      n[        U[        5      (       a5  [        5       R                  " UR	                  5        Vs/ s H  o3PM     sn6 n[        S[        T5      5       H  nTU   U;  d  M  [        S	TU    S35      e   g g s  snf )
Nr   z#Operand must be length 2+ for IS-INc              3   4   >#    U  H  nTS    U;   v   M     g7frX   rY   rZ   s     r;   rO   3QueryBase._validate_isin_operand.<locals>.<genexpr>]   r]   r^   r_   r`   r   ra   rI   rb   )r2   r3   rc   rB   rd   rS   rF   r/   re   rf   rg   range)r:   r#   rh   rN   is    `   r;   r4    QueryBase._validate_isin_operandY   s    w<!BCCbtGXGXG_G_Gabbb1$t*R
|1MNN1:***""71:.B"d## U[[biik":k1k":;1c'l+1:R'$'9'!*Q%GHH , +
 #;s   Dc                 \   U R                   nU R                  nU R                   S:X  a@  SnU R                  SS   Vs/ s H$  n[        U 5      " SU R                  S   U/5      PM&     nnUU Vs/ s H*  n[        U[        5      (       a  UR                  5       OUPM,     snS.$ s  snf s  snf )Nr%   r&   rI   r(   r   )r"   r9   )r"   r9   rS   r/   r    to_dict)r:   opopsvos        r;   r}   QueryBase.to_dicti   s    ]]mm==G#BDHMMRSRTDUVDUq4:dT]]1%5q$9:DUCVQTUQTA
1i(@(@aGQTU
 	
 W Vs   +B$.1B)c                   ^^ ST-  mU R                   R                  n[        U R                  [        5      (       a  [        S U R                   5       5      (       a>  SR                  UU4S jU R                   5       5      nU SU R                   SU ST S3$ U SU R                   S	[        U R                  5       S
3$ U SU R                   S	[        U R                  5       S
3$ )N  c              3   B   #    U  H  n[        U[        5      v   M     g 7frK   rL   )rM   r~   s     r;   rO   %QueryBase.__repr__.<locals>.<genexpr>{   s     E}:b),,}rQ   z,
c              3      >#    U  H>  nT S [        U[        5      (       a  UR                  TS-   5      O
[        U5       3v   M@     g7f)r   rI   N)r/   r    __repr__repr)rM   r~   indent
indent_strs     r;   rO   r   }   sF      *+ "l"
2y@Y@YR[[!%<_cdf_g$hi+s   AA	(z, [

z])z, ))		__class____name__r/   r9   r0   rc   joinr"   r   )r:   r   
class_nameoperands_strr   s    `  @r;   r   QueryBase.__repr__u   s    F]
^^,,
dmmT**Et}}EEE$zz *"mm*   %Qt}}oU<.:,VXYY %Qt}}oRT]]8K7LANN !\4==/D4G3HJJr>   c                 "    U R                  5       $ rK   )r   rA   s    r;   __str__QueryBase.__str__   s    }}r>   )r9   r"   )r   )r   
__module____qualname____firstlineno__Operatorr   r   strro   rp   r<   propertyr   r   rB   rF   r5   r6   r7   r8   r4   r}   r   r   __static_attributes__rY   r>   r;   r    r       s\      E4;LdSViY]^e^j^jYk;k4m  0 Wd W  W Wd W  WM[0A Md MEDsGLL7H1I,J Et E@d5gll9J3K.L @QU @AtE#w||2C,D'E A$ AId;.? ID I 

 

KC K( r>   r    c                       \ rS rSrSr\" S\" \5      05      \S\	4S j5       5       r
\" S\" \SS/S	905      \S\	4S
 j5       5       rSrg)EquityQuery   a  
The `EquityQuery` class constructs filters for stocks based on specific criteria such as region, sector, exchange, and peer group.

Start with value operations: `EQ` (equals), `IS-IN` (is in), `BTWN` (between), `GT` (greater than), `LT` (less than), `GTE` (greater or equal), `LTE` (less or equal).

Combine them with logical operations: `AND`, `OR`.

Example:
    Predefined Yahoo query `aggressive_small_caps`:
    
    .. code-block:: python

        from yfinance import EquityQuery

        EquityQuery('and', [
            EquityQuery('is-in', ['exchange', 'NMS', 'NYQ']), 
            EquityQuery('lt', ["epsgrowth.lasttwelvemonths", 15])
        ])
valid_operand_fields_tabler?   c                     [         $ zC
Valid operands, grouped by category.
{valid_operand_fields_table}
)r   rA   s    r;   rB   EquityQuery.valid_fields   
     &%r>   valid_values_tableexchangeindustry)concat_keysc                     [         $ zh
Most operands take number values, but some have a restricted set of valid values.
{valid_values_table}
)r
   rA   s    r;   rF   EquityQuery.valid_values   r   r>   rY   N)r   r   r   r   __doc__r   r   r   r   r   rB   r
   rF   r   rY   r>   r;   r   r      s    ( 46]^t6uvw&d &  x& ,.UVl  |F  HR  {S  /T  U  V&d &  V&r>   r   c                       \ rS rSrSr\" S\" \5      05      \S\	4S j5       5       r
\" S\" \5      05      \S\	4S j5       5       rSrg	)
	FundQuery   aT  
The `FundQuery` class constructs filters for mutual funds based on specific criteria such as region, sector, exchange, and peer group.

Start with value operations: `EQ` (equals), `IS-IN` (is in), `BTWN` (between), `GT` (greater than), `LT` (less than), `GTE` (greater or equal), `LTE` (less or equal).

Combine them with logical operations: `AND`, `OR`.

Example:
    Predefined Yahoo query `solid_large_growth_funds`:
    
    .. code-block:: python

        from yfinance import FundQuery
        
        FundQuery('and', [
            FundQuery('eq', ['categoryname', 'Large Growth']), 
            FundQuery('is-in', ['performanceratingoverall', 4, 5]), 
            FundQuery('lt', ['initialinvestment', 100001]), 
            FundQuery('lt', ['annualreturnnavy1categoryrank', 50]), 
            FundQuery('eq', ['exchange', 'NAS'])
        ])
r   r?   c                     [         $ r   )r   rA   s    r;   rB   FundQuery.valid_fields   
     $#r>   r   c                     [         $ r   )r   rA   s    r;   rF   FundQuery.valid_values   r   r>   rY   N)r   r   r   r   r   r   r   r   r   r   rB   r   rF   r   rY   r>   r;   r   r      ss    , 46]^r6stu$d $  v$ ,.UVj.klm$d $  n$r>   r   c                       \ rS rSrSr\" S\" \5      05      \S\	4S j5       5       r
\" S\" \5      05      \S\	4S j5       5       rSrg	)
ETFQuery   a  
The `ETFQuery` class constructs filters for ETFs based on specific criteria such as category, fund family, exchange, and performance ratings.

Start with value operations: `EQ` (equals), `IS-IN` (is in), `BTWN` (between), `GT` (greater than), `LT` (less than), `GTE` (greater or equal), `LTE` (less or equal).

Combine them with logical operations: `AND`, `OR`.

Example:
    Predefined Yahoo query `top_etfs_us`:
    
    .. code-block:: python

        from yfinance import ETFQuery

        ETFQuery('and', [
            ETFQuery('gt', ['intradayprice', 10]),
            ETFQuery('is-in', ['performanceratingoverall', 4, 5]),
            ETFQuery('eq', ['region', 'us'])
        ])
r   r?   c                     [         $ r   )r   rA   s    r;   rB   ETFQuery.valid_fields   
     #"r>   r   c                     [         $ r   )r   rA   s    r;   rF   ETFQuery.valid_values   r   r>   rY   N)r   r   r   r   r   r   r   r   r   r   rB   r   rF   r   rY   r>   r;   r   r      ss    ( 46]^q6rst#d #  u# ,.UVi.jkl#d #  m#r>   r   )abcr   r   ro   typingr   r   r   r   r	   yfinance.constr
   r   r   r   r   r   yfinance.exceptionsr   utilsr   r   r   rp   r   r   r    r   r   r   rY   r>   r;   <module>r      sz    #  6 6 I E C 5 NCuS',,./0OP{ {|%&) %&P'$	 '$R%#y %#r>   