
    'i                         d dl mZmZmZmZ ddl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   )	Indicatorc                   >     e Zd ZdZdZdZ edg      Z fdZ xZ	S )Momentuma
  
    Measures the change in price by calculating the difference between the
    current price and the price from a given period ago


    Formula:
      - momentum = data - data_period

    See:
      - http://en.wikipedia.org/wiki/Momentum_(technical_analysis)
    )momentumperiod   g        )
plothlinesc                     | j                   | j                  | j                  j                         z
  | j                  _        t
        t        |           y N)datapr   lr   superr
   __init__self	__class__s    \/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/momentum.pyr   zMomentum.__init__+   s7    ))dii&??h&(    )
__name__
__module____qualname____doc__linesparamsdictplotinfor   __classcell__r   s   @r   r
   r
      s*    
 EFu%H) )r   r
   c                   :     e Zd ZdZdZdZdZd Zd Z fdZ	 xZ
S )MomentumOscillatorz
    Measures the ratio of change in prices over a period

    Formula:
      - mosc = 100 * (data / data_period)

    See:
      - http://ta.mql4.com/indicators/oscillators/momentum
    )MomentumOsc)momosc)r   )band      Y@c                 4    | j                   j                  g}|S r   )r   r   )r   plabelss     r   
_plotlabelzMomentumOscillator._plotlabelC   s    66==/r   c                 P    | j                   j                  g| j                  _        y r   )r   r+   r$   r   )r   s    r   	_plotinitzMomentumOscillator._plotinitG   s    $(FFKK= r   c                     d| j                   | j                  | j                  j                         z  z  | j                  _        t
        t        |           y )Nr,   )r   r   r   r   r*   r   r(   r   r   s    r   r   zMomentumOscillator.__init__J   s=    TYY~-F!FG $02r   )r   r   r   r    aliasr!   r"   r/   r1   r   r%   r&   s   @r   r(   r(   0   s1     E EF13 3r   r(   c                   .     e Zd ZdZdZdZdZ fdZ xZS )RateOfChangez
    Measures the ratio of change in prices over a period

    Formula:
      - roc = (data - data_period) / data_period

    See:
      - http://en.wikipedia.org/wiki/Momentum_(technical_analysis)
    )ROC)rocr   c                     | j                  | j                  j                         }| j                   |z
  |z  | j                  _        t
        t        |           y r   )r   r   r   r   r7   r   r5   r   )r   dperiodr   s     r   r   zRateOfChange.__init__a   sA    ))TVV]]N+ii')W4
lD*,r   	r   r   r   r    r3   r!   r"   r   r%   r&   s   @r   r5   r5   O   s'     E E F- -r   r5   c                   .     e Zd ZdZdZdZdZ fdZ xZS )RateOfChange100aK  
    Measures the ratio of change in prices over a period with base 100

    This is for example how ROC is defined in stockcharts

    Formula:
      - roc = 100 * (data - data_period) / data_period

    See:
      - http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:rate_of_change_roc_and_momentum

    )ROC100)roc100r   c                     dt        | j                  | j                  j                        z  | j                  _        t        t        | #          y )Nr,   )r   )	r6   r   r   r   r   r>   r   r<   r   r   s    r   r   zRateOfChange100.__init__|   s3    DIIdffmm DDot-/r   r:   r&   s   @r   r<   r<   g   s'     E E F0 0r   r<   N)
__future__r   r   r   r    r   r
   r(   r5   r<    r   r   <module>rC      sD   ** * )y )*3 3>-9 -00i 0r   