
    '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
 G d d	e	      Z G d
 de      Zy)    )absolute_importdivisionprint_functionunicode_literals   )	IndicatorMaxMovAvc                   T     e Zd Zdddej                  ffZ edg      Z fdZ xZ	S )_PriceOscBase)period1   )period2   _movavg        )
plothlinesc                 v   | j                   j                  | j                  | j                   j                        | _        | j                   j                  | j                  | j                   j
                        | _        | j                  | j                  z
  | j                  d<   t        t        | +          y )Nperiodr   )pr   datar   ma1r   ma2linessuperr   __init__)self	__class__s    c/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/priceoscillator.pyr   z_PriceOscBase.__init__!   sr    66==466>>=B66==466>>=B488+

1mT+-    )
__name__
__module____qualname__r
   Exponentialparamsdictplotinfor   __classcell__r   s   @r   r   r      s5    **+.F u%H. .r    r   c                       e Zd ZdZdZdZy)PriceOscillatorz
    Shows the difference between a short and long exponential moving
    averages expressed in points.

    Formula:
      - po = ema(short) - ema(long)

    See:
      - http://www.metastock.com/Customer/Resources/TAAZ/?c=3&p=94
    )PriceOscAbsolutePriceOscillatorAPOAbsPriceOsc)poN)r!   r"   r#   __doc__aliasr    r    r   r+   r+   )   s    	 KEEr    r+   c                   V     e Zd ZdZdZdZdZdZ e eddd	      
      Z	 fdZ
 xZS )PercentagePriceOscillatora  
    Shows the difference between a short and long exponential moving
    averages expressed in percentage. The MACD does the same but expressed in
    absolute points.

    Expressing the difference in percentage allows to compare the indicator at
    different points in time when the underlying value has significatnly
    different values.

    Formula:
      - po = 100 * (ema(short) - ema(long)) / ema(long)

    See:
      - http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:price_oscillators_ppo
    T)PPOPercPriceOsc)pposignalhisto))period_signal	   barg      ?g      ?)_methodalphawidth)r:   c                    t         t        |           | j                  r| j                  n| j
                  }d| j                  d   z  |z  | j                  _        | j                  j                  | j                  j                  | j                  j                        | j                  _        | j                  j                  | j                  j                  z
  | j                  _        y )Ng      Y@r   r   )r   r5   r   _longr   r   r   r8   r   r   lr;   r9   r:   )r   denr   s     r   r   z"PercentagePriceOscillator.__init__Q   s    '79**dhh$((A.4

dffjj9M9MN::>>DJJ,=,==

r    )r!   r"   r#   r1   rB   r2   r   r%   r&   	plotlinesr   r(   r)   s   @r   r5   r5   8   s;     E$E&E$F4TEFI> >r    r5   c                       e Zd ZdZdZdZy)PercentagePriceOscillatorShorta  
    Shows the difference between a short and long exponential moving
    averages expressed in percentage. The MACD does the same but expressed in
    absolute points.

    Expressing the difference in percentage allows to compare the indicator at
    different points in time when the underlying value has significatnly
    different values.

    Most on-line literature shows the percentage calculation having the long
    exponential moving average as the denominator. Some sources like MetaStock
    use the short one.

    Formula:
      - po = 100 * (ema(short) - ema(long)) / ema(short)

    See:
      - http://www.metastock.com/Customer/Resources/TAAZ/?c=3&p=94
    F)PPOShortPercPriceOscShortN)r!   r"   r#   r1   rB   r2   r3   r    r   rG   rG   [   s    & E.Er    rG   N)
__future__r   r   r   r    r   r	   r
   r   r+   r5   rG   r3   r    r   <module>rL      sI   ** * $ #.I .m  >  >F/%> /r    