
    i;                         S SK J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JrJrJrJrJr  \" SS9S 5       r   SS
\
S\S\S\S\S\S\S\S\	4S jjrg	)    )njit)clipcumsumint64nanwhere)	DataFrameSeries)DictLikeInt)nb_ffillnb_idiffv_boolv_intv_offsetv_pos_defaultv_seriesT)cachec                    [        X5      nUS:  US:  p[        U5      n	[        U5      n
U	[        [        U) U	[        5      5      -
  nU
[        [        U) U
[        5      5      -
  nUS:  a  [        USU5      n[        USU5      nU(       a#  [        US:H  SU5      n[        US:H  SU5      nX4$ X:  X:*  -  n[        XS5      n[        XS5      nX4$ )Nr   )r   r   r   r   r   r   )xncaplbubshow_allx_diffneg_diffpos_diffdn_csumup_csumdnup
between_lus                 R/var/www/html/trading/venv/lib/python3.13/site-packages/pandas_ta/momentum/exhc.pynb_exhcr%      s    a^F!VaZhXGXG	8E8)Wc:;	;B	8E8)Wc:;	;B
Qw"a"a27Ar"27Ar" 6M	 h28,
:1%:1%6M    Ncloselengthr   asintr   nozerosoffsetkwargsreturnc                 J   [        US5      n[        XS-   5      n U c  g[        USS5      n[        US5      n[        US5      n[        US5      n[	        U5      nU R                  5       n[        XUSS	U5      u  pU(       a*  U	R                  [        5      n	U
R                  [        5      n
U(       a  S
OSU	U(       a  SOSU
0n[        XR                  S9nU(       a  SOSUl        SUl        U(       a  UR                  S[        0SS9  US:w  a  UR                  U5      nU$ )a  Exhaustion Count

This indicator attempts to identify rising/falling exhaustion.

Sources:
    * [demark](https://demark.com)
    * [practicaltechnicalanalysis](http://practicaltechnicalanalysis.blogspot.com/2013/01/tom-demark-sequential.html)

Parameters:
    close (Series): Series of close's
    length (int): The period. Default: ```4```
    cap (int): Count cap. For no cap, set to ```0```. Default: ```13```
    show_all (bool): Counts 1 - 13. For 6 - 9, set to ```False```.
        Default: ```True```
    asint (bool): Returns as ```Int```. Default: ```False```
    nozeros (bool): Replace zeros with ```np.nan```. Default: ```False```
    offset (int): Post shift. Default: ```0```

Returns:
    (DataFrame): 2 columns

Note:
    Similar to TD Sequential
      N   TF   	   EXHC_DNaEXHC_DNEXHC_UPaEXHC_UP)indexEXHCaEXHCmomentumr   )inplace)r   r   r   r   r   to_numpyr%   astyper   r	   r9   namecategoryreplacer   shift)r'   r(   r   r)   r   r*   r+   r,   np_closer!   r"   datadfs                r$   exhcrG   ,   s   < 61%FUQJ'E}
R
Ch%H5% EWe$GfF ~~HXsAq(;FBYYuYYu 
Ir
IrD 
4{{	+B!gvBGBK


As8T
* {XXfIr&   )NNNNNN)numbar   numpyr   r   r   r   r   pandasr	   r
   pandas_ta._typingr   r   pandas_ta.utilsr   r   r   r   r   r   r   r%   boolrG    r&   r$   <module>rO      s     1 1 $ +   D 4 37?CBBB,/BB"&B8<B B #+B 	Br&   