
    'i                     \    d dl mZmZmZmZ ddlmZmZmZ  G d de      Z	 G d de      Z
y)	    )absolute_importdivisionprint_functionunicode_literals   )	IndicatorMovingAverageBaseMovAvc                   H     e Zd ZdZdZdZdej                  ffZ fdZ	 xZ
S )DoubleExponentialMovingAveragea|  
    DEMA was first time introduced in 1994, in the article "Smoothing Data with
    Faster Moving Averages" by Patrick G. Mulloy in "Technical Analysis of
    Stocks & Commodities" magazine.

    It attempts to reduce the inherent lag associated to Moving Averages

    Formula:
      - dema = (2.0 - ema(data, period) - ema(ema(data, period), period)

    See:
      (None)
    )DEMAMovingAverageDoubleExponential)dema_movavc                 0   | j                   j                  | j                  | j                   j                        }| j                   j                  || j                   j                        }d|z  |z
  | j                  _        t        t        | #          y )Nperiodg       @)	pr   datar   linesr   superr   __init__)selfemaema2	__class__s      X/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/dema.pyr   z'DoubleExponentialMovingAverage.__init__/   se    ffmmDIIdffmmm<vv}}S}7)d*

,d<>    __name__
__module____qualname____doc__aliasr   r
   EMAparamsr   __classcell__r   s   @r   r   r      s/     8EE#%F? ?r   r   c                   H     e Zd ZdZdZdZdej                  ffZ fdZ	 xZ
S )TripleExponentialMovingAveragea  
    TEMA was first time introduced in 1994, in the article "Smoothing Data with
    Faster Moving Averages" by Patrick G. Mulloy in "Technical Analysis of
    Stocks & Commodities" magazine.

    It attempts to reduce the inherent lag associated to Moving Averages

    Formula:
      - ema1 = ema(data, period)
      - ema2 = ema(ema1, period)
      - ema3 = ema(ema2, period)
      - tema = 3 * ema1 - 3 * ema2 + ema3

    See:
      (None)
    )TEMAMovingAverageTripleExponential)temar   c                    | j                   j                  | j                  | j                   j                        }| j                   j                  || j                   j                        }| j                   j                  || j                   j                        }d|z  d|z  z
  |z   | j                  _        t        t        | #          y )Nr   g      @)	r   r   r   r   r   r-   r   r*   r   )r   ema1r   ema3r   s       r   r   z'TripleExponentialMovingAverage.__init__M   s    vv}}TYYtvv}}}=vv}}T$&&--}8vv}}T$&&--}8*sTz1D8

,d<>r   r   r(   s   @r   r*   r*   7   s/      8EE#%F? ?r   r*   N)
__future__r   r   r   r    r   r	   r
   r   r*    r   r   <module>r4      s1   ** * 2 1?%6 ?6?%6 ?r   