
    Q-j                         d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZ d dlmZmZmZ  ed      d        Z	 	 	 	 dd
e	dededededededede	fdZy	)    )njit)cosexpnansqrt
zeros_like)Series)DictLikeIntIntFloat)v_offsetv_pos_defaultv_seriesT)cachec                 b   | j                   d|z  |z  }}t        | |z        }d|z  t        d|z        z  }	||z  |	z
  dz   }
t        |       }t        |       }t        |       }t	        d|      D ]4  }d|
z  | |   | |dz
     z   z  |	||dz
     z  z   ||z  ||dz
     z  z
  ||<   6 t	        ||      D ]y  }|||z
     ||   z
  |z  }d}t	        d|      D ]  }|||   |||z
     z
  ||z  z   z  } ||z  }||z  |z  d|z
  ||dz
     z  z   ||<   ||   dk7  sf|t        ||         z  ||<   { |S )N         g      ?r   g        )sizer   r   r   ranger   )xnkalphapisqrt2mratioabc_f_msresultislope_sumjs                     d/Users/jameslopez/projects/TradingBot25/.venv/lib/python3.12/site-packages/pandas_ta/cycle/reflex.py	np_reflexr*   
   s   vvq5y1}uARC%KA	AC%K  A	A	AA	AB
Q-C]F1a[a1Q4!AE(?+a"QU)m;a!ebQi>OO1  1a[AERU"a'q!ABqEBq1uI%E	11D 	$E	SQZ'??Aq6S=tCF|+F1I  M    Ncloselengthsmoothr   r   r   offsetkwargsreturnc                    t        |d      }t        |d      }t        ||      dz   }t        | |      } | yt        |d      }t        |d      }t        |d      }t        |      }| j	                         }	t        |	|||||      }
t        |
d| t        |
| j                        }
|dk7  r|
j                  |      }
d	|v r|
j                  |d	   d
       d| d| d| |
_        d|
_        |
S )u  Reflex

    This cycle indicator, by John F. Ehlers, attempts to reduce lag.

    Sources:
        * [rengel8](https://github.com/rengel8) (2021-08-11) based on the
        implementation from "ProRealCode"
        * [traders.com](http://traders.com/Documentation/FEEDbk_docs/2020/02/TradersTips.html)
        * [prorealcode](https://www.prorealcode.com/prorealtime-indicators/reflex-and-trendflex-indicators-john-f-ehlers/)

    Parameters:
        close (Series): ```close``` Series
        length (int): The period. Default: ```20```
        smooth (int): SuperSmoother period. Default: ```20```
        alpha (float): Alpha weight of Difference Sums. Default: ```0.04```
        pi (float): Ehlers's truncated value: ```3.14159```.
            Default: ```3.14159```
        sqrt2 (float): Ehlers's truncated value: ```1.414```.
            Default: ```1.414```
        offset (int): Post shift. Default: ```0```

    Other Parameters:
        fillna (value): Replaces ```na```'s with ```value```.

    Returns:
        (Series): 1 column

    Tip:
        This implementation has a separate control parameter for the
        internal applied SuperSmoother.

    Note:
        John F. Ehlers introduced two indicators within the article
        "Reflex: A New Zero-Lag Indicator” in February 2020, TASC magazine.
        One of which is Reflex, a lag reduced cycle indicator. Both indicators
        (Reflex/Trendflex) are oscillators that complement each other with the
        focus for cycle and trend.
       r   Ng{Gz?gn!	@g9v?)indexr   fillnaT)inplaceREFLEX__cycle)r   maxr   r   to_numpyr*   r   r	   r4   shiftr5   namecategory)r,   r-   r.   r   r   r   r/   r0   _lengthnp_closer$   s              r)   reflexrA   '   s   Z 62&F62&F&&!A%GUG$E}%&E	r7	#B%'EfF ~~HxEBFF7FOF%++.F {f% 6fX&5 F81VHAeW5FKFOMr+   )NNNNNN)numbar   numpyr   r   r   r   r   pandasr	   pandas_ta._typingr
   r   r   pandas_ta.utilsr   r   r   r*   rA    r+   r)   <module>rH      s     1 1  5 5 = = D : "&*.+/	LLLL'L 	L !)L 	L #+	L
 Lr+   