
    'i]	                     N    d dl mZmZmZmZ d dlZ G d dej                        Zy)    )absolute_importdivisionprint_functionunicode_literalsNc                   &    e Zd ZdZdZd Zd Zd Zy)GrossLeverageae  This analyzer calculates the Gross Leverage of the current strategy
    on a timeframe basis

    Params:

      - ``fund`` (default: ``None``)

        If ``None`` the actual mode of the broker (fundmode - True/False) will
        be autodetected to decide if the returns are based on the total net
        asset value or on the fund value. See ``set_fundmode`` in the broker
        documentation

        Set it to ``True`` or ``False`` for a specific behavior

    Methods:

      - get_analysis

        Returns a dictionary with returns as values and the datetime points for
        each return as keys
    ))fundNc                     | j                   j                  &| j                  j                  j                  | _        y | j                   j                  | _        y N)pr	   strategybrokerfundmode	_fundmode)selfs    [/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/analyzers/leverage.pystartzGrossLeverage.start6   s6    66;;!]]11::DN!VV[[DN    c                 H    || _         | j                  s|| _        y || _        y r   )_cashr   _value)r   cashvalue	fundvaluesharess        r   notify_fundzGrossLeverage.notify_fund<   s    
~~DK#DKr   c                     | j                   | j                  z
  | j                   z  }|| j                  | j                  j                  j	                         <   y r   )r   r   retsdata0datetime)r   levs     r   nextzGrossLeverage.nextC   s@     {{TZZ'4;;647		$**%%..01r   N)__name__
__module____qualname____doc__paramsr   r   r"    r   r   r   r      s    ,F)$8r   r   )	
__future__r   r   r   r   
backtraderbtAnalyzerr   r(   r   r   <module>r-      s$   ** * ,8BKK ,8r   