
    'i                     \    d dl mZmZmZmZ ddlmZ g dZ G d de      Z G d de      Z	y	)
    )absolute_importdivisionprint_functionunicode_literals   )PeriodN)LaguerreRSILRSILaguerreFilterLAGFc                   H    e Zd ZdZdZdZdZ edg d      Zd\  Z	Z
ZZd	 Zy
)r	   a  
    Defined by John F. Ehlers in `Cybernetic Analysis for Stock and Futures`,
    2004, published by Wiley. `ISBN: 978-0-471-46307-8`

    The Laguerre RSI tries to implements a better RSI by providing a sort of
    *Time Warp without Time Travel* using a Laguerre filter. This provides for
    faster reactions to price changes

    ``gamma`` is meant to have values between ``0.2`` and ``0.8``, with the
    best balance found theoretically at the default of ``0.5``
    )r
   )lrsi)gamma      ?)period   g333333?)        g?r   g?      ?)plotymargin
plotyticksr   r   r   r   c                    | j                   }| j                  }| j                  }| j                  j                  }d|z
  | j
                  z  ||z  z   x| _         }| |z  |z   ||z  z   x| _        }| |z  |z   ||z  z   x| _        }| |z  |z   || j                  z  z   x| _        }d}	d}
||k\  r||z
  }	n||z
  }
||k\  r	|	||z
  z  }	n|
||z
  z  }
||k\  r	|	||z
  z  }	n|
||z
  z  }
|	|
z   }|sdn|	|z  | j                  j                  d<   y )Nr   r   r   )	l0l1l2pr   datal3linesr   )selfl0_1l1_1l2_1gr   r   r   r   cucddens               X/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/lrsi.pynextzLaguerreRSI.next8   s5   wwwwwwFFLLa499,q4x77"rBw~D00"rBw~D00"rBw~DGG33"8bBbB8"r'MB"r'MB8"r'MB"r'MB2g(+Sc

    N__name__
__module____qualname____doc__aliasr    paramsdictplotinfor   r   r   r   r*    r+   r)   r	   r	      s@    
 EEF
 ,H
 (NBB:r+   r	   c                   B    e Zd ZdZdZdZdZ ed      Zd\  Z	Z
ZZd Zy	)
r   a  
    Defined by John F. Ehlers in `Cybernetic Analysis for Stock and Futures`,
    2004, published by Wiley. `ISBN: 978-0-471-46307-8`

    ``gamma`` is meant to have values between ``0.2`` and ``0.8``, with the
    best balance found theoretically at the default of ``0.5``
    )r   )lfilter)r   F)subplotr   c                    | j                   }| j                  }| j                  }| j                  j                  }d|z
  | j
                  z  ||z  z   x| _         }| |z  |z   ||z  z   x| _        }| |z  |z   ||z  z   x| _        }| |z  |z   || j                  z  z   x| _        }|d|z  z   d|z  z   |z   dz  | j                  j                  d<   y )Nr      r   r   )	r   r   r   r   r   r   r   r    r7   )	r!   r"   r#   r$   r%   r   r   r   r   s	            r)   r*   zLaguerreFilter.nextg   s    wwwwwwFFLLa499,q4x77"rBw~D00"rBw~D00"rBw~DGG33"!#q2v!b&!9B!>! C

1r+   Nr,   r5   r+   r)   r   r   X   s5     EEFE"H'NBB
Dr+   r   N)

__future__r   r   r   r    r   __all__r	   r   r5   r+   r)   <module>r>      s6   ** *  <7:' 7:tDW Dr+   